aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/repo_commit.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/repo_commit.go')
-rw-r--r--modules/git/repo_commit.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go
index b631f9341e..501ea88e40 100644
--- a/modules/git/repo_commit.go
+++ b/modules/git/repo_commit.go
@@ -27,6 +27,16 @@ func (repo *Repository) GetRefCommitID(name string) (string, error) {
return ref.Hash().String(), nil
}
+// IsCommitExist returns true if given commit exists in current repository.
+func (repo *Repository) IsCommitExist(name string) bool {
+ hash := plumbing.NewHash(name)
+ _, err := repo.gogitRepo.CommitObject(hash)
+ if err != nil {
+ return false
+ }
+ return true
+}
+
// GetBranchCommitID returns last commit ID string of given branch.
func (repo *Repository) GetBranchCommitID(name string) (string, error) {
return repo.GetRefCommitID(BranchPrefix + name)