Skip to content

Commit f15adc8

Browse files
Implement hp-remote-branch-pull (#230)
# Exercise Review ## Exercise Discussion #187 ## 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)?
1 parent dee7a9a commit f15adc8

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

hands_on/remote_branch_pull.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import os
2+
3+
from exercise_utils.file import append_to_file
4+
from exercise_utils.git import (
5+
add,
6+
checkout,
7+
clone_repo_with_git,
8+
commit,
9+
push
10+
)
11+
from exercise_utils.github_cli import (
12+
get_github_username,
13+
fork_repo,
14+
has_repo,
15+
delete_repo,
16+
)
17+
18+
__requires_git__ = True
19+
__requires_github__ = True
20+
21+
22+
TARGET_REPO = "git-mastery/samplerepo-company"
23+
FORK_NAME = "gitmastery-samplerepo-company"
24+
LOCAL_DIR = "samplerepo-company"
25+
26+
27+
def download(verbose: bool):
28+
username = get_github_username(verbose)
29+
full_repo_name = f"{username}/{FORK_NAME}"
30+
31+
if has_repo(full_repo_name, True, verbose):
32+
delete_repo(full_repo_name, verbose)
33+
34+
fork_repo(TARGET_REPO, FORK_NAME, verbose, False)
35+
clone_repo_with_git(f"https://github.com/{full_repo_name}", verbose, LOCAL_DIR)
36+
37+
os.chdir(LOCAL_DIR)
38+
39+
checkout("hiring", True, verbose)
40+
append_to_file("employees.txt", "Receptionist: Pam\n")
41+
add(["employees.txt"], verbose)
42+
commit("Add Pam to employees.txt", verbose)
43+
44+
push("origin", "hiring", verbose)
45+

0 commit comments

Comments
 (0)