Skip to content

Commit 4e4f03a

Browse files
committed
fix: default identity need when run on gh actions
Fix warnings from mypy.
1 parent cacf3ff commit 4e4f03a

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Fix warnings by mypy.
6+
- Add a default user's identity to the `Repository`. Git on GitHub's Actions will complain
7+
when a command like `git commit` is run without user's identity.
58

69
## v0.1.1a2
710

MAINTENANCE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ make html
6767

6868
## Deployment flow
6969

70+
- Run tox.
7071
- Update `grading_lib/VERSION` file.
7172
- Update `CHANGELOG.md` file.
7273
- Make a commit

grading_lib/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def tearDown(self) -> None:
176176
f"[info]: The temporary directory at '{self.temporary_dir_path}' is not deleted since the DEBUG is set to True."
177177
)
178178

179-
def assertArchiveFileIsGzip(self, path: Path):
179+
def assertArchiveFileIsGzip(self, path: Path) -> None:
180180
cmd_result = run_executable(["gunzip", "-t", str(path)])
181181
self.assertTrue(
182182
"not in gzip format" not in cmd_result.output,

grading_lib/repository.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from git import Head, Repo
99
from git.refs.tag import Tag
1010
from git.repo.fun import is_git_dir
11-
from git.util import IterableList
1211

1312
from .common import BaseTestCase, CommandResult, run_executable
1413

@@ -54,6 +53,10 @@ def __init__(self, path: str | Path, *args, **kwargs):
5453
)
5554

5655
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]")
5760
else:
5861
if is_git_dir(path):
5962
self.repo = Repo(path, *args, **kwargs)
@@ -70,7 +73,7 @@ def __init__(self, path: str | Path, *args, **kwargs):
7073
def __enter__(self):
7174
return self
7275

73-
def __exit__(self, exc_type, exc_val, exc_tb):
76+
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
7477
self.cleanup()
7578

7679
def cleanup(self) -> None:
@@ -147,7 +150,7 @@ def create_random_commits(self, amount: int, branch: Head | None = None) -> None
147150
if branch is not None:
148151
previous_branch.checkout()
149152

150-
def get_all_tag_refs(self) -> IterableList:
153+
def get_all_tag_refs(self) -> list[Tag]:
151154
return Tag.list_items(self.repo)
152155

153156
def get_tag_refs_at(self, commit_hash: str) -> list[Tag]:
@@ -167,7 +170,9 @@ def visualize(self) -> str:
167170

168171

169172
class RepositoryBaseTestCase(BaseTestCase):
170-
def assertHasTagWithNameAt(self, repo: Repository, name: str, commit_hash: str):
173+
def assertHasTagWithNameAt(
174+
self, repo: Repository, name: str, commit_hash: str
175+
) -> None:
171176
tag_path = "refs/tags/" + name
172177
tag_refs = repo.get_tag_refs_at(commit_hash)
173178
for tag_ref in tag_refs:
@@ -181,7 +186,7 @@ def assertHasTagWithNameAt(self, repo: Repository, name: str, commit_hash: str):
181186

182187
def assertHasTagWithNameAndMessageAt(
183188
self, repo: Repository, name: str, message: str, commit_hash: str
184-
):
189+
) -> None:
185190
tag_path = "refs/tags/" + name
186191
tag_refs = repo.get_tag_refs_at(commit_hash)
187192
for tag_ref in tag_refs:

0 commit comments

Comments
 (0)