Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/git/from_disk.py
Show All 15 Lines | |||||
except ImportError: | except ImportError: | ||||
# dulwich >= 0.20 | # dulwich >= 0.20 | ||||
from dulwich.objects import EmptyFileException | from dulwich.objects import EmptyFileException | ||||
from deprecated import deprecated | from deprecated import deprecated | ||||
import dulwich.objects | import dulwich.objects | ||||
import dulwich.repo | import dulwich.repo | ||||
from swh.loader.core.loader import DVCSLoader | |||||
from swh.model import hashutil | from swh.model import hashutil | ||||
from swh.model.model import Snapshot, SnapshotBranch, TargetType | from swh.model.model import Snapshot, SnapshotBranch, TargetType | ||||
from swh.storage.algos.origin import origin_get_latest_visit_status | from swh.storage.algos.origin import origin_get_latest_visit_status | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
from . import converters, utils | from . import converters, utils | ||||
from .base import BaseGitLoader | |||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
def _check_tag(tag): | def _check_tag(tag): | ||||
"""Copy-paste of dulwich.objects.Tag, minus the tagger and time checks, | """Copy-paste of dulwich.objects.Tag, minus the tagger and time checks, | ||||
which are too strict and error on old tags.""" | which are too strict and error on old tags.""" | ||||
# Copyright (C) 2007 James Westby <jw+debian@jameswestby.net> | # Copyright (C) 2007 James Westby <jw+debian@jameswestby.net> | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | for field, _ in dulwich.objects._parse_message(tag._chunked_text): | ||||
elif field == _TAG_HEADER and last != _TYPE_HEADER: | elif field == _TAG_HEADER and last != _TYPE_HEADER: | ||||
raise ObjectFormatException("unexpected tag name") | raise ObjectFormatException("unexpected tag name") | ||||
elif field == _TAGGER_HEADER and last != _TAG_HEADER: | elif field == _TAGGER_HEADER and last != _TAG_HEADER: | ||||
raise ObjectFormatException("unexpected tagger") | raise ObjectFormatException("unexpected tagger") | ||||
last = field | last = field | ||||
@deprecated(version="1.1", reason="Use `swh.loader.git.loader.GitLoader` instead") | @deprecated(version="1.1", reason="Use `swh.loader.git.loader.GitLoader` instead") | ||||
class GitLoaderFromDisk(DVCSLoader): | class GitLoaderFromDisk(BaseGitLoader): | ||||
"""Load a git repository from a directory.""" | """Load a git repository from a directory.""" | ||||
visit_type = "git" | visit_type = "git" | ||||
def __init__( | def __init__( | ||||
self, | self, | ||||
storage: StorageInterface, | storage: StorageInterface, | ||||
url: str, | url: str, | ||||
▲ Show 20 Lines • Show All 340 Lines • Show Last 20 Lines |