-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mr un/approve: If -F, un/approve completes even if file read failed #708
Comments
@bmeneguele @prarit any input on this one? :) |
Huh, I thought the log.Fatal(err) would have stopped lab. But yes, an os.Exit(1) there is fine. |
@prarit on a quick search, I found that log.Fatal() should call os.Exit(1). |
Oh, yes. The |
Just to clarify: even though we have a custom log layer, our Lines 117 to 133 in 833faeb
|
Well, I'm sorry, the issue is far simpler than I initially thought, While a simple fix would be to just move the function up with: diff --git a/cmd/mr_approve.go b/cmd/mr_approve.go
index cd6a932..8e82775 100644
--- a/cmd/mr_approve.go
+++ b/cmd/mr_approve.go
@@ -48,6 +48,15 @@ var mrApproveCmd = &cobra.Command{
log.Fatal(err)
}
+ if comment || len(msgs) > 0 || filename != "" {
+ linebreak, err := cmd.Flags().GetBool("force-linebreak")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ createNote(rn, true, int(id), msgs, filename, linebreak, "")
+ }
+
err = lab.MRApprove(p.ID, int(id))
if err != nil {
if err == lab.ErrStatusForbidden {
@@ -59,15 +68,6 @@ var mrApproveCmd = &cobra.Command{
}
}
- if comment || len(msgs) > 0 || filename != "" {
- linebreak, err := cmd.Flags().GetBool("force-linebreak")
- if err != nil {
- log.Fatal(err)
- }
-
- createNote(rn, true, int(id), msgs, filename, linebreak, "")
- }
-
fmt.Printf("Merge Request !%d approved\n", id)
},
} The problem with that fix is that it does not prevent a comment from being added when the un/approve does fail, so we are solving a problem and creating a new one. I think the optimal solution would be to unify the comment and approve action in one API call, unfortunately, GitLab does not provide an API explicit for that. |
When using the -F, file, option, if the file read failed for any reason, the operation continues, ignoring the file comment.
In the example below, the user will unapprove the MR without submitting the message that he wanted.
it is possible that the same problem may occur in other parts of Lab that provides the
-F
option, a global solution for that would be:Should Lab take care of that? if so let me know so I can do further testing and can submit a PR :)
The text was updated successfully, but these errors were encountered: