mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	improve force push detect when push (#2798)
This commit is contained in:
		@@ -118,7 +118,7 @@ func runHookPreReceive(c *cli.Context) error {
 | 
				
			|||||||
		if protectBranch != nil && protectBranch.IsProtected() {
 | 
							if protectBranch != nil && protectBranch.IsProtected() {
 | 
				
			||||||
			// detect force push
 | 
								// detect force push
 | 
				
			||||||
			if git.EmptySHA != oldCommitID {
 | 
								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 {
 | 
									if err != nil {
 | 
				
			||||||
					fail("Internal error", "Fail to detect force push: %v", err)
 | 
										fail("Internal error", "Fail to detect force push: %v", err)
 | 
				
			||||||
				} else if len(output) > 0 {
 | 
									} else if len(output) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user