Skip to content

Commit abbf991

Browse files
Implement T8L2/remote-branch-pull-new (#285)
# Exercise Review ## Exercise Discussion Fixes #270 Link the exercise discussion issue [Link to issue](#270) ## Notes for Reviewers - Added a utility function `delete_remote_tracking_branch_locally` in `exercise_utils/git.py` just to follow standard. Understand if that function has limited reusability and can change to write `run_command` directly in `remote_branch_pull_new.py` ## Checklist - [ ] If you require a new remote repository on the `Git-Mastery` organization, have you [created a request](https://github.com/git-mastery/exercises/issues/new?template=request_exercise_repository.yaml) for it? - [ ] Have you written unit tests using [`repo-smith`](https://github.com/git-mastery/repo-smith) to validate the exercise grading scheme? - [x] Have you tested your changes using the instructions posted? - [x] Have you verified that this exercise does not already exist or is not currently in review? - [ ] Did you introduce a new grading mechanism that should belong to [`git-autograder`](https://github.com/git-mastery/git-autograder)? - [ ] Did you introduce a new dependency that should belong to [`app`](https://github.com/git-mastery/app)? --------- Co-authored-by: jovnc <95868357+jovnc@users.noreply.github.com>
1 parent ea90d90 commit abbf991

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

hands_on/remote_branch_pull_new.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import os
2+
3+
from exercise_utils.git import remove_remote, run_command, track_remote_branch
4+
from exercise_utils.github_cli import (
5+
clone_repo_with_gh,
6+
delete_repo,
7+
fork_repo,
8+
get_github_username,
9+
has_repo,
10+
)
11+
12+
__requires_git__ = True
13+
__requires_github__ = True
14+
15+
TARGET_REPO = "git-mastery/samplerepo-company-2"
16+
FORK_NAME = "gitmastery-samplerepo-company-2"
17+
LOCAL_DIR = "samplerepo-company"
18+
19+
20+
def download(verbose: bool):
21+
username = get_github_username(verbose)
22+
full_repo_name = f"{username}/{FORK_NAME}"
23+
24+
if has_repo(full_repo_name, True, verbose):
25+
delete_repo(full_repo_name, verbose)
26+
27+
fork_repo(TARGET_REPO, FORK_NAME, verbose, False)
28+
clone_repo_with_gh(full_repo_name, verbose, LOCAL_DIR)
29+
30+
os.chdir(LOCAL_DIR)
31+
32+
remove_remote("upstream", verbose)
33+
track_remote_branch("origin", "track-sales", verbose)
34+
run_command(["git", "branch", "-dr", "origin/track-sales"], verbose)

0 commit comments

Comments
 (0)