diff options
author | Chris Marchesi <chrism@vancluevertech.com> | 2018-08-23 10:14:21 -0700 |
---|---|---|
committer | Chris Marchesi <chrism@vancluevertech.com> | 2018-08-23 10:14:21 -0700 |
commit | 119459a6b9ddaa244f76f67b182bf2c627434d02 (patch) | |
tree | 611bf3d9f65a3f688f9456b4cc029f78ec46e94c /repository_test.go | |
parent | 8d8d4c52f42d5e5e7eccd8e51671b7d73d331ea0 (diff) | |
download | go-git-119459a6b9ddaa244f76f67b182bf2c627434d02.tar.gz |
git: Discern tag target type from supplied hash
I figured there was a way to do this without having to have
TagObjectOptions supply this in - there is.
Added support for this in and removed the object type from
TagObjectOptions.
Signed-off-by: Chris Marchesi <chrism@vancluevertech.com>
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/repository_test.go b/repository_test.go index fd80152..795ee55 100644 --- a/repository_test.go +++ b/repository_test.go @@ -1333,9 +1333,8 @@ func (s *RepositorySuite) TestCreateTagAnnotated(c *C) { expectedHash := h.Hash() ref, err := r.CreateTag("foobar", expectedHash, &TagObjectOptions{ - Tagger: defaultSignature(), - Message: "foo bar baz qux", - TargetType: plumbing.CommitObject, + Tagger: defaultSignature(), + Message: "foo bar baz qux", }) c.Assert(err, IsNil) @@ -1364,32 +1363,32 @@ func (s *RepositorySuite) TestCreateTagAnnotatedBadOpts(c *C) { expectedHash := h.Hash() ref, err := r.CreateTag("foobar", expectedHash, &TagObjectOptions{ - Message: "foo bar baz qux", - TargetType: plumbing.CommitObject, + Message: "foo bar baz qux", }) c.Assert(ref, IsNil) c.Assert(err, Equals, ErrMissingTagger) ref, err = r.CreateTag("foobar", expectedHash, &TagObjectOptions{ - Tagger: defaultSignature(), - TargetType: plumbing.CommitObject, + Tagger: defaultSignature(), }) c.Assert(ref, IsNil) c.Assert(err, Equals, ErrMissingMessage) +} - ref, err = r.CreateTag("foobar", expectedHash, &TagObjectOptions{ +func (s *RepositorySuite) TestCreateTagAnnotatedBadHash(c *C) { + url := s.GetLocalRepositoryURL( + fixtures.ByURL("https://github.com/git-fixtures/tags.git").One(), + ) + + r, _ := Init(memory.NewStorage(), nil) + err := r.clone(context.Background(), &CloneOptions{URL: url}) + c.Assert(err, IsNil) + + ref, err := r.CreateTag("foobar", plumbing.ZeroHash, &TagObjectOptions{ Tagger: defaultSignature(), Message: "foo bar baz qux", }) c.Assert(ref, IsNil) - c.Assert(err, Equals, ErrBadObjectType) - - ref, err = r.CreateTag("foobar", expectedHash, &TagObjectOptions{ - Tagger: defaultSignature(), - Message: "foo bar baz qux", - TargetType: plumbing.TagObject, - }) - c.Assert(ref, IsNil) c.Assert(err, Equals, plumbing.ErrObjectNotFound) } @@ -1407,10 +1406,9 @@ func (s *RepositorySuite) TestCreateTagSigned(c *C) { key := commitSignKey(c, true) _, err = r.CreateTag("foobar", h.Hash(), &TagObjectOptions{ - Tagger: defaultSignature(), - Message: "foo bar baz qux", - TargetType: plumbing.CommitObject, - SignKey: key, + Tagger: defaultSignature(), + Message: "foo bar baz qux", + SignKey: key, }) c.Assert(err, IsNil) @@ -1447,10 +1445,9 @@ func (s *RepositorySuite) TestCreateTagSignedBadKey(c *C) { key := commitSignKey(c, false) _, err = r.CreateTag("foobar", h.Hash(), &TagObjectOptions{ - Tagger: defaultSignature(), - Message: "foo bar baz qux", - TargetType: plumbing.CommitObject, - SignKey: key, + Tagger: defaultSignature(), + Message: "foo bar baz qux", + SignKey: key, }) c.Assert(err, Equals, openpgperr.InvalidArgumentError("signing key is encrypted")) } @@ -1469,10 +1466,9 @@ func (s *RepositorySuite) TestCreateTagCanonicalize(c *C) { key := commitSignKey(c, true) _, err = r.CreateTag("foobar", h.Hash(), &TagObjectOptions{ - Tagger: defaultSignature(), - Message: "\n\nfoo bar baz qux\n\nsome message here", - TargetType: plumbing.CommitObject, - SignKey: key, + Tagger: defaultSignature(), + Message: "\n\nfoo bar baz qux\n\nsome message here", + SignKey: key, }) c.Assert(err, IsNil) |