Skip to content

Commit

Permalink
cmd/util: remove "remote" arguement from verifyRemoteAndBranch function
Browse files Browse the repository at this point in the history
The verifyRemoteAndBranch() was using the remote information only for
formatting the error message, since the projectID for the remote is also
being passed as argument, therefore, to simplify the code, this patch
removes the "remote" argument and let the callee to prepend the remote
name to the error message.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
  • Loading branch information
bmeneg committed Jun 24, 2021
1 parent 6c5a5d6 commit 482d054
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cmd/mr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func init() {
)
}

func verifyRemoteAndBranch(projectID int, remote string, branch string) error {
func verifyRemoteBranch(projectID int, branch string) error {
if _, err := lab.GetCommit(projectID, branch); err != nil {
return fmt.Errorf("%s:%s is not a valid reference", remote, branch)
return fmt.Errorf("%s is not a valid reference", branch)
}
return nil
}
Expand Down Expand Up @@ -143,10 +143,10 @@ func runMRCreate(cmd *cobra.Command, args []string) {
log.Fatal(err)
}

// verify the source branch and remote
err = verifyRemoteAndBranch(sourceProject.ID, sourceRemote, sourceBranch)
// verify the source branch in remote project
err = verifyRemoteBranch(sourceProject.ID, sourceBranch)
if err != nil {
log.Fatal(err)
log.Fatalf("%s:%s\n", sourceRemote, err)
}

targetRemote := defaultRemote
Expand All @@ -169,10 +169,10 @@ func runMRCreate(cmd *cobra.Command, args []string) {
targetBranch := targetProject.DefaultBranch
if len(args) > 1 && targetBranch != args[1] {
targetBranch = args[1]
// verify the target branch and remote
err = verifyRemoteAndBranch(targetProject.ID, targetRemote, targetBranch)
// verify the target branch in remote project
err = verifyRemoteBranch(targetProject.ID, targetBranch)
if err != nil {
log.Fatal(err)
log.Fatalf("%s:%s\n", targetRemote, err)
}
}

Expand Down

0 comments on commit 482d054

Please sign in to comment.