From 5b90407edc5f3cd1eaf9e5667b96f8e155fe0118 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 15 Dec 2020 15:08:02 +0100 Subject: 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) --- pkg/vcs/git.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkg/vcs/git.go') 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") } -- cgit mrf-deployment