Skip to content
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

Overload --json to fetch via PR number #2356

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

bytexenon
Copy link
Contributor

Introduces the --pull-request PULL_REQUEST and -pr PULL_REQUEST flag. This flag accepts a pull request number, gets the head of the specified pull request, and fetches the latest data.json file from it.

Additionally, I've added a check to ensure that the --json and --pull-request flags are not used simultaneously. If both flags are used together, an error message will be displayed: "You cannot use both --json and --pull_request at the same time."

Example usage:

sherlock -pr 2331 bytexenon
sherlock --pull-request 2331 bytexenon

Feel free to leave any feedback or request changes as necessary.

Fixes #2354

@ppfeister
Copy link
Member

ppfeister commented Nov 4, 2024

Hm. Having some thoughts regarding UX.

@sdushantha any of your own?

Wondering if we should instead overload --json to take either a URI or (something like) a #0000 formatted PR ref, rather than adding a bespoke option.

i.e. --json #2356 and --json https[...]whateverUri.json each behaving differently according to the apparent intention.

If bespoke, I would probably drop the short -pr (multiple reasons) and leave only --pull-request.

Reference tagged issue for targeted functionality. Feel free to weigh in yourself if you have any thoughts @bytexenon

@ppfeister
Copy link
Member

ppfeister commented Nov 4, 2024

Regression tests ran at the time of this comment all PASS.

Failures indicated are due only to an existing positive test target (BodyBuilding[.]com) shutting down. This target will be swapped out elsewhere and can be disregarded.

tests/test_probes.py::TestLiveTargets::test_known_positives_via_response_url[BodyBuilding-blue] FAILED [ 44%]

@bytexenon
Copy link
Contributor Author

Wondering if we should instead overload --json to take either a URI or (something like) a #0000 formatted PR ref, rather than adding a bespoke option.

i.e. --json #2356 and --json https[...]whateverUri.json each behaving differently according to the apparent intention.

It does sound much better than adding the --pull-request option, the only issue I have with it is the # symbol for PR numbers might require quotes around the argument (e.g., sherlock --json "#9876" bytexenon) because # is a comment character in Bash. Omitting the # and specifying just the number could make the command cleaner:

sherlock --json 9876 bytexenon

Ultimately, the decision is yours

@ppfeister
Copy link
Member

Good catch. The # was just meant to better distinguish uri types (filepath, url, pull request), but I don't think it's really necessary. Let's do your version with just the number.

Think you can make it happen cleanly?

Additional notes for the current version. to be hopefully fixed in the new:

When passing a non-PR number (i.e. of an Issue or Discussion), it errors out with ERROR: 'head'. Can we add proper validation to see if the ref is actually a PR, and if not, print something more descriptive saying so

@bytexenon
Copy link
Contributor Author

Think you can make it happen cleanly?

Of course, I'll work on it

When passing a non-PR number (i.e. of an Issue or Discussion), it errors out with ERROR: 'head'. Can we add proper validation to see if the ref is actually a PR, and if not, print something more descriptive saying so

Got it, thanks for pointing that out. I'll make sure to add proper validation and improve the error messages

@ppfeister
Copy link
Member

Just confirming --- is this ready for review or are you looking to make some other tweaks? @bytexenon

@bytexenon
Copy link
Contributor Author

Just confirming --- is this ready for review or are you looking to make some other tweaks? @bytexenon

I think it's done. Sorry for the late response, @ppfeister

Copy link
Member

@ppfeister ppfeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, just wanted to make sure it was actually done first -- didn't want to jump the gun

Changes look good and seem to function as expected. Merging!

@ppfeister ppfeister changed the title Add --pull-request flag Overload --json to fetch via PR number Nov 11, 2024
@ppfeister ppfeister added the enhancement New feature or request label Nov 11, 2024
@ppfeister ppfeister merged commit 662d80e into sherlock-project:master Nov 11, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add flag to specify PR for testing manifest changes
3 participants