From 482d05412985292229995ddc605e23ed29f1c269 Mon Sep 17 00:00:00 2001 From: Bruno Meneguele Date: Thu, 24 Jun 2021 10:15:32 -0300 Subject: [PATCH] cmd/util: remove "remote" arguement from verifyRemoteAndBranch function 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 --- cmd/mr_create.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/mr_create.go b/cmd/mr_create.go index 560fd994..9cf69241 100644 --- a/cmd/mr_create.go +++ b/cmd/mr_create.go @@ -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 } @@ -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 @@ -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) } }