aboutsummaryrefslogtreecommitdiff
path: root/modules/git/commit.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/commit.go')
-rw-r--r--modules/git/commit.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/git/commit.go b/modules/git/commit.go
index 4a55645d3..6e8fcb3e0 100644
--- a/modules/git/commit.go
+++ b/modules/git/commit.go
@@ -218,6 +218,19 @@ func (c *Commit) HasPreviousCommit(commitHash SHA1) (bool, error) {
return false, err
}
+// IsForcePush returns true if a push from oldCommitHash to this is a force push
+func (c *Commit) IsForcePush(oldCommitID string) (bool, error) {
+ if oldCommitID == EmptySHA {
+ return false, nil
+ }
+ oldCommit, err := c.repo.GetCommit(oldCommitID)
+ if err != nil {
+ return false, err
+ }
+ hasPreviousCommit, err := c.HasPreviousCommit(oldCommit.ID)
+ return !hasPreviousCommit, err
+}
+
// CommitsBeforeLimit returns num commits before current revision
func (c *Commit) CommitsBeforeLimit(num int) ([]*Commit, error) {
return c.repo.getCommitsBeforeLimit(c.ID, num)