Skip to content

Commit 9ddbbd9

Browse files
lunnylafriks
authored andcommitted
improve force push detect when push (#2798)
1 parent 1da17db commit 9ddbbd9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmd/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func runHookPreReceive(c *cli.Context) error {
118118
if protectBranch != nil && protectBranch.IsProtected() {
119119
// detect force push
120120
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)
122122
if err != nil {
123123
fail("Internal error", "Fail to detect force push: %v", err)
124124
} else if len(output) > 0 {

0 commit comments

Comments
 (0)