8
8
from git import Head , Repo
9
9
from git .refs .tag import Tag
10
10
from git .repo .fun import is_git_dir
11
- from git .util import IterableList
12
11
13
12
from .common import BaseTestCase , CommandResult , run_executable
14
13
@@ -54,6 +53,10 @@ def __init__(self, path: str | Path, *args, **kwargs):
54
53
)
55
54
56
55
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] " )
57
60
else :
58
61
if is_git_dir (path ):
59
62
self .repo = Repo (path , * args , ** kwargs )
@@ -70,7 +73,7 @@ def __init__(self, path: str | Path, *args, **kwargs):
70
73
def __enter__ (self ):
71
74
return self
72
75
73
- def __exit__ (self , exc_type , exc_val , exc_tb ):
76
+ def __exit__ (self , exc_type , exc_val , exc_tb ) -> None :
74
77
self .cleanup ()
75
78
76
79
def cleanup (self ) -> None :
@@ -147,7 +150,7 @@ def create_random_commits(self, amount: int, branch: Head | None = None) -> None
147
150
if branch is not None :
148
151
previous_branch .checkout ()
149
152
150
- def get_all_tag_refs (self ) -> IterableList :
153
+ def get_all_tag_refs (self ) -> list [ Tag ] :
151
154
return Tag .list_items (self .repo )
152
155
153
156
def get_tag_refs_at (self , commit_hash : str ) -> list [Tag ]:
@@ -167,7 +170,9 @@ def visualize(self) -> str:
167
170
168
171
169
172
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 :
171
176
tag_path = "refs/tags/" + name
172
177
tag_refs = repo .get_tag_refs_at (commit_hash )
173
178
for tag_ref in tag_refs :
@@ -181,7 +186,7 @@ def assertHasTagWithNameAt(self, repo: Repository, name: str, commit_hash: str):
181
186
182
187
def assertHasTagWithNameAndMessageAt (
183
188
self , repo : Repository , name : str , message : str , commit_hash : str
184
- ):
189
+ ) -> None :
185
190
tag_path = "refs/tags/" + name
186
191
tag_refs = repo .get_tag_refs_at (commit_hash )
187
192
for tag_ref in tag_refs :
0 commit comments