forked from importers/git-importer
Merge pull request 'Push to the remote when the repo changed' (#19) from push_it_baby into main
Reviewed-on: https://gitea.opensuse.org/importers/git-importer/pulls/19
This commit is contained in:
commit
d1a8a3288d
11
lib/git.py
11
lib/git.py
@ -214,3 +214,14 @@ class Git:
|
|||||||
print(response.data)
|
print(response.data)
|
||||||
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):
|
||||||
|
remo = self.repo.remotes["origin"]
|
||||||
|
|
||||||
|
keypair = pygit2.KeypairFromAgent("gitea")
|
||||||
|
callbacks = pygit2.RemoteCallbacks(credentials=keypair)
|
||||||
|
|
||||||
|
refspecs = ["refs/heads/factory"]
|
||||||
|
if "refs/heads/devel" in self.repo.references:
|
||||||
|
refspecs.append("refs/heads/devel")
|
||||||
|
remo.push(refspecs, callbacks=callbacks)
|
||||||
|
@ -84,6 +84,8 @@ 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()
|
||||||
|
|
||||||
def run_gc(self):
|
def run_gc(self):
|
||||||
self.gc_cnt = self.gc_interval
|
self.gc_cnt = self.gc_interval
|
||||||
self.git.gc()
|
self.git.gc()
|
||||||
|
Loading…
Reference in New Issue
Block a user