Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/git/from_disk.py
Show First 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | def get_snapshot(self): | ||||
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 = {} | |||||
for ref, target in self.repo.refs.get_symrefs().items(): | for ref, target in self.repo.refs.get_symrefs().items(): | ||||
branches[ref] = SnapshotBranch(target=target, target_type=TargetType.ALIAS,) | branches[ref] = SnapshotBranch(target=target, target_type=TargetType.ALIAS) | ||||
if target not in branches: | |||||
# This handles the case where the pointer is "dangling". | |||||
# There's a chance that a further symbolic reference will | |||||
# override this default value, which is totally fine. | |||||
dangling_branches[target] = ref | |||||
branches[target] = None | |||||
utils.warn_dangling_branches( | |||||
branches, dangling_branches, self.log, self.origin_url | |||||
) | |||||
self.snapshot = Snapshot(branches=branches) | self.snapshot = Snapshot(branches=branches) | ||||
return self.snapshot | return self.snapshot | ||||
def get_fetch_history_result(self): | def get_fetch_history_result(self): | ||||
"""Return the data to store in fetch_history for the current loader""" | """Return the data to store in fetch_history for the current loader""" | ||||
return { | return { | ||||
"contents": len(self.type_to_ids[b"blob"]), | "contents": len(self.type_to_ids[b"blob"]), | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |