(cmd *Command, args *Args)
| 132 | } |
| 133 | |
| 134 | func pullRequest(cmd *Command, args *Args) { |
| 135 | localRepo, err := github.LocalRepo() |
| 136 | utils.Check(err) |
| 137 | |
| 138 | currentBranch, currentBranchErr := localRepo.CurrentBranch() |
| 139 | |
| 140 | baseProject, err := localRepo.MainProject() |
| 141 | utils.Check(err) |
| 142 | |
| 143 | host, err := github.CurrentConfig().PromptForHost(baseProject.Host) |
| 144 | if err != nil { |
| 145 | utils.Check(github.FormatError("creating pull request", err)) |
| 146 | } |
| 147 | client := github.NewClientWithHost(host) |
| 148 | |
| 149 | trackedBranch, headProject, _ := localRepo.RemoteBranchAndProject(host.User, false) |
| 150 | if headProject == nil { |
| 151 | utils.Check(fmt.Errorf("could not determine project for head branch")) |
| 152 | } |
| 153 | |
| 154 | var ( |
| 155 | base, head string |
| 156 | ) |
| 157 | |
| 158 | if flagPullRequestBase := args.Flag.Value("--base"); flagPullRequestBase != "" { |
| 159 | baseProject, base = parsePullRequestProject(baseProject, flagPullRequestBase) |
| 160 | } |
| 161 | |
| 162 | if flagPullRequestHead := args.Flag.Value("--head"); flagPullRequestHead != "" { |
| 163 | headProject, head = parsePullRequestProject(headProject, flagPullRequestHead) |
| 164 | } |
| 165 | |
| 166 | baseRemote, _ := localRepo.RemoteForProject(baseProject) |
| 167 | if base == "" && baseRemote != nil { |
| 168 | base = localRepo.DefaultBranch(baseRemote).ShortName() |
| 169 | } |
| 170 | |
| 171 | if head == "" && trackedBranch != nil { |
| 172 | if !trackedBranch.IsRemote() { |
| 173 | // the current branch tracking another branch |
| 174 | // pretend there's no upstream at all |
| 175 | trackedBranch = nil |
| 176 | } else { |
| 177 | if baseProject.SameAs(headProject) && base == trackedBranch.ShortName() { |
| 178 | e := fmt.Errorf(`Aborted: head branch is the same as base ("%s")`, base) |
| 179 | e = fmt.Errorf("%s\n(use `-h <branch>` to specify an explicit pull request head)", e) |
| 180 | utils.Check(e) |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | force := args.Flag.Bool("--force") |
| 186 | flagPullRequestPush := args.Flag.Bool("--push") |
| 187 | |
| 188 | if head == "" { |
| 189 | if trackedBranch == nil { |
| 190 | utils.Check(currentBranchErr) |
| 191 | if !force && !flagPullRequestPush { |
nothing calls this directly
no test coverage detected
searching dependent graphs…