From f371f84fa3456c2a71470632b6458d81e4892a54 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 20 Mar 2024 09:45:27 +0800 Subject: Restore deleted branches when syncing (#29898) Regression of #29493. If a branch has been deleted, repushing it won't restore it. Lunny may have noticed that, but I didn't delve into the comment then overlooked it: https://github.com/go-gitea/gitea/pull/29493#discussion_r1509046867 The additional comments added are to explain the issue I found during testing, which are unrelated to the fixes. --- services/repository/branch.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'services/repository/branch.go') diff --git a/services/repository/branch.go b/services/repository/branch.go index 8d8cfa2d19..db7acdb505 100644 --- a/services/repository/branch.go +++ b/services/repository/branch.go @@ -318,11 +318,11 @@ func SyncBranchesToDB(ctx context.Context, repoID, pusherID int64, branchNames, for i, branchName := range branchNames { commitID := commitIDs[i] branch, exist := branchMap[branchName] - if exist && branch.CommitID == commitID { + if exist && branch.CommitID == commitID && !branch.IsDeleted { continue } - commit, err := getCommit(branchName) + commit, err := getCommit(commitID) if err != nil { return fmt.Errorf("get commit of %s failed: %v", branchName, err) } -- cgit v1.2.3