Skip to content

Commit

Permalink
Added Force Option for create
Browse files Browse the repository at this point in the history
  • Loading branch information
craftamap committed Oct 31, 2020
1 parent 44bce40 commit 5e22a58
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/commands/pr/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
return
}
if !Force {
possiblePrs, err := c.GetPrIDBySourceBranch(bbrepo.RepoOrga, bbrepo.RepoSlug, sourceBranch)
// Note: We want err to be set here, since we don't want an existing pull request
if err != nil {
fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
return
}
if len(possiblePrs.Values) != 0 {
id := possiblePrs.Values[0].ID
fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), fmt.Sprintf("Pull request %d already exists for this branch. Use --force to ignore this.", id))
return
}
}

repo, err := c.RepositoryGet(bbrepo.RepoOrga, bbrepo.RepoSlug)
if err != nil {
Expand Down

0 comments on commit 5e22a58

Please # to comment.