Skip to content

Commit 82f8f80

Browse files
committed
fix: incorrect use of config_writer
1 parent a05c7d9 commit 82f8f80

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

grading_lib/repository.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ def __init__(self, path: str | Path, *args, **kwargs):
5353
)
5454

5555
self.repo = Repo(temp_dir_path / "repo", *args, **kwargs)
56-
# Some git commands when run on GH Actions need user indentity.
57-
with self.repo.config_writer(config_level="repository") as conf_writer:
58-
conf_writer.set_value("user.name", "ou-cs3560-grading-script")
59-
conf_writer.set_value("user.email", "[email protected]")
6056
else:
6157
if is_git_dir(path):
6258
self.repo = Repo(path, *args, **kwargs)
@@ -68,6 +64,11 @@ def __init__(self, path: str | Path, *args, **kwargs):
6864
"A repository must have a working tree directory (Repo.working_tree_dir must not be None)."
6965
)
7066

67+
# Some git commands when run on GitHub's Actions need a user's indentity.
68+
with self.repo.config_writer(config_level="repository") as conf_writer:
69+
conf_writer.set_value("user", "name", "ou-cs3560-grading-script")
70+
conf_writer.set_value("user", "email", "[email protected]")
71+
7172
self.working_tree_dir = Path(self.repo.working_tree_dir)
7273

7374
def __enter__(self):

tests/test_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def an_empty_folder():
1717
temp_dir.cleanup()
1818

1919

20-
def test_Repository_init(an_empty_folder):
20+
def test_Repository_init_with_an_empty_folder(an_empty_folder):
2121
repo = Repository(an_empty_folder.name)
2222
assert isinstance(repo.working_tree_dir, Path)
2323

0 commit comments

Comments
 (0)