From d1ea1556d94d53e6f072959fecdbf1a69df6f4f4 Mon Sep 17 00:00:00 2001 From: izruff Date: Sun, 2 Nov 2025 15:51:23 +0800 Subject: [PATCH 1/3] Init hp-add-tags with new.sh script --- hands_on/add_tags.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 hands_on/add_tags.py diff --git a/hands_on/add_tags.py b/hands_on/add_tags.py new file mode 100644 index 00000000..04f6d0b5 --- /dev/null +++ b/hands_on/add_tags.py @@ -0,0 +1,9 @@ +from exercise_utils.cli import run_command +from exercise_utils.gitmastery import create_start_tag + +__requires_git__ = True +__requires_github__ = True + + +def download(verbose: bool): + pass From 444900a5561534672230b787304ae7cfb01297e7 Mon Sep 17 00:00:00 2001 From: izruff Date: Sun, 2 Nov 2025 15:54:17 +0800 Subject: [PATCH 2/3] Implement hp-add-tags download workflow --- hands_on/add_tags.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hands_on/add_tags.py b/hands_on/add_tags.py index 04f6d0b5..fa1705a3 100644 --- a/hands_on/add_tags.py +++ b/hands_on/add_tags.py @@ -1,9 +1,11 @@ from exercise_utils.cli import run_command -from exercise_utils.gitmastery import create_start_tag __requires_git__ = True __requires_github__ = True +WORKING_REPO = "samplerepo-preferences" + def download(verbose: bool): - pass + run_command(["gh", "repo", "fork", f"git-mastery/{WORKING_REPO}", + "--clone"], verbose) From 0633878108d048fd1de8c19f931ad4b78fa03819 Mon Sep 17 00:00:00 2001 From: jovnc <95868357+jovnc@users.noreply.github.com> Date: Fri, 12 Dec 2025 16:04:59 +0800 Subject: [PATCH 3/3] [hp-add-tags] Align method to fork repository --- hands_on/add_tags.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/hands_on/add_tags.py b/hands_on/add_tags.py index fa1705a3..144bc373 100644 --- a/hands_on/add_tags.py +++ b/hands_on/add_tags.py @@ -1,11 +1,25 @@ -from exercise_utils.cli import run_command +from exercise_utils.github_cli import ( + get_github_username, + has_repo, + fork_repo, + delete_repo, + clone_repo_with_gh, +) __requires_git__ = True __requires_github__ = True -WORKING_REPO = "samplerepo-preferences" + +TARGET_REPO = "git-mastery/samplerepo-preferences" +LOCAL_DIR = "gitmastery-samplerepo-preferences" def download(verbose: bool): - run_command(["gh", "repo", "fork", f"git-mastery/{WORKING_REPO}", - "--clone"], verbose) + username = get_github_username(verbose) + full_repo_name = f"{username}/{LOCAL_DIR}" + + if has_repo(full_repo_name, True, verbose): + delete_repo(full_repo_name, verbose) + + fork_repo(TARGET_REPO, LOCAL_DIR, verbose) + clone_repo_with_gh(full_repo_name, verbose)