-
Notifications
You must be signed in to change notification settings - Fork 219
add support for --preview-pr #2331
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
Changes from 4 commits
ce1b274
792cc08
29aea71
468f154
e2b0a97
77ddd19
79c9913
3ba5bf9
a086775
f2c8bfd
bde283d
25e9b56
ca98281
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -473,33 +473,41 @@ def find_related_easyconfigs(path, ec): | |
|
|
||
| return sorted(res) | ||
|
|
||
|
|
||
| def review_pr(pr, colored=True, branch='develop'): | ||
| def review_pr(paths=None, pr=None, colored=True, branch='develop'): | ||
| """ | ||
| Print multi-diff overview between easyconfigs in specified PR and specified branch. | ||
| Print multi-diff overview between specified easyconfigs or PR and specified branch. | ||
| :param pr: pull request number in easybuild-easyconfigs repo to review | ||
| :param paths: path tuples (path, generated) of easyconfigs to review | ||
| :param colored: boolean indicating whether a colored multi-diff should be generated | ||
| :param branch: easybuild-easyconfigs branch to compare with | ||
| """ | ||
| tmpdir = tempfile.mkdtemp() | ||
|
|
||
| download_repo_path = download_repo(branch=branch, path=tmpdir) | ||
| repo_path = os.path.join(download_repo_path, 'easybuild', 'easyconfigs') | ||
| pr_files = [path for path in fetch_easyconfigs_from_pr(pr) if path.endswith('.eb')] | ||
|
|
||
|
|
||
| if pr: | ||
| pr_files = [path for path in fetch_easyconfigs_from_pr(pr) if path.endswith('.eb')] | ||
| elif paths: | ||
| pr_files = [path[0] for path in paths] | ||
| else: | ||
| return "no easyconfigs or pr specified" | ||
|
||
|
|
||
| lines = [] | ||
| ecs, _ = parse_easyconfigs([(fp, False) for fp in pr_files], validate=False) | ||
| for ec in ecs: | ||
| files = find_related_easyconfigs(repo_path, ec['ec']) | ||
| _log.debug("File in PR#%s %s has these related easyconfigs: %s" % (pr, ec['spec'], files)) | ||
| if pr: | ||
| _log.debug("File in PR#%s %s has these related easyconfigs: %s" % (pr, ec['spec'], files)) | ||
| else: | ||
| _log.debug("File in new PR %s has these related easyconfigs: %s" % (ec['spec'], files)) | ||
|
||
| if files: | ||
| lines.append(multidiff(ec['spec'], files, colored=colored)) | ||
| else: | ||
| lines.extend(['', "(no related easyconfigs found for %s)\n" % os.path.basename(ec['spec'])]) | ||
|
|
||
| return '\n'.join(lines) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @migueldiascosta This is working as expected now, but there's way too much copy-pasting going on here when comparing Can we create a private method (
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @boegel definitely, will do
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current approach of enhancing the existing |
||
|
|
||
|
|
||
| def dump_env_script(easyconfigs): | ||
| """ | ||
| Dump source scripts that set up build environment for specified easyconfigs. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -276,7 +276,7 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None): | |
| merge_pr(options.merge_pr) | ||
|
|
||
| elif options.review_pr: | ||
| print review_pr(options.review_pr, colored=use_color(options.color)) | ||
| print review_pr(pr=options.review_pr, colored=use_color(options.color)) | ||
|
|
||
| elif options.list_installed_software: | ||
| detailed = options.list_installed_software == 'detailed' | ||
|
|
@@ -323,7 +323,7 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None): | |
| categorized_paths = categorize_files_by_type(orig_paths) | ||
|
|
||
| # command line options that do not require any easyconfigs to be specified | ||
| no_ec_opts = [options.aggregate_regtest, options.new_pr, options.regtest, options.update_pr, search_query] | ||
| no_ec_opts = [options.aggregate_regtest, options.new_pr, options.preview_pr, options.regtest, options.update_pr, search_query] | ||
|
||
|
|
||
| # determine paths to easyconfigs | ||
| paths = det_easyconfig_paths(categorized_paths['easyconfigs']) | ||
|
|
@@ -375,7 +375,7 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None): | |
|
|
||
| forced = options.force or options.rebuild | ||
| dry_run_mode = options.dry_run or options.dry_run_short | ||
| new_update_pr = options.new_pr or options.update_pr | ||
| new_update_pr = options.new_pr or options.update_pr or options.preview_pr | ||
|
||
|
|
||
| # skip modules that are already installed unless forced, or unless an option is used that warrants not skipping | ||
| if not (forced or dry_run_mode or options.extended_dry_run or new_update_pr or options.inject_checksums): | ||
|
|
@@ -402,7 +402,9 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None): | |
|
|
||
| # creating/updating PRs | ||
| if new_update_pr: | ||
| if options.new_pr: | ||
| if options.preview_pr: | ||
| print review_pr(paths=paths, colored=use_color(options.color)) | ||
| elif options.new_pr: | ||
|
||
| new_pr(categorized_paths, ordered_ecs, title=options.pr_title, descr=options.pr_descr, | ||
| commit_msg=options.pr_commit_msg) | ||
| else: | ||
|
|
||
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.
Hmm, shouldn't we pass the paths without the
generatedpart down toreview_prinstead?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.
in main the paths from
det_easyconfig_pathsare transformed to these tuples and I used those, but I suppose I can calldet_easyconfig_pathsin main again, or store the original paths when it is called the first time