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:
parent
6073e2f1bb
commit
39de2955fd
6 changed files with 109 additions and 26 deletions
|
@ -1,10 +1,12 @@
|
|||
{{if and .UpstreamDivergingInfo (or .UpstreamDivergingInfo.BaseHasNewCommits .UpstreamDivergingInfo.HeadCommitsBehind)}}
|
||||
{{if and .UpstreamDivergingInfo .UpstreamDivergingInfo.BaseBranchHasNewCommits}}
|
||||
<div class="ui message flex-text-block">
|
||||
<div class="tw-flex-1">
|
||||
{{$upstreamLink := printf "%s/src/branch/%s" .Repository.BaseRepo.Link (.Repository.BaseRepo.DefaultBranch|PathEscapeSegments)}}
|
||||
{{$upstreamHtml := HTMLFormat `<a href="%s">%s:%s</a>` $upstreamLink .Repository.BaseRepo.FullName .Repository.BaseRepo.DefaultBranch}}
|
||||
{{if .UpstreamDivergingInfo.HeadCommitsBehind}}
|
||||
{{ctx.Locale.TrN .UpstreamDivergingInfo.HeadCommitsBehind "repo.pulls.upstream_diverging_prompt_behind_1" "repo.pulls.upstream_diverging_prompt_behind_n" .UpstreamDivergingInfo.HeadCommitsBehind $upstreamHtml}}
|
||||
{{$upstreamLink := printf "%s/src/branch/%s" .Repository.BaseRepo.Link (.UpstreamDivergingInfo.BaseBranchName|PathEscapeSegments)}}
|
||||
{{$upstreamRepoBranchDisplay := HTMLFormat "%s:%s" .Repository.BaseRepo.FullName .UpstreamDivergingInfo.BaseBranchName}}
|
||||
{{$thisRepoBranchDisplay := HTMLFormat "%s:%s" .Repository.FullName .BranchName}}
|
||||
{{$upstreamHtml := HTMLFormat `<a href="%s">%s</a>` $upstreamLink $upstreamRepoBranchDisplay}}
|
||||
{{if .UpstreamDivergingInfo.HeadBranchCommitsBehind}}
|
||||
{{ctx.Locale.TrN .UpstreamDivergingInfo.HeadBranchCommitsBehind "repo.pulls.upstream_diverging_prompt_behind_1" "repo.pulls.upstream_diverging_prompt_behind_n" .UpstreamDivergingInfo.HeadBranchCommitsBehind $upstreamHtml}}
|
||||
{{else}}
|
||||
{{ctx.Locale.Tr "repo.pulls.upstream_diverging_prompt_base_newer" $upstreamHtml}}
|
||||
{{end}}
|
||||
|
@ -12,7 +14,7 @@
|
|||
{{if .CanWriteCode}}
|
||||
<button class="ui compact primary button tw-m-0 link-action"
|
||||
data-modal-confirm-header="{{ctx.Locale.Tr "repo.pulls.upstream_diverging_merge"}}"
|
||||
data-modal-confirm-content="{{ctx.Locale.Tr "repo.pulls.upstream_diverging_merge_confirm" .BranchName}}"
|
||||
data-modal-confirm-content="{{ctx.Locale.Tr "repo.pulls.upstream_diverging_merge_confirm" $upstreamRepoBranchDisplay $thisRepoBranchDisplay}}"
|
||||
data-url="{{.Repository.Link}}/branches/merge-upstream?branch={{.BranchName}}">
|
||||
{{ctx.Locale.Tr "repo.pulls.upstream_diverging_merge"}}
|
||||
</button>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue