Skip to content

Commit 1ad61ee

Browse files
committed
deploy: cc40ae7
1 parent 115adf4 commit 1ad61ee

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

hands_on/stage_modified.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os
2+
import subprocess
3+
from sys import exit
4+
from typing import List, Optional
5+
6+
__requires_git__ = True
7+
__requires_github__ = False
8+
9+
10+
def run_command(command: List[str], verbose: bool) -> Optional[str]:
11+
try:
12+
result = subprocess.run(
13+
command,
14+
capture_output=True,
15+
text=True,
16+
check=True,
17+
)
18+
if verbose:
19+
print(result.stdout)
20+
return result.stdout
21+
except subprocess.CalledProcessError as e:
22+
if verbose:
23+
print(e.stderr)
24+
exit(1)
25+
26+
27+
def download(verbose: bool):
28+
os.makedirs("things")
29+
os.chdir("things")
30+
run_command(["git", "init", "--initial-branch=main"], verbose)
31+
with open("fruits.txt", "w") as f:
32+
f.write("apples\nbananas\ncherries\n")
33+
run_command(["git", "add", "fruits.txt"], verbose)

0 commit comments

Comments
 (0)