diff options
| author | Audun Sutterud <audun.sutterud@qt.io> | 2025-05-21 11:55:34 +0200 |
|---|---|---|
| committer | Audun Sutterud <audun.sutterud@qt.io> | 2025-06-02 08:31:40 +0000 |
| commit | 74d66e51f93cc16c3376925b3f4041adabca7dac (patch) | |
| tree | 4ec66c829146575edd707e4501460a53c8a173d0 /git.py | |
| parent | 26104de0f20d4b578be971b2f022240ca851ecd4 (diff) | |
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 <daniel.smith@qt.io>
Diffstat (limited to 'git.py')
| -rw-r--r-- | git.py | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -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 |
