sourcegraph / go-vcs

manipulate and inspect VCS repositories in Go
https://sourcegraph.com/sourcegraph/go-vcs
Other
79 stars 20 forks source link

Fix inconsistency in annotated tag dereferencing; add test coverage for it. #108

Closed dmitshur closed 6 years ago

dmitshur commented 6 years ago

There was inconsistency in how annotated tags were handled by various git backends (git, gitcmd) and various methods (ResolveRevision, ResolveTag, Tags). In some cases, annotated tags were dereferenced, and in other cases, they were not. This is issue #24.

This PR fixes the inconsistency by opting to always dereference annotated tags to the underlying commit ID.

It consists of two logical commits (please don't squash them, otherwise information will be lost):

  1. First commit adds tests that cover the inconsistent annotated tag behavior, without changing the implementation. The tests demonstrate the inconsistent behavior, and are passing.

  2. Second commit changes git and gitcmd behavior to always dereference annotated tags, and updates tests to have consistent output. The tests are passing.

The decision to always dereference annotated tags is based the following rationale. This behavior is more consistent with the high level nature of the vcs API, and it's easier for users to consume. If detailed tag information is needed, support for that can be added as an optional enhancement.

Fixes #24.

/cc @keegancsmith @slimsag Happy to answer any questions about this, or elaborate on any part.