Find DefaultPRHead based on branch and SHA (#514)

Reviewed-on: https://gitea.com/gitea/tea/pulls/514
Reviewed-by: strk <strk@noreply.gitea.io>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
6543
2022-10-25 06:38:39 +08:00
parent c1c7870ceb
commit 54b535a527
2 changed files with 40 additions and 16 deletions

View File

@ -99,11 +99,12 @@ func GetDefaultPRBase(login *config.Login, owner, repo string) (string, error) {
// that has a branch with the same name, and extracts the owner from its URL.
// If no remote matches, owner is empty, meaning same as head repo owner.
func GetDefaultPRHead(localRepo *local_git.TeaRepo) (owner, branch string, err error) {
if branch, err = localRepo.TeaGetCurrentBranchName(); err != nil {
var sha string
if branch, sha, err = localRepo.TeaGetCurrentBranchNameAndSHA(); err != nil {
return
}
remote, err := localRepo.TeaFindBranchRemote(branch, "")
remote, err := localRepo.TeaFindBranchRemote(branch, sha)
if err != nil {
err = fmt.Errorf("could not determine remote for current branch: %s", err)
return