test/import/test_git.rb in autobuild-1.9.0.b1 vs test/import/test_git.rb in autobuild-1.9.0.b2

- old
+ new

@@ -70,11 +70,11 @@ end it "returns false if the specified name does not resolve to an object" do assert !importer.has_commit?(pkg, 'blabla') end it "returns false if the specified commit is not present locally" do - assert !importer.has_commit?(pkg, '1ddb20665622279700770be09f9a291b37c9b631') + assert !importer.has_commit?(pkg, 'c8cf0798b1d53931314a86bdb3e2ad874eb8deb5') end it "raises for any other error" do flexmock(Autobuild::Subprocess).should_receive(:run). and_raise(Autobuild::SubcommandFailed.new('test', 'test', 'bla', 200)) assert_raises(Autobuild::SubcommandFailed) do @@ -203,12 +203,38 @@ importer.run_git(pkg, 'rm', delfile) assert Autobuild::Git.has_uncommitted_changes?(pkg) end end + describe "#commit_present_in?" do + attr_reader :commits + before do + importer.import(pkg) + @commits = [ + importer.rev_parse(pkg, 'HEAD'), + importer.rev_parse(pkg, 'HEAD~1')] + end + + it "returns true if the revision is in the provided branch" do + assert importer.commit_present_in?(pkg, 'HEAD', 'master') + assert importer.commit_present_in?(pkg, commits[0], 'master') + assert importer.commit_present_in?(pkg, 'HEAD~1', 'master') + assert importer.commit_present_in?(pkg, commits[1], 'master') + end + it "returns false if the revision is not in the provided branch" do + importer.run_git(pkg, 'branch', 'fork', 'autobuild/fork') + assert !importer.commit_present_in?(pkg, commits[0], "refs/heads/fork") + end + # git rev-parse return the tag ID for annotated tags instead of the + # commit ID. This was in turn breaking commit_present_in? + it "handles annotated tags properly" do + importer.run_git(pkg, 'tag', '-a', '-m', 'tag0', "tag0", "HEAD~1") + assert importer.commit_present_in?(pkg, 'tag0', 'master') + end + end + describe "update" do def self.common_commit_and_tag_behaviour - it "does not access the repository if the target is already merged and reset is false" do importer.import(pkg) # We relocate to a non-existing repository to ensure that it # does not try to access it