From 6240390d62a349f18d4b7a22b05004540762f0cb Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Tue, 19 Oct 2021 13:24:26 +0100 Subject: [PATCH] Support references other than commit has This enables support for flexible references, such as: HEAD, branch, tag, heads/branch, refs/heads/branch, refs/tags/tag, refs/remotes/origin/branch, refs/remotes/origin/HEAD, tilde and caret (HEAD~1, master~^, tag~2, ref/heads/master~1, ...), selection by text (HEAD^{/fix nasty bug}), hash (prefix and full). --- patrol/repo.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/patrol/repo.go b/patrol/repo.go index 82a4a20..77b47f2 100644 --- a/patrol/repo.go +++ b/patrol/repo.go @@ -160,8 +160,12 @@ func (r *Repo) detectInternalChangesFrom(revision string) error { return err } - ref := plumbing.NewHash(revision) - then, err := repo.CommitObject(ref) + ref, err := repo.ResolveRevision(plumbing.Revision(revision)) + if err != nil { + return err + } + + then, err := repo.CommitObject(*ref) if err != nil { return err } @@ -204,8 +208,12 @@ func (r *Repo) detectGoModulesChanges(revision string) error { return err } - ref := plumbing.NewHash(revision) - then, err := repo.CommitObject(ref) + ref, err := repo.ResolveRevision(plumbing.Revision(revision)) + if err != nil { + return err + } + + then, err := repo.CommitObject(*ref) if err != nil { return err }