Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/git/from_disk.py
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | def get_releases(self): | ||||
self.repo[hashutil.hash_to_bytehex(oid)], log=self.log | self.repo[hashutil.hash_to_bytehex(oid)], log=self.log | ||||
) | ) | ||||
def get_snapshot(self): | def get_snapshot(self): | ||||
"""Turn the list of branches into a snapshot to load""" | """Turn the list of branches into a snapshot to load""" | ||||
branches: Dict[bytes, Optional[SnapshotBranch]] = {} | branches: Dict[bytes, Optional[SnapshotBranch]] = {} | ||||
for ref, target in self.repo.refs.as_dict().items(): | for ref, target in self.repo.refs.as_dict().items(): | ||||
if utils.ignore_branch_name(ref): | |||||
continue | |||||
obj = self.get_object(target) | obj = self.get_object(target) | ||||
if obj: | if obj: | ||||
target_type = converters.DULWICH_TARGET_TYPES[obj.type_name] | target_type = converters.DULWICH_TARGET_TYPES[obj.type_name] | ||||
branches[ref] = SnapshotBranch( | branches[ref] = SnapshotBranch( | ||||
target=hashutil.bytehex_to_hash(target), target_type=target_type, | target=hashutil.bytehex_to_hash(target), target_type=target_type, | ||||
) | ) | ||||
else: | else: | ||||
branches[ref] = None | branches[ref] = None | ||||
dangling_branches = {} | dangling_branches = {} | ||||
for ref, target in self.repo.refs.get_symrefs().items(): | for ref, target in self.repo.refs.get_symrefs().items(): | ||||
if utils.ignore_branch_name(ref): | |||||
continue | |||||
branches[ref] = SnapshotBranch(target=target, target_type=TargetType.ALIAS) | branches[ref] = SnapshotBranch(target=target, target_type=TargetType.ALIAS) | ||||
if target not in branches: | if target not in branches: | ||||
# This handles the case where the pointer is "dangling". | # This handles the case where the pointer is "dangling". | ||||
# There's a chance that a further symbolic reference will | # There's a chance that a further symbolic reference will | ||||
# override this default value, which is totally fine. | # override this default value, which is totally fine. | ||||
dangling_branches[target] = ref | dangling_branches[target] = ref | ||||
branches[target] = None | branches[target] = None | ||||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |