"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmd/pr/checkout/checkout.go" between
gh-cli-1.10.3.tar.gz and gh-cli-1.11.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

checkout.go  (gh-cli-1.10.3):checkout.go  (gh-cli-1.11.0)
skipping to change at line 75 skipping to change at line 75
cmd.Flags().BoolVarP(&opts.RecurseSubmodules, "recurse-submodules", "", f alse, "Update all submodules after checkout") cmd.Flags().BoolVarP(&opts.RecurseSubmodules, "recurse-submodules", "", f alse, "Update all submodules after checkout")
cmd.Flags().BoolVarP(&opts.Force, "force", "f", false, "Reset the existin g local branch to the latest state of the pull request") cmd.Flags().BoolVarP(&opts.Force, "force", "f", false, "Reset the existin g local branch to the latest state of the pull request")
cmd.Flags().BoolVarP(&opts.Detach, "detach", "", false, "Checkout PR with a detached HEAD") cmd.Flags().BoolVarP(&opts.Detach, "detach", "", false, "Checkout PR with a detached HEAD")
return cmd return cmd
} }
func checkoutRun(opts *CheckoutOptions) error { func checkoutRun(opts *CheckoutOptions) error {
findOptions := shared.FindOptions{ findOptions := shared.FindOptions{
Selector: opts.SelectorArg, Selector: opts.SelectorArg,
Fields: []string{"number", "headRefName", "headRepository", "he adRepositoryOwner", "isCrossRepository"}, Fields: []string{"number", "headRefName", "headRepository", "he adRepositoryOwner", "isCrossRepository", "maintainerCanModify"},
} }
pr, baseRepo, err := opts.Finder.Find(findOptions) pr, baseRepo, err := opts.Finder.Find(findOptions)
if err != nil { if err != nil {
return err return err
} }
cfg, err := opts.Config() cfg, err := opts.Config()
if err != nil { if err != nil {
return err return err
} }
skipping to change at line 99 skipping to change at line 99
if err != nil { if err != nil {
return err return err
} }
baseRemote, _ := remotes.FindByRepo(baseRepo.RepoOwner(), baseRepo.RepoNa me()) baseRemote, _ := remotes.FindByRepo(baseRepo.RepoOwner(), baseRepo.RepoNa me())
baseURLOrName := ghrepo.FormatRemoteURL(baseRepo, protocol) baseURLOrName := ghrepo.FormatRemoteURL(baseRepo, protocol)
if baseRemote != nil { if baseRemote != nil {
baseURLOrName = baseRemote.Name baseURLOrName = baseRemote.Name
} }
headRemote := baseRemote headRemote := baseRemote
if pr.IsCrossRepository { if pr.HeadRepository == nil {
headRemote = nil
} else if pr.IsCrossRepository {
headRemote, _ = remotes.FindByRepo(pr.HeadRepositoryOwner.Login, pr.HeadRepository.Name) headRemote, _ = remotes.FindByRepo(pr.HeadRepositoryOwner.Login, pr.HeadRepository.Name)
} }
if strings.HasPrefix(pr.HeadRefName, "-") { if strings.HasPrefix(pr.HeadRefName, "-") {
return fmt.Errorf("invalid branch name: %q", pr.HeadRefName) return fmt.Errorf("invalid branch name: %q", pr.HeadRefName)
} }
var cmdQueue [][]string var cmdQueue [][]string
if headRemote != nil { if headRemote != nil {
skipping to change at line 210 skipping to change at line 212
cmds = append(cmds, []string{"git", "fetch", baseURLOrNam e, fmt.Sprintf("%s:%s", ref, newBranchName), "--force"}) cmds = append(cmds, []string{"git", "fetch", baseURLOrNam e, fmt.Sprintf("%s:%s", ref, newBranchName), "--force"})
} else { } else {
// TODO: check if non-fast-forward and suggest to use `-- force` // TODO: check if non-fast-forward and suggest to use `-- force`
cmds = append(cmds, []string{"git", "fetch", baseURLOrNam e, fmt.Sprintf("%s:%s", ref, newBranchName)}) cmds = append(cmds, []string{"git", "fetch", baseURLOrNam e, fmt.Sprintf("%s:%s", ref, newBranchName)})
} }
cmds = append(cmds, []string{"git", "checkout", newBranchName}) cmds = append(cmds, []string{"git", "checkout", newBranchName})
} }
remote := baseURLOrName remote := baseURLOrName
mergeRef := ref mergeRef := ref
if pr.MaintainerCanModify { if pr.MaintainerCanModify && pr.HeadRepository != nil {
headRepo := ghrepo.NewWithHost(pr.HeadRepositoryOwner.Login, pr.H eadRepository.Name, repoHost) headRepo := ghrepo.NewWithHost(pr.HeadRepositoryOwner.Login, pr.H eadRepository.Name, repoHost)
remote = ghrepo.FormatRemoteURL(headRepo, protocol) remote = ghrepo.FormatRemoteURL(headRepo, protocol)
mergeRef = fmt.Sprintf("refs/heads/%s", pr.HeadRefName) mergeRef = fmt.Sprintf("refs/heads/%s", pr.HeadRefName)
} }
if missingMergeConfigForBranch(newBranchName) { if missingMergeConfigForBranch(newBranchName) {
cmds = append(cmds, []string{"git", "config", fmt.Sprintf("branch .%s.remote", newBranchName), remote}) cmds = append(cmds, []string{"git", "config", fmt.Sprintf("branch .%s.remote", newBranchName), remote})
cmds = append(cmds, []string{"git", "config", fmt.Sprintf("branch .%s.merge", newBranchName), mergeRef}) cmds = append(cmds, []string{"git", "config", fmt.Sprintf("branch .%s.merge", newBranchName), mergeRef})
} }
return cmds return cmds
 End of changes. 3 change blocks. 
3 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)