diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-09-26 14:04:58 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-09-26 14:04:58 +0100 |
commit | 98f6297ab4bc566f3496f4cfa4e6d7d8b41fdbe6 (patch) | |
tree | b6f5d4113f779bcebae46ba95f4ed54b3c6d1d97 | |
parent | ab81582f30b886544a3010e8f33b964fbe4a30b0 (diff) | |
download | gall-98f6297ab4bc566f3496f4cfa4e6d7d8b41fdbe6.tar.gz |
REPOSITORY: Support annotated tags in :merge_base()
-rw-r--r-- | lib/gall/repository.lua | 14 | ||||
-rw-r--r-- | test/test-gall.repository.lua | 8 | ||||
-rw-r--r-- | test/test_repo.tar | bin | 92160 -> 92160 bytes |
3 files changed, 20 insertions, 2 deletions
diff --git a/lib/gall/repository.lua b/lib/gall/repository.lua index 0e2c2d5..70381cb 100644 --- a/lib/gall/repository.lua +++ b/lib/gall/repository.lua @@ -218,8 +218,18 @@ if ll.git2 then if get_all then return old_merge_base(self, sha_1, sha_2, get_all) end - local oid_1 = ll.git2.OID.hex(sha_1) - local oid_2 = ll.git2.OID.hex(sha_2) + local commitish_1 = self:get(sha_1) + local commitish_2 = self:get(sha_2) + pcall(function() + if commitish_1.type == "tag" then + commitish_1 = commitish_1.content.object + end + if commitish_2.type == "tag" then + commitish_2 = commitish_2.content.object + end + end) + local oid_1 = ll.git2.OID.hex(commitish_1.sha) + local oid_2 = ll.git2.OID.hex(commitish_2.sha) local oid_base, err = ll.git2.merge.base(self.git2.repo, oid_1, oid_2) if not oid_base then if tostring(err) == "ENOTFOUND" then diff --git a/test/test-gall.repository.lua b/test/test-gall.repository.lua index 8fb6ab9..f945864 100644 --- a/test/test-gall.repository.lua +++ b/test/test-gall.repository.lua @@ -214,6 +214,14 @@ function suite.merge_base_nobase() assert(ok == true) end +function suite.merge_base_annotated_tags() + local repo = test_repo() + local sha_1 = "annotated-1" + local sha_2 = "annotated-2" + local sha_b = "b972b3345490a898f46df143a7285cb7840b9845" + assert(repo:merge_base(sha_1, sha_2) == sha_b) +end + function suite.rev_list() local repo = test_repo() local sha_new = "0b65c32b6a5277ff0e75ddad9e3914148914042d" diff --git a/test/test_repo.tar b/test/test_repo.tar Binary files differindex 614b8aa..dcfc172 100644 --- a/test/test_repo.tar +++ b/test/test_repo.tar |