-
Notifications
You must be signed in to change notification settings - Fork 994
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
Refactor shelling out in Python #8167
Refactor shelling out in Python #8167
Conversation
} | ||
) | ||
def run_command(command, env: {}, fingerprint: nil) | ||
SharedHelpers.run_shell_command(command, env: env, fingerprint: fingerprint) |
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.
This is a slight change where we will now raise stderr concatenated with stdout as the exception message, while before we'd only raise stdout.
dependabot-core/common/lib/dependabot/shared_helpers.rb
Lines 344 to 347 in 1b3368e
raise SharedHelpers::HelperSubprocessFailed.new( | |
message: stderr_to_stdout ? stdout : "#{stderr}\n#{stdout}", | |
error_context: error_context | |
) |
It seems like a good change to me.
@@ -204,7 +203,7 @@ def run_poetry_update_command | |||
end | |||
|
|||
def run_poetry_command(command, fingerprint: nil) | |||
Helpers.run_poetry_command(command, fingerprint: fingerprint) | |||
SharedHelpers.run_shell_command(command, fingerprint: fingerprint) |
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.
Same as the other comment, but reversed. This used to raise an error including only stderr, now we'll raise an error including stdout and stderr concatenated.
Seems fine too I guess!
@@ -309,7 +308,7 @@ def lockfile | |||
end | |||
|
|||
def run_poetry_command(command, fingerprint: nil) | |||
Helpers.run_poetry_command(command, fingerprint: fingerprint) | |||
SharedHelpers.run_shell_command(command, fingerprint: fingerprint) |
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.
Same as the other comment in the other run_poetry_command
method.
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.
It's always great to see these cleanups and more so when the tests are happy 🥇
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.
This LGTM. I would maybe get another approval from the team though since I haven't used time_taken
in my debugging, but maybe someone else has found it useful and doesn't want it removed?
@Nishnha Note that this is not removing dependabot-core/common/lib/dependabot/shared_helpers.rb Lines 317 to 348 in 1b3368e
Only changes in behavior should be the ones I noticed as inline comments in the PR. |
e73094e
to
c0d56c0
Compare
There's a lot of duplicated code in the Python ecosystem that deals with shelling out to package managers. This PR refactors it to always use the same helper.
This fixes most of #6110.