-
Notifications
You must be signed in to change notification settings - Fork 38
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't remove comments unless they are bogus, and maybe replace them with correct ones even in that case.
command.go
Outdated
return nil | ||
} | ||
|
||
return ctx.Err() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And what happens to err
? Looks like simply getting lost ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about swapping the conditiona and returning err if not nil and return nil outside the condition block ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The err returned by exec.Wait is discarded in favor of ctx.Err(). Because exec.Wait() will returns a string 'signal: killed', which isn't good to depend on and is less meaningful. I don't have a good idea to encode the two errors (exec.Wait's and ctx.Err's) into one cleanly either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just log it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean logging the error of Wait and returning the error of ctx.Err() or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes log the error of Wait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// 'signal: killed' when the error is returned by exec.Wait | ||
// It depends on the point of the time (before or after exec.Start returns) at which the timeout is triggered. | ||
if err.Error() != "context deadline exceeded" && err.Error() != "signal: killed" { | ||
if err != context.DeadlineExceeded { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want to remove documentation in those comments ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since that is encapsulated into RunInDirTimeoutPipeline and the test won't be exposed to the nuances anymore (which is what I hope for).
c62f66a
to
c981984
Compare
c981984
to
1a38a29
Compare
@@ -70,7 +70,11 @@ func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, std | |||
return err | |||
} | |||
|
|||
return cmd.Wait() | |||
if err := cmd.Wait(); err != nil { | |||
log("exec.Wait: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be log.Warn
instead, and include more info about the command being run and the name of the function it's coming from ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a bit of more involved since there is an existing function called log
within the package. I can give a nickname to the logger at the import statement but that looks weird and inconsistent with the rest of the package. The plan B is to rename the internal log
function with another name, or to migrate all the uses of the log
function with the logger's equivalent. But that would be beyond the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, sorry. I just realized this was the git
module and not gitea
itself.
LGTM |
LGTM |
For #42 and #41
Sanitizing the error handling a little bit, now it looks nicer.