Compare commits

...

3 Commits

Author SHA1 Message Date
Dirk Müller
574bc9aa10
Avoid guessing in switch 2024-05-17 20:07:16 +02:00
Dirk Müller
0414b33206
Fix testing for origin
The previous code path was untested and not working
2024-05-17 20:06:25 +02:00
Dirk Müller
b9670821a9
Only init the repository if it doesn't exist already
harmless, but avoids a scary warning
2024-05-17 20:05:54 +02:00

View File

@ -46,7 +46,8 @@ class Git:
)
def open(self):
self.git_run(["init", "--object-format=sha256", "-b", "factory"])
if not self.exists():
self.git_run(["init", "--object-format=sha256", "-b", "factory"])
def is_dirty(self):
"""Check if there is something to commit"""
@ -89,7 +90,7 @@ class Git:
else:
ref = f"refs/heads/{branch}"
if (self.path / ".git" / ref).exists():
self.git_run(["switch", "-q", branch])
self.git_run(["switch", "--no-guess", "-q", branch])
return new_branch
def commit(
@ -266,7 +267,10 @@ class Git:
)
def push(self, force=False):
if "origin" not in self.git_run(["remote"]).stdout:
if "origin" not in self.git_run(
["remote"],
stdout=subprocess.PIPE,
).stdout.decode("utf-8"):
logger.warning("Not pushing to remote because no 'origin' configured")
return