Skip to content

Commit ceb604c

Browse files
committed
[stage-fright] Use new utils
1 parent 8828453 commit ceb604c

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

stage_fright/download.py

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,11 @@
1-
import subprocess
2-
from sys import exit
3-
from typing import List, Optional
4-
5-
6-
def run_command(command: List[str], verbose: bool) -> Optional[str]:
7-
try:
8-
result = subprocess.run(
9-
command,
10-
capture_output=True,
11-
text=True,
12-
check=True,
13-
)
14-
if verbose:
15-
print(result.stdout)
16-
return result.stdout
17-
except subprocess.CalledProcessError as e:
18-
if verbose:
19-
print(e.stderr)
20-
exit(1)
1+
from exercise_utils.file import create_or_update_file
2+
from exercise_utils.git import add
3+
from exercise_utils.gitmastery import create_start_tag
214

225

236
def setup(verbose: bool = False):
247
names = ["alice", "bob", "joe", "jim", "carrey"]
258
for name in names:
26-
open(f"{name}.txt", "a").close()
27-
run_command(["git", "add", "jim.txt"], verbose)
28-
run_command(["git", "add", "carrey.txt"], verbose)
29-
commits_str = run_command(
30-
["git", "log", "--reverse", "--pretty=format:%h"], verbose
31-
)
32-
assert commits_str is not None
33-
first_commit = commits_str.split(" ")[0]
34-
tag_name = f"git-mastery-start-{first_commit}"
35-
run_command(["git", "tag", tag_name], verbose)
9+
create_or_update_file(f"{name}.txt", "a")
10+
add(["jim.txt", "carrey.txt"], verbose)
11+
create_start_tag(verbose)

0 commit comments

Comments
 (0)