Skip to content

Commit

Permalink
feat: Update "vendorize" noxfile session to allow commit directly on …
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
jcfr committed Aug 15, 2024
1 parent 5debd82 commit c6c6d48
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ def _vendorize(session: nox.Session, paths: list[str]) -> None:
"""
Vendorize files into a directory. Directory must exist.
"""
project = "MorphoCloudWorkflow"

parser = argparse.ArgumentParser()
parser.add_argument(
"--commit", action="store_true", help="Make a branch and commit."
"--commit", action="store_true", help="Commit onto the current branch."
)
parser.add_argument(
"--branch",
action="store_true",
help=f"Make a branch (e.g update-to-{project.lower()}-SHA).",
)
parser.add_argument(
"target", type=Path, help="The target directory to vendorize file into."
Expand All @@ -50,7 +57,6 @@ def _vendorize(session: nox.Session, paths: list[str]) -> None:

if args.commit:
org = "MorphoCloud"
project = "MorphoCloudWorkflow"

# if any, extract SHA associated with the last update
with session.chdir(target_dir):
Expand Down Expand Up @@ -87,13 +93,15 @@ def _vendorize(session: nox.Session, paths: list[str]) -> None:
)

with session.chdir(target_dir):
session.run(
"git",
"switch",
"-c",
f"update-to-{project.lower()}-{after}",
external=True,
)
if args.branch:
session.run(
"git",
"switch",
"-c",
f"update-to-{project.lower()}-{after}",
external=True,
)

session.run("git", "add", "-A", external=True)
session.run(
"git",
Expand All @@ -112,10 +120,13 @@ def _vendorize(session: nox.Session, paths: list[str]) -> None:
else f"fix: Update to {org}/{project}@{after}",
external=True,
)
command = f"cd MorphoCloudWorkflow; pipx run nox -s {session.name} -- /path/to/{target_dir.stem} --commit"
session.log(
f'Complete! Now run: gh pr create --fill --body "Created by running `{command}`"'
)
if args.branch:
command = f"cd {src_dir.stem}; pipx run nox -s {session.name} -- /path/to/{target_dir.stem} --commit"
session.log(
f'Complete! Now run: cd {target_dir}; gh pr create --fill --body "Created by running `{command}`"'
)
else:
session.log(f"Complete! Now run: cd {target_dir}; git push origin main")


@nox.session
Expand Down

0 comments on commit c6c6d48

Please sign in to comment.