diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-12-15 15:08:02 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-12-25 10:12:41 +0100 |
| commit | 5b90407edc5f3cd1eaf9e5667b96f8e155fe0118 (patch) | |
| tree | 1c1f550de443b15fd5f6d3b30ce156b824124c01 /pkg/vcs/git.go | |
| parent | 51cfe8e5099c61aa64746eb323891f0ee28b67c9 (diff) | |
pkg/vcs: add repo.Contains method
Returns true if the current tree contains the specified commit
(the commit is reachable from the current HEAD).
Cntains(commit string) (bool, error)
Diffstat (limited to 'pkg/vcs/git.go')
| -rw-r--r-- | pkg/vcs/git.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/vcs/git.go b/pkg/vcs/git.go index 163f3e497..22a665b37 100644 --- a/pkg/vcs/git.go +++ b/pkg/vcs/git.go @@ -197,6 +197,11 @@ func (git *git) initRepo(reason error) error { return nil } +func (git *git) Contains(commit string) (bool, error) { + _, err := git.git("merge-base", "--is-ancestor", commit, "HEAD") + return err == nil, nil +} + func (git *git) HeadCommit() (*Commit, error) { return git.getCommit("HEAD") } |
