Compare commits

...

8 Commits

Author SHA1 Message Date
Dirk Mueller
b74f36c81e Merge pull request 'Make sure we create devel branch, even if no diff to Factory' (#29) from adamm/git-importer:always_create_devel into use_git_for_sha256
Reviewed-on: #29
2024-06-13 15:02:30 +02:00
Adam Majer
7b9b033adc Make sure we create devel branch, when no diff to Factory 2024-06-13 09:51:27 +02:00
Dirk Mueller
c44cb17e5d Merge pull request 'Ignore .osc directory' (#28) from adamm/git-importer:gitingore into use_git_for_sha256
Reviewed-on: #28
Reviewed-by: Dirk Mueller <dirkmueller@noreply@src.opensuse.org>
2024-06-10 18:13:33 +02:00
Dirk Mueller
3384a6f2b1 Merge pull request 'Fix typo' (#27) from adamm/git-importer:typo into use_git_for_sha256
Reviewed-on: #27
2024-06-10 18:10:40 +02:00
Adam Majer
1ec72ac80c Ignore .osc directory 2024-06-10 17:31:14 +02:00
Dirk Mueller
033b8f8cee Merge pull request 'New branch is empty' (#26) from adamm/git-importer:fix_inintial_branch into use_git_for_sha256
Reviewed-on: #26
Reviewed-by: Dirk Mueller <dirkmueller@noreply@src.opensuse.org>
2024-06-10 17:03:48 +02:00
Adam Majer
17062df04e Fix typo 2024-06-10 15:44:21 +02:00
Adam Majer
aa73d97b35 New branch is empty
New branches must be born empty
2024-06-10 15:35:11 +02:00
2 changed files with 14 additions and 2 deletions

View File

@ -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"]

View File

@ -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: