From 611c90e69fc331b75801b27f755fb14b7be2171e Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Wed, 29 Oct 2025 21:31:57 +0800 Subject: [PATCH 1/4] add hands on for pull from remote --- exercise_utils/git.py | 9 +++++++++ hands_on/pull_remote.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 hands_on/pull_remote.py diff --git a/exercise_utils/git.py b/exercise_utils/git.py index 5df9919..7476c25 100644 --- a/exercise_utils/git.py +++ b/exercise_utils/git.py @@ -69,6 +69,15 @@ def push(remote: str, branch: str, verbose: bool) -> None: """Push the given branch on the remote.""" run_command(["git", "push", remote, branch], verbose) +# named it pull_branch to indicate that branch must be specified +def pull_branch(remote: str, branch: str, verbose: bool) -> None: + """Pull from the given branch on the remote""" + run_command(["git", "pull", remote, branch], verbose) + +def clone(repo: str, verbose: bool) -> None: + """Clone an existing repository""" + run_command(["git", "clone", repo], verbose) + def track_remote_branch(remote: str, branch: str, verbose: bool) -> None: """Tracks a remote branch locally using the same name.""" diff --git a/hands_on/pull_remote.py b/hands_on/pull_remote.py new file mode 100644 index 0000000..1570c2d --- /dev/null +++ b/hands_on/pull_remote.py @@ -0,0 +1,15 @@ +import os + +from exercise_utils.cli import run_command +from exercise_utils.git import clone, pull_branch + +__requires_git__ = True +__requires_github__ = True + + +def download(verbose: bool): + os.makedirs("samplerepo-finances") + clone("https://github.com/git-mastery/samplerepo-finances.git", verbose) + os.chdir("samplerepo-finances") + run_command(["git", "remote", "set-url", "origin", "https://github.com/git-mastery/samplerepo-finances-2.git"], verbose) + pull_branch("origin", "master", verbose) \ No newline at end of file From 311ce3a44f0234fa49b85cc04601bf4f11022121 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Wed, 29 Oct 2025 21:44:46 +0800 Subject: [PATCH 2/4] remove pull operation --- exercise_utils/git.py | 5 ----- hands_on/pull_remote.py | 5 ++--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/exercise_utils/git.py b/exercise_utils/git.py index 7476c25..6fa8501 100644 --- a/exercise_utils/git.py +++ b/exercise_utils/git.py @@ -69,11 +69,6 @@ def push(remote: str, branch: str, verbose: bool) -> None: """Push the given branch on the remote.""" run_command(["git", "push", remote, branch], verbose) -# named it pull_branch to indicate that branch must be specified -def pull_branch(remote: str, branch: str, verbose: bool) -> None: - """Pull from the given branch on the remote""" - run_command(["git", "pull", remote, branch], verbose) - def clone(repo: str, verbose: bool) -> None: """Clone an existing repository""" run_command(["git", "clone", repo], verbose) diff --git a/hands_on/pull_remote.py b/hands_on/pull_remote.py index 1570c2d..dc4743d 100644 --- a/hands_on/pull_remote.py +++ b/hands_on/pull_remote.py @@ -1,7 +1,7 @@ import os from exercise_utils.cli import run_command -from exercise_utils.git import clone, pull_branch +from exercise_utils.git import clone __requires_git__ = True __requires_github__ = True @@ -11,5 +11,4 @@ def download(verbose: bool): os.makedirs("samplerepo-finances") clone("https://github.com/git-mastery/samplerepo-finances.git", verbose) os.chdir("samplerepo-finances") - run_command(["git", "remote", "set-url", "origin", "https://github.com/git-mastery/samplerepo-finances-2.git"], verbose) - pull_branch("origin", "master", verbose) \ No newline at end of file + run_command(["git", "remote", "set-url", "origin", "https://github.com/git-mastery/samplerepo-finances-2.git"], verbose) \ No newline at end of file From 156100d25bfef4dabdaed8bac80d81f50f10a25f Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Thu, 20 Nov 2025 13:38:35 +0800 Subject: [PATCH 3/4] update code to use new functions --- exercise_utils/git.py | 5 ----- hands_on/pull_remote.py | 8 ++++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/exercise_utils/git.py b/exercise_utils/git.py index 4a6d9f5..07af85b 100644 --- a/exercise_utils/git.py +++ b/exercise_utils/git.py @@ -69,11 +69,6 @@ def push(remote: str, branch: str, verbose: bool) -> None: """Push the given branch on the remote.""" run_command(["git", "push", remote, branch], verbose) -def clone(repo: str, verbose: bool) -> None: - """Clone an existing repository""" - run_command(["git", "clone", repo], verbose) - - def track_remote_branch(remote: str, branch: str, verbose: bool) -> None: """Tracks a remote branch locally using the same name.""" run_command(["git", "branch", branch, f"{remote}/{branch}"], verbose) diff --git a/hands_on/pull_remote.py b/hands_on/pull_remote.py index dc4743d..1e2fcaf 100644 --- a/hands_on/pull_remote.py +++ b/hands_on/pull_remote.py @@ -1,14 +1,14 @@ import os from exercise_utils.cli import run_command -from exercise_utils.git import clone +from exercise_utils.git import add_remote, clone_repo_with_git __requires_git__ = True -__requires_github__ = True +__requires_github__ = False def download(verbose: bool): os.makedirs("samplerepo-finances") - clone("https://github.com/git-mastery/samplerepo-finances.git", verbose) + clone_repo_with_git("https://github.com/git-mastery/samplerepo-finances.git", verbose) os.chdir("samplerepo-finances") - run_command(["git", "remote", "set-url", "origin", "https://github.com/git-mastery/samplerepo-finances-2.git"], verbose) \ No newline at end of file + add_remote("origin", "https://github.com/git-mastery/samplerepo-finances-2.git", verbose) \ No newline at end of file From b577bbe2e7fca25284249395b536a280e8fb3a95 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Thu, 20 Nov 2025 13:51:01 +0800 Subject: [PATCH 4/4] add blank line --- exercise_utils/git.py | 1 + 1 file changed, 1 insertion(+) diff --git a/exercise_utils/git.py b/exercise_utils/git.py index 07af85b..28d8441 100644 --- a/exercise_utils/git.py +++ b/exercise_utils/git.py @@ -69,6 +69,7 @@ def push(remote: str, branch: str, verbose: bool) -> None: """Push the given branch on the remote.""" run_command(["git", "push", remote, branch], verbose) + def track_remote_branch(remote: str, branch: str, verbose: bool) -> None: """Tracks a remote branch locally using the same name.""" run_command(["git", "branch", branch, f"{remote}/{branch}"], verbose)