Improve sync fork behavior (#33319)

Fix #33271

Suppose there is a `branch-a` in fork repo:

1. if `branch-a` exists in base repo: try to sync `base:branch-a` to `fork:branch-a`
2. if `branch-a` doesn't exist in base repo: try to sync `base:main` to `fork:branch-a`
This commit is contained in:
wxiaoguang 2025-01-20 15:17:47 +08:00 committed by GitHub
parent 6073e2f1bb
commit 39de2955fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 109 additions and 26 deletions

View file

@ -167,6 +167,9 @@ func GetBranch(ctx context.Context, repoID int64, branchName string) (*Branch, e
BranchName: branchName,
}
}
// FIXME: this design is not right: it doesn't check `branch.IsDeleted`, it doesn't make sense to make callers to check IsDeleted again and again.
// It causes inconsistency with `GetBranches` and `git.GetBranch`, and will lead to strange bugs
// In the future, there should be 2 functions: `GetBranchExisting` and `GetBranchWithDeleted`
return &branch, nil
}