[Bps-public-commit] Test-Chimps-Client branch, master, updated. 101986be50b86344291f7dad307d4f59438e22e9
Alex M Vandiver
alexmv at bestpractical.com
Fri Dec 11 20:12:15 EST 2009
The branch, master has been updated
via 101986be50b86344291f7dad307d4f59438e22e9 (commit)
from d48756903e0654ef2fca3ee565add39e778d42d6 (commit)
Summary of changes:
lib/Test/Chimps/Smoker.pm | 2 +
lib/Test/Chimps/Smoker/Git.pm | 64 +++++++++++++++++++++----------------
lib/Test/Chimps/Smoker/Source.pm | 1 +
3 files changed, 39 insertions(+), 28 deletions(-)
- Log -----------------------------------------------------------------
commit 101986be50b86344291f7dad307d4f59438e22e9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Dec 11 20:08:27 2009 -0500
Proper git testing or merge commits and branches
In order to correctly deal with merge commits, we must store not just
one "tested" commit, but an arbitrary set of them. Thus, when
approaching a merge commit, we ask Git for "all revisions in the
branch, ignoring those which are descendants of the tested ones"
using:
git rev-list branchname ^tested1 ^tested2
diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 3e4d284..43204db 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -331,6 +331,8 @@ sub update_revision_in_config {
my $self = shift;
my ($project, $revision) = @_;
+ $revision = $self->source($project)->store_tested_revision($revision);
+
my $tmp = LoadFile($self->config_file);
$tmp->{$project}->{revision} = $self->config->{$project}->{revision} = $revision;
$self->source($project)->revision($revision);
diff --git a/lib/Test/Chimps/Smoker/Git.pm b/lib/Test/Chimps/Smoker/Git.pm
index 9c2fb3b..a672c69 100644
--- a/lib/Test/Chimps/Smoker/Git.pm
+++ b/lib/Test/Chimps/Smoker/Git.pm
@@ -12,21 +12,6 @@ sub _init {
return $self->SUPER::_init( @_ );
}
-sub revision_after {
- my $self = shift;
- my $revision = shift;
-
- # stolen shamelessly from post-receive-email
- # this probably still loops and needs some date support
- # or a stash or shas to test
- my $branch = $self->branch;
- my $cmd = "git rev-parse --not --branches | grep -v \$(git rev-parse $branch) | git rev-list --stdin $revision..origin/$branch | tail -n 1";
- my $next = `$cmd`;
- chomp($next);
-
- return $next;
-}
-
sub committer {
my $self = shift;
my $revision = shift;
@@ -69,7 +54,13 @@ sub clone {
$self->run_cmd( 'checkout', '-t', '-b', $self->branch, 'origin/'.$self->branch );
}
- $self->revision($self->branch . "^") unless $self->revision;
+ unless ($self->revision) {
+ # Default is that we've tested all parents of the current
+ # revision, but not the current revision itself.
+ my $branch = $self->branch;
+ my $rev = `git log $branch --format='\%P' -n 1`; chomp $rev;
+ $self->revision($rev);
+ }
return 1;
}
@@ -90,25 +81,42 @@ sub checkout {
sub next {
my $self = shift;
- my $current = $self->revision;
+ # Get more revisions
+ $self->run_cmd('remote', 'update');
- my $revision = $self->revision_after( $current );
- unless ( $revision ) {
- $self->run_cmd('pull');
- $revision = $self->revision_after( $current );
- return () unless $revision;
- }
+ # In rev-list terms, "everything that isn't these commit, or an
+ # ancestor of them"
+ my $branch = $self->branch;
+ my @seen = map {"^$_"} split ' ', $self->revision;
+ my @revs = split /\n/, `git rev-list refs/remotes/origin/$branch @seen`;
- my $committer = $self->committer($revision);
- my $committed_date = $self->committed_date($revision);
+ return () unless @revs;
+ my $rev = pop @revs;
return (
- revision => $revision,
- committer => $committer,
- committed_date => $committed_date,
+ revision => $rev,
+ committer => $self->committer($rev),
+ committed_date => $self->committed_date($rev),
);
}
+sub store_tested_revision {
+ my $self = shift;
+ my $ref = shift;
+ my @oldrefs = split ' ', $self->revision;
+ my $branch = $self->branch;
+
+ # We need to determine if we can simplify the list of refs that
+ # we've seen. If the new ref is good enough to block off all of
+ # the other pending refs (it's a merge commit, a child of all of
+ # them), then we only need to store it; otherwise, we append.
+ my $with_prev = `git rev-list refs/remotes/origin/$branch ^$ref @{[map {"^$_"} @oldrefs]}`;
+ my $only_new = `git rev-list refs/remotes/origin/$branch ^$ref`;
+
+ return $ref if $with_prev eq $only_new;
+ return "$ref @oldrefs";
+}
+
sub run_cmd {
my $self = shift;
return $self->SUPER::run_cmd( "git", @_ );
diff --git a/lib/Test/Chimps/Smoker/Source.pm b/lib/Test/Chimps/Smoker/Source.pm
index 7368db5..51af660 100644
--- a/lib/Test/Chimps/Smoker/Source.pm
+++ b/lib/Test/Chimps/Smoker/Source.pm
@@ -183,6 +183,7 @@ sub checkout { return 1 }
sub clean { return 1 }
sub next { return () }
+sub store_tested_revision { return shift }
sub run_cmd {
my $self = shift;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list