-
Notifications
You must be signed in to change notification settings - Fork 71
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
Fix failing scan-remote-repo
command
#241
Conversation
The recent live-output & pygit2 changes broke existing remote repo scans because `scanner.scan` was being called from the subcommand and the cloned directory was being deleted before the scan could actually happen. The original process_issues callback has now been moved into util and is called from the sub-commands to fix this issue. The main callback only handles exit status now.
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.
Just one small change.
Also, doesn't the scan-folder
command need to be updated as well?
tartufo/cli.py
Outdated
@@ -282,26 +280,9 @@ def main(ctx: click.Context, **kwargs: config.OptionTypes) -> None: | |||
@click.pass_context | |||
def process_issues( |
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 this is no longer doing any actual processing of issues, let's rename it to something more appropriate.
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.
I keep coming up with stupid-sounding redundant names. "return_exit_status" or "compute_return_code" or something oxymoronic that covers the 2 lines of code that's all that's left...
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.
Just the one rename @tarkatronic already pointed out.
tartufo/cli.py
Outdated
@@ -282,26 +280,9 @@ def main(ctx: click.Context, **kwargs: config.OptionTypes) -> None: | |||
@click.pass_context | |||
def process_issues( |
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.
I keep coming up with stupid-sounding redundant names. "return_exit_status" or "compute_return_code" or something oxymoronic that covers the 2 lines of code that's all that's left...
This addresses godaddy#243. We had two problems: 1. Diff was generated in backwards order; it is clear from: https://pygit2.readthedocs.io/en/latest/recipes/git-show.html that if "show diff" is implemented as: ``` >>> diff = repo.diff(commit.parents[0], commit) ``` then the previous commit must be the first argument (and in fact you can see just above where prev_commit is precisely commit.parents[0]). 2. Commit metadata was retrieved for the previous commit I verified running tartufo against itself that the reported commit hashes and diffs now match what "git show" actually displays. Unit test changes were restricted to swapping the order of the commits in expected call signatures for repo.diff(). I resisted the temptation to collapse the special-case logic for the lead commit into the earlier block that looks for it, in order to minimize the size of this commit.
To help us get this pull request reviewed and merged quickly, please be sure to include the following items:
PR Type
What kind of change does this PR introduce?
Backward Compatibility
Is this change backward compatible with the most recently released version? Does it introduce changes which might change the user experience in any way? Does it alter the API in any way?
What's new?
The recent live-output & pygit2 changes broke existing remote repo scans because
scanner.scan
was beingcalled from the subcommand and the cloned directory was being deleted before the scan could actually happen.
The original process_issues callback has now been moved into util and is called from the sub-commands to
fix this issue. The main callback only handles exit status now.