mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Fix deleted branch isn't removed when push the branch again (#9516)
This commit is contained in:
		@@ -525,6 +525,12 @@ func (deletedBranch *DeletedBranch) LoadUser() {
 | 
				
			|||||||
	deletedBranch.DeletedBy = user
 | 
						deletedBranch.DeletedBy = user
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// RemoveDeletedBranch removes all deleted branches
 | 
				
			||||||
 | 
					func RemoveDeletedBranch(repoID int64, branch string) error {
 | 
				
			||||||
 | 
						_, err := x.Where("repo_id=? AND name=?", repoID, branch).Delete(new(DeletedBranch))
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RemoveOldDeletedBranches removes old deleted branches
 | 
					// RemoveOldDeletedBranches removes old deleted branches
 | 
				
			||||||
func RemoveOldDeletedBranches(ctx context.Context) {
 | 
					func RemoveOldDeletedBranches(ctx context.Context) {
 | 
				
			||||||
	// Nothing to do for shutdown or terminate
 | 
						// Nothing to do for shutdown or terminate
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -520,6 +520,12 @@ func PushUpdates(repo *models.Repository, optsList []*PushUpdateOptions) error {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if opts.NewCommitID != git.EmptySHA {
 | 
				
			||||||
 | 
								if err = models.RemoveDeletedBranch(repo.ID, opts.Branch); err != nil {
 | 
				
			||||||
 | 
									log.Error("models.RemoveDeletedBranch %s/%s failed: %v", repo.ID, opts.Branch, err)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		log.Trace("TriggerTask '%s/%s' by %s", repo.Name, opts.Branch, pusher.Name)
 | 
							log.Trace("TriggerTask '%s/%s' by %s", repo.Name, opts.Branch, pusher.Name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		go pull_service.AddTestPullRequestTask(pusher, repo.ID, opts.Branch, true)
 | 
							go pull_service.AddTestPullRequestTask(pusher, repo.ID, opts.Branch, true)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user