-
Notifications
You must be signed in to change notification settings - Fork 128
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
feat: run command with context #95
Conversation
Pass a context down to *exec.Command and make timing out optional when o.Timeout < 0. Using `context.Background()` _all the time_ is not practical as sometimes we need to stop the execution when _a_ parent context stops. Signed-off-by: Ayman Bagabas <[email protected]>
@unknwon let me know what you think |
Thanks, I think it should be great, but I would need to double check https://github.com/gogs/gogs because some places might have just assumed |
I've made some additional changes and deprecated the old options timeout in favor of using |
CommandOptions now can take a context and a timeout. Deprecate current options timeout property in favor of that. The current behavior is not affected and RunWithTimeout methods should be removed in the future. Use *Command.WithTimeout and *Command.SetTimeout instead. Signed-off-by: Ayman Bagabas <[email protected]>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #95 +/- ##
==========================================
- Coverage 83.68% 83.41% -0.28%
==========================================
Files 28 28
Lines 1784 1809 +25
==========================================
+ Hits 1493 1509 +16
- Misses 176 182 +6
- Partials 115 118 +3 |
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.
Thank you!
https://github.com/gogs/git-module/releases/tag/v1.8.2 has been created for this merge. |
Pass a context down to *exec.Command and make timing out optional when o.Timeout < 0.
Using
context.Background()
all the time is not practical as sometimes we need to stop the execution when a parent context stops.Describe the pull request
A clear and concise description of what the pull request is about, i.e. what problem should be fixed?
Link to the issue:
Checklist