Skip to content

Commit 55d0430

Browse files
committed
Support empty commit when no downloaded resources
1 parent 060c231 commit 55d0430

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

app/commands/download.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
get_username,
1919
has_fork,
2020
)
21-
from app.utils.git_cli_utils import add_all, commit, init
21+
from app.utils.git_cli_utils import add_all, commit, empty_commit, init
2222
from app.utils.gitmastery_utils import (
2323
download_file,
2424
execute_py_file_function_from_url,
@@ -88,8 +88,11 @@ def setup_exercise_folder(
8888

8989
if config.exercise_repo.init:
9090
init(verbose)
91-
add_all(verbose)
92-
commit("Initial commit", verbose)
91+
if download_resources:
92+
add_all(verbose)
93+
commit("Initial commit", verbose)
94+
else:
95+
empty_commit("Initial commit", verbose)
9396

9497
info("Executing download setup")
9598
execute_py_file_function_from_url(

app/utils/git_cli_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ def commit(message: str, verbose: bool) -> None:
1919
subprocess.run(["git", "commit", "-m", message], stdout=stdout, stderr=stderr)
2020

2121

22+
def empty_commit(message: str, verbose: bool) -> None:
23+
stdout, stderr = get_stdout_stderr(verbose)
24+
subprocess.run(
25+
["git", "commit", "-m", message, "--allow-empty"], stdout=stdout, stderr=stderr
26+
)
27+
28+
2229
def push(remote: str, branch: str, verbose: bool) -> None:
2330
stdout, stderr = get_stdout_stderr(verbose)
2431
subprocess.run(["git", "push", "-u", remote, branch], stdout=stdout, stderr=stderr)

0 commit comments

Comments
 (0)