-
Notifications
You must be signed in to change notification settings - Fork 14
Expand project scripts to work with issues too #187
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4108955
make project class more flexible
jennyhickson 1ec44f5
expand classes to Issues
jennyhickson 4253491
add issue test file
jennyhickson 1c401ba
clear unfinished issues
jennyhickson 372ca37
move counting into project class
jennyhickson 3e549de
update help
jennyhickson 1164cd0
black
jennyhickson 598d347
tweaks
jennyhickson c2844a5
CR response
jennyhickson a7c5fd2
Update gh_review_project/review_project.py
jennyhickson d65f146
black
jennyhickson f253859
Merge branch 'main' into tidy_issues
james-bruten-mo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import argparse | ||
| from pathlib import Path | ||
| from review_project import ProjectData, ISSUE_ID | ||
|
|
||
|
|
||
| def remove_milestone( | ||
| issue_data: ProjectData, milestone: str, dry_run: bool = False | ||
| ) -> int: | ||
| """ | ||
| Remove the milestone from all open issues that do not have any linked PRs | ||
| attached to them. Leave a comment explaining why. | ||
| """ | ||
|
|
||
| open_issues = issue_data.get_milestone(milestone=milestone, status="open") | ||
|
|
||
| comment = ( | ||
| f"[Automatic Update]\n\nThe Code Review deadline for the {milestone} has " | ||
| f"passed. As this issue does not have a linked pull request it has been " | ||
| f"removed from the milestone. Please review this issue and either select " | ||
| f"a new milestone or close it as appropriate. Please contact " | ||
| f"@MetOffice/ssdteam if you think there has been an error.\n\n Thanks" | ||
| ) | ||
|
|
||
| for repo in open_issues: | ||
| print(f"\nRemoving issues in {repo}") | ||
| for issue in open_issues[repo]: | ||
| if not issue.linked_prs: | ||
| issue.add_comment(comment, dry_run=dry_run) | ||
| issue.modify_milestone(milestone=None, dry_run=dry_run) | ||
|
|
||
|
|
||
| def parse_args(): | ||
| """ | ||
| Read command line args | ||
| """ | ||
|
|
||
| testfile_path = Path(__file__).parent / "test" | ||
|
|
||
| parser = argparse.ArgumentParser( | ||
| "Changes to the Simulation System projects required at the code" | ||
| "review deadline." | ||
| ) | ||
|
|
||
| parser.add_argument("--milestone", help="Milestone being released") | ||
| parser.add_argument( | ||
| "--test", | ||
| action="store_true", | ||
| help="Use test input files.", | ||
| ) | ||
| parser.add_argument( | ||
| "--capture_project", | ||
| action="store_true", | ||
| help="Capture the current project status into the test file", | ||
| ) | ||
| parser.add_argument( | ||
| "--file", | ||
| default=testfile_path, | ||
| help="Filepath to test data for either capturing the project status, " | ||
| "or use as input data.", | ||
| ) | ||
| parser.add_argument( | ||
| "--dry", | ||
| action="store_true", | ||
| help="Dry run. Print commands, don't action them. Always true when " | ||
| "running with test data.", | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| args.file = Path(args.file) | ||
| args.file = args.file.expanduser().resolve() | ||
|
|
||
| if args.test: | ||
| args.dry = True | ||
|
|
||
| return args | ||
|
|
||
|
|
||
| def main( | ||
| milestone: str, test: bool, capture_project: bool, file: Path, dry: bool | ||
| ) -> None: | ||
|
|
||
| # Get milestone data | ||
| if test: | ||
| issue_data = ProjectData.from_file(ISSUE_ID, file / "issue.json") | ||
| else: | ||
| issue_data = ProjectData.from_github( | ||
| ISSUE_ID, capture_project, file / "issue.json" | ||
| ) | ||
|
|
||
| remove_milestone(issue_data, milestone=milestone, dry_run=dry) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| args = parse_args() | ||
| main(args.milestone, args.test, args.capture_project, args.file, args.dry) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Docstring :)
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