-
Notifications
You must be signed in to change notification settings - Fork 25
Implement hands on hp-move-tags #111
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from exercise_utils.cli import run_command | ||
| from exercise_utils.gitmastery import create_start_tag | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
|
|
||
| __requires_git__ = True | ||
| __requires_github__ = True | ||
|
|
||
|
|
||
| def download(verbose: bool): | ||
| """ | ||
| hp-move-tags (T4L2) | ||
| - Fork https://github.com/git-mastery/samplerepo-preferences to user account | ||
| - Clone the fork locally as 'samplerepo-preferences' | ||
| - Create: | ||
| * lightweight tag `v1.0` on HEAD | ||
| * annotated tag `v0.9` on HEAD~2 with message "First beta release" | ||
| """ | ||
|
|
||
| # Ensure GitHub CLI is authenticated | ||
| gh_user = run_command(["gh", "api", "user", "--jq", ".login"], verbose).strip() | ||
| if not gh_user: | ||
| raise RuntimeError("GitHub CLI not authenticated. Run `gh auth login` and retry.") | ||
|
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. This is already handled when you set |
||
|
|
||
| upstream = "git-mastery/samplerepo-preferences" | ||
| target_dir = Path("samplerepo-preferences") | ||
|
|
||
| # Fresh sandbox, if re-downloading | ||
| if target_dir.exists(): | ||
| import shutil | ||
|
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. I would avoid local imports, there's no issues with importing it at the start of the script |
||
| shutil.rmtree(target_dir) | ||
|
|
||
| # Fork to user's account and clone here; origin -> user's fork, upstream -> original | ||
| run_command(["gh", "repo", "fork", upstream, "--clone=true", "--remote=true"], verbose) | ||
|
|
||
| if not target_dir.exists(): | ||
| raise RuntimeError("Expected 'samplerepo-preferences' not found after fork/clone.") | ||
|
|
||
| os.chdir(target_dir) | ||
|
|
||
| # Prepare the tags | ||
| run_command(["git", "tag", "v1.0"], verbose) # lightweight on HEAD | ||
| run_command(["git", "tag", "-a", "v0.9", "HEAD~2", "-m", "First beta release"], verbose) | ||
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.
We don't need this