66def run_command (func ):
77 @wraps (func )
88 def wrapper (* args , ** kwargs ) -> str :
9- command_list = func (* args , ** kwargs ). split ()
9+ command_list = func (* args , ** kwargs )
1010 output = subprocess .run (
1111 command_list , capture_output = True , text = True , check = True
1212 ) # nosec
@@ -18,20 +18,20 @@ def wrapper(*args, **kwargs) -> str:
1818class Git :
1919 @staticmethod
2020 @run_command
21- def get_latest_tag () -> str :
21+ def get_latest_tag ():
2222 """
2323 Get the latest tag from the git repository.
2424 """
25- return "git describe --tags --abbrev=0"
25+ return [ "git" , " describe" , " --tags" , " --abbrev=0"]
2626
2727 @staticmethod
2828 @run_command
29- def read_file_from_tag (tag : str , remote_file : str ) -> str :
29+ def read_file_from_tag (tag : str , remote_file : str ):
3030 """
3131 Read the contents of the specified file `remote_file` at the point in time
3232 specified by git tag `tag`.
3333 """
34- return f "git cat-file blob { tag } :{ remote_file } "
34+ return [ "git" , " cat-file" , " blob" , f" { tag } :{ remote_file } "]
3535
3636 @staticmethod
3737 def copy_remote_file_locally (
@@ -42,10 +42,9 @@ def copy_remote_file_locally(
4242 specified by git tag `tag` and copy it into the local `destination_directory/remote_file`.
4343 """
4444 contents = Git .read_file_from_tag (tag = tag , remote_file = remote_file )
45- destination_filepath = destination_directory / remote_file
46- destination_filepath .write_text (contents )
45+ (destination_directory / remote_file ).write_text (contents )
4746
4847 @staticmethod
4948 @run_command
50- def create_and_switch_to_branch (branch_name : str ) -> str :
51- return f "git switch -c { branch_name } "
49+ def create_and_switch_to_branch (branch_name : str ):
50+ return [ "git" , " switch" , "-c" , branch_name ]
0 commit comments