Compare commits
8 Commits
main
...
use_git_fo
Author | SHA1 | Date | |
---|---|---|---|
|
b74f36c81e | ||
|
7b9b033adc | ||
|
c44cb17e5d | ||
|
3384a6f2b1 | ||
|
1ec72ac80c | ||
|
033b8f8cee | ||
|
17062df04e | ||
|
aa73d97b35 |
10
lib/git.py
10
lib/git.py
@ -85,7 +85,7 @@ class Git:
|
||||
"""Checkout into the branch HEAD"""
|
||||
new_branch = False
|
||||
if branch not in self.branches():
|
||||
self.git_run(["branch", "-q", branch, "HEAD"])
|
||||
self.git_run(["switch", "-q", "--orphan", branch])
|
||||
new_branch = True
|
||||
else:
|
||||
ref = f"refs/heads/{branch}"
|
||||
@ -182,6 +182,12 @@ class Git:
|
||||
def add(self, filename):
|
||||
self.git_run(["add", filename])
|
||||
|
||||
def add_default_gitignore(self):
|
||||
if not (self.path / ".gitignore").exists():
|
||||
with (self.path / ".gitignore").open("w") as f:
|
||||
f.write(".osc\n")
|
||||
self.add(".gitignore")
|
||||
|
||||
def add_default_lfs_gitattributes(self, force=False):
|
||||
if not (self.path / ".gitattributes").exists() or force:
|
||||
with (self.path / ".gitattributes").open("w") as f:
|
||||
@ -271,7 +277,7 @@ class Git:
|
||||
["remote"],
|
||||
stdout=subprocess.PIPE,
|
||||
).stdout.decode("utf-8"):
|
||||
logger.warning("Not pushing to remote because no 'origin' configured")
|
||||
logging.warning("Not pushing to remote because no 'origin' configured")
|
||||
return
|
||||
|
||||
cmd = ["push"]
|
||||
|
@ -86,6 +86,11 @@ class GitExporter:
|
||||
logging.debug(f"Committing {flat}")
|
||||
self.commit_flat(flat, branch_state)
|
||||
|
||||
# make sure that we create devel branch
|
||||
if not branch_state["devel"]:
|
||||
logging.debug("force creating devel")
|
||||
self.git.set_branch_head("devel", self.git.branch_head("factory"))
|
||||
|
||||
self.git.push(force=True)
|
||||
|
||||
def run_gc(self):
|
||||
@ -150,6 +155,7 @@ class GitExporter:
|
||||
|
||||
# create file if not existant
|
||||
self.git.add_default_lfs_gitattributes(force=False)
|
||||
self.git.add_default_gitignore()
|
||||
|
||||
to_download, to_delete = flat.commit.calc_delta(branch_state[flat.branch])
|
||||
for file in to_delete:
|
||||
|
Loading…
Reference in New Issue
Block a user