Skip to content

Commit 92904d7

Browse files
authored
Merge pull request #16 from git-mastery/woojiahao/embed-publish-into-bump
Support repo-smith v2 syntax
2 parents a7e38ed + e61eb94 commit 92904d7

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

app/commands/download.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import click
77
import pytz
8+
from repo_smith.repo_smith import create_repo_smith
89

910
from app.commands.check.git import git
1011
from app.commands.check.github import github
@@ -177,10 +178,12 @@ def _download_hands_on(hands_on: str, formatted_hands_on: str) -> None:
177178
warn("Setup Github and Github CLI before downloading this hands-on")
178179
exit(1)
179180

180-
hands_on_namespace.execute_function(
181-
"download",
182-
{"verbose": get_verbose()},
183-
)
181+
verbose = get_verbose()
182+
with create_repo_smith(verbose, null_repo=True) as repo_smith:
183+
hands_on_namespace.execute_function(
184+
"download",
185+
{"rs": repo_smith, "verbose": verbose},
186+
)
184187
success(f"Completed setting up {click.style(hands_on, bold=True, italic=True)}")
185188

186189

@@ -251,10 +254,12 @@ def setup_exercise_folder(
251254
empty_commit(initial_commit_message)
252255

253256
info("Executing download setup")
254-
namespace.execute_function(
255-
"setup",
256-
{"verbose": get_verbose()},
257-
)
257+
verbose = get_verbose()
258+
with create_repo_smith(verbose, existing_path=".") as repo_smith:
259+
namespace.execute_function(
260+
"setup",
261+
{"rs": repo_smith, "verbose": verbose},
262+
)
258263

259264
success(f"Completed setting up {click.style(exercise, bold=True, italic=True)}")
260265
info("Start working on it:")

app/utils/gitmastery.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import inspect
12
import os
23
import sys
34
import tempfile
@@ -21,10 +22,15 @@
2122
T = TypeVar("T")
2223

2324

24-
# We hardcode this list because to fetch it dynamically requires a Github API call
25-
# which we only have 60/hour so it's unwise to do it
26-
# TODO(woojiahao): Find a better way around this
27-
EXERCISE_UTILS_FILES = ["__init__", "cli", "git", "file", "gitmastery", "github_cli"]
25+
EXERCISE_UTILS_FILES = [
26+
"__init__",
27+
"cli",
28+
"git",
29+
"file",
30+
"gitmastery",
31+
"github_cli",
32+
"test",
33+
]
2834

2935

3036
class ExercisesRepo:
@@ -147,7 +153,10 @@ def execute_function(
147153
sys.dont_write_bytecode = False
148154
return None
149155

150-
result = self.namespace[function_name](**params)
156+
func = self.namespace[function_name]
157+
sig = inspect.signature(func)
158+
valid_params = {k: v for k, v in params.items() if k in sig.parameters}
159+
result = self.namespace[function_name](**valid_params)
151160
sys.dont_write_bytecode = False
152161
return result
153162

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ git-autograder==6.*
88
pytz
99
PyYAML
1010
GitPython
11+
repo-smith

0 commit comments

Comments
 (0)