forked from importers/git-importer
Fix up some code after aplanas' continued review
This commit is contained in:
parent
6ac0f90ec7
commit
172242891d
@ -91,7 +91,7 @@ def main():
|
||||
return
|
||||
|
||||
if not args.repodir:
|
||||
args.repodir = pathlib.Path("repos/" + args.package)
|
||||
args.repodir = pathlib.Path("repos") / args.package
|
||||
|
||||
importer = Importer(URL_OBS, "openSUSE:Factory", args.package)
|
||||
importer.import_into_db()
|
||||
|
@ -1,6 +1,10 @@
|
||||
class AbstractWalker:
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class AbstractWalker(ABC):
|
||||
"""Just a duck type, most likely not needed by python, but I
|
||||
find interface classes preferable (java school)"""
|
||||
|
||||
@abstractmethod
|
||||
def call(self, node, is_source):
|
||||
pass
|
||||
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from hashlib import md5
|
||||
from pathlib import PurePath
|
||||
from typing import Optional
|
||||
|
||||
from lib.db import DB
|
||||
@ -223,11 +224,11 @@ class DBRevision:
|
||||
for entry in self.files_list(db):
|
||||
if old_files.get(entry["name"]) != f"{entry['md5']}-{entry['size']}":
|
||||
logging.debug(f"Download {entry['name']}")
|
||||
to_download.append((entry["name"], entry["md5"]))
|
||||
to_download.append((PurePath(entry["name"]), entry["md5"]))
|
||||
old_files.pop(entry["name"], None)
|
||||
for entry in old_files.keys():
|
||||
logging.debug(f"Delete {entry}")
|
||||
to_delete.append(entry)
|
||||
to_delete.append(PurePath(entry))
|
||||
return to_download, to_delete
|
||||
|
||||
@staticmethod
|
||||
|
@ -9,12 +9,8 @@ class FlatNode:
|
||||
self.parent2 = parent2
|
||||
|
||||
def __str__(self) -> str:
|
||||
p1_str = ""
|
||||
if self.parent1:
|
||||
p1_str = f" p1:{self.parent1.short_string()}"
|
||||
p2_str = ""
|
||||
if self.parent2:
|
||||
p2_str = f" p2:{self.parent2.short_string()}"
|
||||
p1_str = f" p1:{self.parent1.short_string()}" if self.parent1 else ""
|
||||
p2_str = f" p2:{self.parent2.short_string()}" if self.parent2 else ""
|
||||
return f"{self.branch} c:{self.commit.short_string()}{p1_str}{p2_str}"
|
||||
|
||||
|
||||
@ -36,8 +32,7 @@ class FlatTreeWalker(AbstractWalker):
|
||||
def handle_source_node(self, node) -> None:
|
||||
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:
|
||||
elif node.parent:
|
||||
self.add("devel", node.revision, node.parent.revision)
|
||||
elif self.last_merge:
|
||||
self.add("devel", node.revision, self.last_merge.parent.revision)
|
||||
|
10
lib/git.py
10
lib/git.py
@ -256,11 +256,11 @@ class Git:
|
||||
)
|
||||
return any(fnmatch.fnmatch(filename, line) for line in patterns)
|
||||
|
||||
def remove(self, filename):
|
||||
self.repo.index.remove(filename)
|
||||
(self.path / filename).unlink()
|
||||
def remove(self, file: pathlib.Path):
|
||||
self.repo.index.remove(file.name)
|
||||
(self.path / file).unlink()
|
||||
|
||||
patterns = self.get_specific_lfs_gitattributes()
|
||||
if filename in patterns:
|
||||
patterns.remove(filename)
|
||||
if file.name in patterns:
|
||||
patterns.remove(file.name)
|
||||
self.add_specific_lfs_gitattributes(patterns)
|
||||
|
@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
@ -121,10 +122,8 @@ class GitExporter:
|
||||
logging.debug(f"Committing {flat}")
|
||||
self.commit_flat(db, flat, branch_state)
|
||||
|
||||
def limit_download(self, file):
|
||||
if file.endswith(".spec") or file.endswith(".changes"):
|
||||
return True
|
||||
return False
|
||||
def limit_download(self, file: Path):
|
||||
return file.suffix in (".spec", ".changes")
|
||||
|
||||
def commit_flat(self, db, flat, branch_state):
|
||||
parents = []
|
||||
@ -144,7 +143,7 @@ class GitExporter:
|
||||
self.obs.download(
|
||||
flat.commit.project,
|
||||
flat.commit.package,
|
||||
file,
|
||||
file.name,
|
||||
flat.commit.expanded_srcmd5,
|
||||
self.git.path,
|
||||
file_md5=md5,
|
||||
|
Loading…
Reference in New Issue
Block a user