{{$data := $.MergeBoxData}} {{$pull := $.PullRequest}}
{{/* align with other item icon & text */}} {{ctx.Locale.Tr "repo.pulls.cmd_instruction_hint"}}

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_title"}}

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_desc"}}
{{$localBranch := $pull.HeadBranch}} {{if ne $pull.HeadRepo.ID $pull.BaseRepo.ID}} {{$localBranch = print $pull.HeadRepo.OwnerName "-" $pull.HeadBranch}} {{end}}
{{$gitRemoteName := ctx.RootData.SystemConfig.Repository.GitGuideRemoteName.Value ctx}} {{if eq $pull.Flow 0}}
git fetch -u {{if ne $pull.HeadRepo.ID $pull.BaseRepo.ID}}{{ctx.AppFullLink $pull.HeadRepo.Link}}{{else}}{{$gitRemoteName}}{{end}} {{$pull.HeadBranch}}:{{$localBranch}}
{{else}}
git fetch -u {{$gitRemoteName}} {{$pull.GetGitHeadRefName}}:{{$localBranch}}
{{end}}
git checkout {{$localBranch}}
{{if $data.ShowMergeInstructions}}

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}} {{if not $data.AutodetectManualMerge}}
{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_warning"}}
{{end}}
git checkout {{$pull.BaseBranch}}
git merge --no-ff {{$localBranch}}
git checkout {{$pull.BaseBranch}}
git merge --ff-only {{$localBranch}}
git checkout {{$localBranch}}
git rebase {{$pull.BaseBranch}}
git checkout {{$pull.BaseBranch}}
git merge --no-ff {{$localBranch}}
git checkout {{$pull.BaseBranch}}
git merge --squash {{$localBranch}}
git checkout {{$pull.BaseBranch}}
git merge --ff-only {{$localBranch}}
git checkout {{$pull.BaseBranch}}
git merge {{$localBranch}}
git push {{$gitRemoteName}} {{$pull.BaseBranch}}
{{end}}