Add force push for the devel branch

As devel branches can change in case of factory reverts we need to force
push. Factory branch shouldn't be affected, so not force pushing there
This commit is contained in:
Stephan Kulow 2022-12-02 09:12:11 +01:00
parent 4692d47120
commit 7b20c03256
2 changed files with 8 additions and 4 deletions

View File

@ -215,13 +215,17 @@ class Git:
url = f"gitea@gitea.opensuse.org:{org_name}/{repo_name}.git" url = f"gitea@gitea.opensuse.org:{org_name}/{repo_name}.git"
self.repo.remotes.create("origin", url) self.repo.remotes.create("origin", url)
def push(self): def push(self, force=False):
remo = self.repo.remotes["origin"] remo = self.repo.remotes["origin"]
keypair = pygit2.KeypairFromAgent("gitea") keypair = pygit2.KeypairFromAgent("gitea")
callbacks = pygit2.RemoteCallbacks(credentials=keypair) callbacks = pygit2.RemoteCallbacks(credentials=keypair)
refspecs = ["refs/heads/factory"] refspecs = ["refs/heads/factory"]
if "refs/heads/devel" in self.repo.references: develspec = "refs/heads/devel"
refspecs.append("refs/heads/devel") if develspec in self.repo.references:
if force:
refspecs.append(f"+{develspec}:{develspec}")
else:
refspecs.append("{develspec}:{develspec}")
remo.push(refspecs, callbacks=callbacks) remo.push(refspecs, callbacks=callbacks)

View File

@ -86,7 +86,7 @@ class GitExporter:
logging.debug(f"Committing {flat}") logging.debug(f"Committing {flat}")
self.commit_flat(flat, branch_state) self.commit_flat(flat, branch_state)
self.git.push() self.git.push(force=True)
def run_gc(self): def run_gc(self):
self.gc_cnt = self.gc_interval self.gc_cnt = self.gc_interval