Skip to content

Commit

Permalink
Improvements to the move-pr-to-intel-llvm script
Browse files Browse the repository at this point in the history
* Added an `--allow-dirty` option to skip the dirty git repo checks.
  Untracked files trip this check up but don't seem to cause any
  problems.
* The default `intel-base-branch` is now "sycl"
* Specifically say "LLVM" branch when talking about feature branches.
* Push to `intel_llvm_push_remote` rather than origin.
* Closing a pull request now uses a string when building the command.
  • Loading branch information
RossBrunton committed Feb 19, 2025
1 parent e162de9 commit 25649c3
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions scripts/move-pr-to-intel-llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@

verbose = False
yes = False
allow_dirty = False

ur_default_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
unified_runtime_slug = "oneapi-src/unified-runtime"
intel_llvm_slug = "intel/llvm"


def main():
global verbose, yes
global verbose, yes, allow_dirty

cli = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter
Expand Down Expand Up @@ -111,14 +112,20 @@ def main():
)
cli.add_argument(
"--intel-llvm-base-branch",
default=None,
default="sycl",
help="intel/llvm branch to base new branch upon, defaults to 'sycl'",
)
cli.add_argument(
"--intel-llvm-feature-branch",
default=None,
help="intel/llvm remote branch to create, defaults to --ur-branch",
)
cli.add_argument(
"--allow-dirty",
default=False,
action="store_true",
help="Skip checks for a clean workspace. Please check any generated patch files before applying",
)
args = cli.parse_args()

if platform.system() != "Linux":
Expand All @@ -127,6 +134,7 @@ def main():

verbose = args.verbose
yes = args.yes
allow_dirty = args.allow_dirty

git = get_git_executable()
gh = get_gh_executable()
Expand Down Expand Up @@ -173,7 +181,7 @@ def main():
locally
and remotely
and not confirm(
f"Feature branch '{args.intel_llvm_feature_branch}' exists "
f"LLVM feature branch '{args.intel_llvm_feature_branch}' exists "
"locally and remotely, proceed with applying patches on top "
"of this branch?"
)
Expand All @@ -182,7 +190,7 @@ def main():
not locally
and remotely
and not confirm(
f"Feature branch '{args.intel_llvm_feature_branch}' exists "
f"LLVM feature branch '{args.intel_llvm_feature_branch}' exists "
"remotely but not locally, proceed with applying patches on "
"top of this branch?"
)
Expand All @@ -191,7 +199,7 @@ def main():
locally
and not remotely
and not confirm(
f"Feature branch '{args.intel_llvm_feature_branch}' exists "
f"LLVM feature branch '{args.intel_llvm_feature_branch}' exists "
"locally but not remotely, proceed with applying patches on "
"top of this branch?"
)
Expand Down Expand Up @@ -230,14 +238,14 @@ def main():
os.remove(patch)

if not confirm(
f"Push '{args.intel_llvm_feature_branch}' to '{args.intel_llvm_remote}'?"
f"Push '{args.intel_llvm_feature_branch}' to '{args.intel_llvm_push_remote}'?"
):
print("Please push the changes and create your pull request manually.")
exit(0)
push_branch(
git,
args.intel_llvm_dir,
args.intel_llvm_remote,
args.intel_llvm_push_remote,
args.intel_llvm_feature_branch,
)

Expand All @@ -260,7 +268,7 @@ def main():
if not confirm(f"Close {ur_pr['url']}?"):
print("Please create your pull request manually.")
exit()
close_pull_request(gh, args.ur_dir, unified_runtime_slug, ur_pr["number"])
close_pull_request(gh, args.ur_dir, unified_runtime_slug, str(ur_pr["number"]))


def get_git_executable() -> str:
Expand Down Expand Up @@ -319,6 +327,8 @@ def get_current_branch(git, dir) -> str:


def check_worktree_is_clean(git, dir):
if allow_dirty:
return
result = run([git, "-C", dir, "status", "--porcelain"], stdout=PIPE)
stdout = result.stdout.decode()
if verbose:
Expand Down

0 comments on commit 25649c3

Please sign in to comment.