4
4
5
5
import os
6
6
import shutil
7
+ import subprocess
7
8
import sys
8
9
import textwrap
9
10
import time
10
11
import typing
11
12
from glob import glob
12
13
from pathlib import Path
13
- from subprocess import run
14
14
from urllib .parse import quote
15
15
16
16
import click
17
17
18
18
19
- def shell (cmd , * , check : bool , ** kwargs ) :
20
- return run ([cmd ], shell = True , check = check , ** kwargs )
19
+ def shell (cmd : str , * , check : bool , ** kwargs : object ) -> subprocess . CompletedProcess [ str ] :
20
+ return subprocess . run ([cmd ], shell = True , check = check , ** kwargs ) # type: ignore[call-overload, no-any-return]
21
21
22
22
23
- def git_repo_has_changes ():
23
+ def git_repo_has_changes () -> bool :
24
24
unstaged_changes = shell ("git diff-index --quiet HEAD --" , check = False ).returncode != 0
25
25
staged_changes = shell ("git diff-index --quiet --cached HEAD --" , check = False ).returncode != 0
26
26
return unstaged_changes or staged_changes
27
27
28
28
29
- def generate_basic_project (path ) :
29
+ def generate_basic_project (path : Path ) -> None :
30
30
sys .path .insert (0 , "" )
31
31
from test .test_projects .c import new_c_project
32
32
@@ -79,7 +79,7 @@ class CIService(typing.NamedTuple):
79
79
]
80
80
81
81
82
- def ci_service_for_config_file (config_file ) :
82
+ def ci_service_for_config_file (config_file : str ) -> CIService :
83
83
filename = Path (config_file ).name
84
84
85
85
try :
@@ -134,7 +134,7 @@ def run_example_ci_configs(config_files=None):
134
134
dst_config_file .parent .mkdir (parents = True , exist_ok = True )
135
135
shutil .copyfile (src_config_file , dst_config_file )
136
136
137
- run (["git" , "add" , example_project ], check = True )
137
+ subprocess . run (["git" , "add" , example_project ], check = True )
138
138
message = textwrap .dedent (
139
139
f"""\
140
140
Test example minimal configs
@@ -144,7 +144,7 @@ def run_example_ci_configs(config_files=None):
144
144
Time: { timestamp }
145
145
"""
146
146
)
147
- run (["git" , "commit" , "--no-verify" , "--message" , message ], check = True )
147
+ subprocess . run (["git" , "commit" , "--no-verify" , "--message" , message ], check = True )
148
148
shell (f"git subtree --prefix={ example_project } push origin { branch_name } " , check = True )
149
149
150
150
print ("---" )
0 commit comments