From 611c90e69fc331b75801b27f755fb14b7be2171e Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Wed, 29 Oct 2025 21:31:57 +0800 Subject: [PATCH 1/2] 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/2] 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