Skip to content

Instantly share code, notes, and snippets.

@dbnicholson
Last active September 21, 2018 19:48
Show Gist options
  • Save dbnicholson/cdf39c56fd7a1c08eebe4c74f658c427 to your computer and use it in GitHub Desktop.
Save dbnicholson/cdf39c56fd7a1c08eebe4c74f658c427 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3 -u
from argparse import ArgumentParser
from gi import require_version
require_version('OSTree', '1.0')
from gi.repository import GLib, Gio, OSTree
import sys
aparser = ArgumentParser(
description='Find commits that have missing objects'
)
aparser.add_argument('--repo', help='repository path')
args = aparser.parse_args()
if args.repo is None:
repo = OSTree.Repo.new_default()
else:
repo_file = Gio.File.new_for_path(args.repo)
repo = OSTree.Repo.new(repo_file)
repo.open(None)
_, all_objects = repo.list_objects(OSTree.RepoListObjectsFlags.ALL, None)
for objname in all_objects:
checksum, objtype = OSTree.object_name_deserialize(objname)
if objtype != OSTree.ObjectType.COMMIT:
continue
try:
repo.traverse_commit(checksum, 0)
except GLib.Error as err:
if not err.matches(Gio.io_error_quark(),
Gio.IOErrorEnum.NOT_FOUND):
raise
print('Commit', checksum, 'failed:', err.message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment