Browse Source

improve force push detect when push (#2798)

Lunny Xiao 2 years ago
parent
commit
9ddbbd9d5a
1 changed files with 1 additions and 1 deletions
  1. 1 1
      cmd/hook.go

+ 1 - 1
cmd/hook.go

@@ -118,7 +118,7 @@ func runHookPreReceive(c *cli.Context) error {
118 118
 		if protectBranch != nil && protectBranch.IsProtected() {
119 119
 			// detect force push
120 120
 			if git.EmptySHA != oldCommitID {
121
-				output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
121
+				output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
122 122
 				if err != nil {
123 123
 					fail("Internal error", "Fail to detect force push: %v", err)
124 124
 				} else if len(output) > 0 {