diff --git a/cmd/mergeRequest.go b/cmd/mergeRequest.go index 0904f542..98de20e8 100644 --- a/cmd/mergeRequest.go +++ b/cmd/mergeRequest.go @@ -7,9 +7,9 @@ import ( // mrCmd represents the mr command var mergeRequestCmd = &cobra.Command{ Use: "merge-request [remote]", - Short: "Open a merge request on GitLab", - Long: `Currently only supports MRs into master`, - Args: cobra.ExactArgs(0), + Short: mrCreateCmd.Short, + Long: mrCreateCmd.Long, + Args: mrCreateCmd.Args, Run: runMRCreate, } diff --git a/cmd/mrCreate.go b/cmd/mrCreate.go index 0ce59e57..0b5129ad 100644 --- a/cmd/mrCreate.go +++ b/cmd/mrCreate.go @@ -50,8 +50,12 @@ func runMRCreate(cmd *cobra.Command, args []string) { log.Fatal(err) } - if !lab.BranchPushed(sourceProjectName, branch) { - log.Fatal("aborting MR, branch not present on remote: ", sourceRemote) + p, err := lab.FindProject(sourceProjectName) + if err != nil { + log.Fatal(err) + } + if !lab.BranchPushed(p.ID, branch) { + log.Fatalf("aborting MR, branch %s not present on remote %s. did you forget to push?", branch, sourceRemote) } targetRemote := forkedFromRemote diff --git a/internal/gitlab/gitlab.go b/internal/gitlab/gitlab.go index 3424e6eb..1cfe2317 100644 --- a/internal/gitlab/gitlab.go +++ b/internal/gitlab/gitlab.go @@ -260,13 +260,8 @@ func IssueClose(pid interface{}, id int) error { } // BranchPushed checks if a branch exists on a GitLab project -func BranchPushed(project, branch string) bool { - p, err := FindProject(project) - if err != nil { - return false - } - - b, _, err := lab.Branches.GetBranch(p.ID, branch) +func BranchPushed(pid interface{}, branch string) bool { + b, _, err := lab.Branches.GetBranch(pid, branch) if err != nil { return false }