[Bps-public-commit] smokingit branch, anna, updated. bc133ecd7d533ec621b307e0cb5093124b97fbf8
Alex Vandiver
alexmv at bestpractical.com
Wed May 29 02:33:09 EDT 2013
The branch, anna has been updated
via bc133ecd7d533ec621b307e0cb5093124b97fbf8 (commit)
via 701e540064c11d2ba86f74c14197a9b00af59f02 (commit)
via 60bb6c2b1e80a9fc8cf2fd1eae164f02234cad88 (commit)
via df83b40a28c0509b30e4bc76cdc87cda226f607e (commit)
via 03dcc9484440be62bac9e87d1f7c5040b35648d1 (commit)
from de1a679dfedc0475bd1b99c00166308c3790f003 (commit)
Summary of changes:
lib/Smokingit/Action/Test.pm | 57 +++++++++++++++++++++++++++++++-----------
lib/Smokingit/IRC.pm | 2 +-
lib/Smokingit/Model/Branch.pm | 5 ++++
lib/Smokingit/Model/Project.pm | 17 +++++++------
4 files changed, 58 insertions(+), 23 deletions(-)
- Log -----------------------------------------------------------------
commit 03dcc9484440be62bac9e87d1f7c5040b35648d1
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed May 29 02:01:23 2013 -0400
Support retest of rt:master[sqlite] instead of just deadbeef[sqlite]
diff --git a/lib/Smokingit/Action/Test.pm b/lib/Smokingit/Action/Test.pm
index fe0e309..d4d1514 100644
--- a/lib/Smokingit/Action/Test.pm
+++ b/lib/Smokingit/Action/Test.pm
@@ -21,23 +21,50 @@ sub validate_commit {
my $self = shift;
my $arg = shift;
- unless ($arg =~ /^([0-9a-fA-F]+)(?:\s*\[\s*(.*)\s*\])?(?:\s*\{\s*(.*)\s*\})?$/) {
+ unless ($arg =~ m{^\s*([0-9a-f]+|(?:\S+?:)?\S+?)(?:\s*\[\s*([^\]]+)\s*\])?(?:\s*\{\s*[^\}]+\s*\})?\s*$}i) {
return $self->validation_error(
- commit => "That doesn't look like a SHA" );
+ commit => "That doesn't look like a valid ref" );
}
- my ($sha,$config_text, $branch_text) = ($1, $2, $3);
-
- my $commits = Smokingit::Model::CommitCollection->new;
- $commits->limit( column => "sha", operator => "like", value => "$sha%" );
- return $self->validation_error(
- commit => "Unknown SHA $sha"
- ) if $commits->count == 0;
- return $self->validation_error(
- commit => "Ambiguous SHA (".$commits->count." matches)"
- ) if $commits->count > 1;
-
- my $commit = $commits->first;
- $sha = $commit->sha;
+ my ($ref,$config_text, $branch_text) = ($1, $2, $3);
+
+ my $commit;
+ if ($ref =~ /^[0-9a-f]+$/) {
+ my $commits = Smokingit::Model::CommitCollection->new;
+ $commits->limit( column => "sha", operator => "like", value => "$ref%" );
+ return $self->validation_error(
+ commit => "Unknown SHA $ref"
+ ) if $commits->count == 0;
+ return $self->validation_error(
+ commit => "Ambiguous SHA (".$commits->count." matches)"
+ ) if $commits->count > 1;
+ $commit = $commits->first;
+ } else {
+ my ($project, $branch) = $ref =~ /^\s*(?:(\S+):)?(\S+)\s*$/;
+ my $branches = Smokingit::Model::BranchCollection->new;
+ $branches->limit( column => "name", value => "$branch" );
+
+ if ($project) {
+ my $project_obj = Smokingit::Model::Project->new;
+ $project_obj->load_by_cols( name => $project );
+ return $self-> validation_error(
+ commit => "No such project $project"
+ ) unless $project_obj->id;
+ $branches->limit( column => "project_id", value => $project_obj->id );
+ }
+
+ return $self->validation_error(
+ commit => "No branch $branch found",
+ ) if $branches->count == 0;
+ return $self->validation_error(
+ commit => "Ambiguous branch (".$branches->count." matches)"
+ ) if $branches->count > 1;
+
+ $commit = $branches->first->current_commit;
+ $branch_text ||= $branches->first->name;
+ }
+
+
+ my $sha = $commit->sha;
if (not $config_text) {
# We'll do all of them
commit df83b40a28c0509b30e4bc76cdc87cda226f607e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed May 29 02:22:49 2013 -0400
Combine listing of refs with current SHA extraction, for speed
diff --git a/lib/Smokingit/Model/Project.pm b/lib/Smokingit/Model/Project.pm
index 44a84bb..f724121 100644
--- a/lib/Smokingit/Model/Project.pm
+++ b/lib/Smokingit/Model/Project.pm
@@ -167,9 +167,9 @@ sub sync {
local $ENV{GIT_DIR} = $self->repository_path;
my %branches;
- for ($self->repository->ref_names) {
- next unless s{^refs/heads/}{};
- $branches{$_}++;
+ for my $line (`git for-each-ref refs/heads/`) {
+ next unless $line =~ m{^([a-f0-9]+)\s+commit\s+refs/heads/(\S+)};
+ $branches{$2} = $1;
}
my @messages;
@@ -180,8 +180,7 @@ sub sync {
push @messages, $branch->name." deleted";
next;
}
- delete $branches{$branch->name};
- my $new_ref = $self->repository->ref_sha1("refs/heads/" . $branch->name);
+ my $new_ref = delete $branches{$branch->name};
my $old_ref = $branch->current_commit->sha;
next if $new_ref eq $old_ref;
@@ -198,7 +197,6 @@ sub sync {
for my $name (($has_master ? ("master") : ()), sort keys %branches) {
warn "New branch $name\n";
my $trunk = ($name eq "master");
- my $sha = $self->repository->ref_sha1("refs/heads/$name");
my $branch = Smokingit::Model::Branch->new;
my $status = $trunk ? "master" :
$test_new ? "hacking" :
@@ -206,7 +204,7 @@ sub sync {
my ($ok, $msg) = $branch->create(
project_id => $self->id,
name => $name,
- sha => $sha,
+ sha => $branches{$name},
status => $status,
long_status => "",
to_merge_into => undef,
commit 60bb6c2b1e80a9fc8cf2fd1eae164f02234cad88
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed May 29 02:24:45 2013 -0400
Allow for passing one or more branches to synchronize
diff --git a/lib/Smokingit/Model/Project.pm b/lib/Smokingit/Model/Project.pm
index f724121..2a21023 100644
--- a/lib/Smokingit/Model/Project.pm
+++ b/lib/Smokingit/Model/Project.pm
@@ -149,6 +149,9 @@ sub update_repository {
sub sync {
my $self = shift;
+ my $filter;
+ $filter->{$_} = 1 for @_;
+
# Start a txn
Jifty->handle->begin_transaction;
@@ -169,12 +172,14 @@ sub sync {
my %branches;
for my $line (`git for-each-ref refs/heads/`) {
next unless $line =~ m{^([a-f0-9]+)\s+commit\s+refs/heads/(\S+)};
+ next if $filter and not $filter->{$2};
$branches{$2} = $1;
}
my @messages;
my $branches = $self->branches;
while (my $branch = $branches->next) {
+ next if $filter and not $filter->{$branch->name};
if (not $branches{$branch->name}) {
$branch->delete;
push @messages, $branch->name." deleted";
commit 701e540064c11d2ba86f74c14197a9b00af59f02
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed May 29 02:25:00 2013 -0400
Helper method on branches to update just them
diff --git a/lib/Smokingit/Model/Branch.pm b/lib/Smokingit/Model/Branch.pm
index cefdedf..8338aae 100644
--- a/lib/Smokingit/Model/Branch.pm
+++ b/lib/Smokingit/Model/Branch.pm
@@ -102,6 +102,11 @@ sub create {
return ($ok, $msg);
}
+sub sync {
+ my $self = shift;
+ return $self->project->sync( $self->name );
+}
+
sub guess_merge_into {
my $self = shift;
commit bc133ecd7d533ec621b307e0cb5093124b97fbf8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed May 29 02:25:18 2013 -0400
Update just the relevant branch before checking status
diff --git a/lib/Smokingit/IRC.pm b/lib/Smokingit/IRC.pm
index 5c59786..29c78d1 100644
--- a/lib/Smokingit/IRC.pm
+++ b/lib/Smokingit/IRC.pm
@@ -146,7 +146,7 @@ sub do_status {
# Need to re-parse if this got any updates
return $self->do_status($incoming, $what)
- if $matches[0]->project->as_superuser->sync;
+ if $matches[0]->as_superuser->sync;
$what = $matches[0]->current_commit;
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list