From 74d66e51f93cc16c3376925b3f4041adabca7dac Mon Sep 17 00:00:00 2001 From: Audun Sutterud Date: Wed, 21 May 2025 11:55:34 +0200 Subject: Improve usability of git.py * Split one function into three. This allows us to do git operations separately. It also simplifies a follow-up patch. We need to perform a clean operation separately. Change-Id: Ic95c15d89557af65ccdb0718edf178a632b9f451 Reviewed-by: Daniel Smith --- git.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'git.py') diff --git a/git.py b/git.py index fd827f9..b9b62f9 100644 --- a/git.py +++ b/git.py @@ -46,32 +46,26 @@ class Repository: return Repository(directory) - async def reset(self, revision: str, log_directory: str) -> Optional[common.Error]: - error = await common.Command.run( + async def fetch(self, revision: str, log_directory: str) -> Optional[common.Error]: + return await common.Command.run( arguments=["git", "fetch", "origin", revision], output_file=os.path.join(log_directory, "fetch.log"), timeout=COMMAND_TIMEOUT, cwd=self.directory, ) - if error: - return error - error = await common.Command.run( + async def clean(self, log_directory: str) -> Optional[common.Error]: + return await common.Command.run( arguments=["git", "clean", "-dfx"], output_file=os.path.join(log_directory, "clean.log"), timeout=COMMAND_TIMEOUT, cwd=self.directory, ) - if error: - return error - error = await common.Command.run( + async def reset(self, revision: str, log_directory: str) -> Optional[common.Error]: + return await common.Command.run( arguments=["git", "reset", "--hard", revision], output_file=os.path.join(log_directory, "reset.log"), timeout=COMMAND_TIMEOUT, cwd=self.directory, ) - if error: - return error - - return None -- cgit v1.2.3