forked from importers/git-importer
Download .spec and .changes file only for now
This commit is contained in:
@@ -278,9 +278,11 @@ class Importer:
|
||||
return f"{self.branch} c:{self.commit.short_string()}{p1_str}{p2_str}"
|
||||
|
||||
class FlatTreeWalker(AbstractWalker):
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, rebase_devel) -> None:
|
||||
super().__init__()
|
||||
self.flats = []
|
||||
# the rebase_devel won't work as such as rebasing the branch needs an explicit action
|
||||
self.rebase_devel = rebase_devel
|
||||
# remember the last merge point so we can know the parent of it for the root of the sources
|
||||
self.last_merge = None
|
||||
|
||||
@@ -288,7 +290,7 @@ class Importer:
|
||||
self.flats.append(FlatNode(branch, commit, parent1, parent2))
|
||||
|
||||
def handle_source_node(self, node) -> None:
|
||||
if node.parent and node.parent.merged_into and False:
|
||||
if self.rebase_devel and node.parent and node.parent.merged_into:
|
||||
self.add("devel", node.revision, node.parent.merged_into.revision)
|
||||
return
|
||||
if node.parent:
|
||||
@@ -312,18 +314,40 @@ class Importer:
|
||||
|
||||
self.last_merge = node
|
||||
|
||||
ftw = FlatTreeWalker()
|
||||
ftw = FlatTreeWalker(self.rebase_devel)
|
||||
tree.walk(ftw)
|
||||
branch_state = {"factory": None, "devel": None}
|
||||
for flat in reversed(ftw.flats):
|
||||
self.commit_flat(flat)
|
||||
self.commit_flat(db, flat, branch_state)
|
||||
|
||||
def commit_flat(self, flat):
|
||||
def limit_download(self, file):
|
||||
if file.endswith(".spec") or file.endswith(".changes"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def commit_flat(self, db, flat, branch_state):
|
||||
parents = []
|
||||
self.git.checkout(flat.branch)
|
||||
if flat.parent1:
|
||||
parents.append(flat.parent1.git_commit)
|
||||
if flat.parent2:
|
||||
parents.append(flat.parent2.git_commit)
|
||||
to_download, to_delete = flat.commit.calc_delta(db, branch_state[flat.branch])
|
||||
for file in to_delete:
|
||||
if not self.limit_download(file):
|
||||
continue
|
||||
self.git.remove(file)
|
||||
for file in to_download:
|
||||
if not self.limit_download(file):
|
||||
continue
|
||||
self.obs.download(
|
||||
flat.commit.project,
|
||||
flat.commit.package,
|
||||
file,
|
||||
flat.commit.expanded_srcmd5,
|
||||
self.git.path,
|
||||
)
|
||||
self.git.add(file)
|
||||
|
||||
commit = self.git.commit(
|
||||
f"OBS User {flat.commit.userid}",
|
||||
@@ -335,6 +359,7 @@ class Importer:
|
||||
parents=parents,
|
||||
)
|
||||
flat.commit.git_commit = commit
|
||||
branch_state[flat.branch] = flat.commit
|
||||
|
||||
def import_into_db(self):
|
||||
db = DB()
|
||||
|
Reference in New Issue
Block a user