Skip to content

Commit

Permalink
improve force push detect when push (go-gitea#2798)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and lafriks committed Oct 28, 2017
1 parent 1da17db commit 9ddbbd9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func runHookPreReceive(c *cli.Context) error {
if protectBranch != nil && protectBranch.IsProtected() {
// detect force push
if git.EmptySHA != oldCommitID {
output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
if err != nil {
fail("Internal error", "Fail to detect force push: %v", err)
} else if len(output) > 0 {
Expand Down

0 comments on commit 9ddbbd9

Please sign in to comment.