Skip to content

Commit 37ed10a

Browse files
[hp-update-remote] Implement hands on hp-update-remote (#81)
# Exercise Review ## Exercise Discussion #57 ## 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.md) 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 the download script using `test-download.sh`? - [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 8bbf0c6 commit 37ed10a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

hands_on/update_remote.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os
2+
3+
from exercise_utils.cli import run_command
4+
from exercise_utils.file import create_or_update_file, append_to_file
5+
from exercise_utils.git import add, init, commit, add_remote
6+
from exercise_utils.github_cli import (
7+
delete_repo,
8+
has_repo,
9+
get_github_username,
10+
create_repo
11+
)
12+
13+
__requires_git__ = True
14+
__requires_github__ = True
15+
16+
REPO_NAME = "gitmastery-things"
17+
18+
def download(verbose: bool):
19+
username = get_github_username(verbose)
20+
os.makedirs("things")
21+
os.chdir("things")
22+
init(verbose)
23+
create_or_update_file("fruits.txt", """
24+
apples
25+
bananas
26+
cherries
27+
dragon fruits
28+
""",
29+
)
30+
add(["fruits.txt"], verbose)
31+
append_to_file("fruits.txt", "figs")
32+
add(["fruits.txt"], verbose)
33+
commit("Insert figs into fruits.txt", verbose)
34+
create_or_update_file("colours.txt", """
35+
a file for colours
36+
""",
37+
)
38+
create_or_update_file("shapes.txt", """
39+
a file for shapes
40+
""",
41+
)
42+
add(["colours.txt", "shapes.txt"], verbose)
43+
commit("Add colours.txt, shapes.txt", verbose)
44+
repo_check = has_repo(REPO_NAME, False, verbose)
45+
46+
if repo_check:
47+
delete_repo(REPO_NAME, verbose)
48+
49+
create_repo(REPO_NAME, verbose)
50+
add_remote("origin", f"https://github.com/{username}/{REPO_NAME}", verbose)
51+
52+
run_command(["git", "push", "-u", "origin", "main"], verbose)

0 commit comments

Comments
 (0)