Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions exercise_utils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ 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."""
Expand Down
14 changes: 14 additions & 0 deletions hands_on/pull_remote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

from exercise_utils.cli import run_command
from exercise_utils.git import clone

__requires_git__ = True
__requires_github__ = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
__requires_github__ = True
__requires_github__ = False

This can be set to False if you do not use gh as part of the script



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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run_command(["git", "remote", "set-url", "origin", "https://github.com/git-mastery/samplerepo-finances-2.git"], verbose)
run_command(["git", "remote", "set-url", "origin", "https://github.com/git-mastery/samplerepo-finances-2.git"], verbose)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious what the rationale behind abstracting clone to a utility function but not set-url?