Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOI: use libgit/pygit2 for extracting "core" metadata? #257

Open
yarikoptic opened this issue Jun 21, 2022 · 0 comments
Open

FOI: use libgit/pygit2 for extracting "core" metadata? #257

yarikoptic opened this issue Jun 21, 2022 · 0 comments

Comments

@yarikoptic
Copy link
Member

ATM relies on git log -1 per file to extract information about each file. I wonder if it might be more efficient to implement it through "parsing" git log --stats thus going through the history until all files in the tree are covered. To avoid parsing of git log I thought that may be libgit could be used.

here is ipython history where I investigated how to go through history of commits and get to "stats" per each commit:
In [26]: history
import rich
import pygit2
repo = pygit2.Repository('.')
c = next(repo.walk(repo.head.target))
rich.inspect(c)
pygit2.diff(c.hex)
repo.diff(c.hex)
diffstat = repo.diff(c.hex)
rich.inspect(diffstat)
rich.inspect(diffstat.stats)
rich.inspect(diffstat.deltas)
rich.inspect(next(diffstat.deltas))
c.hex
rich.inspect(c)
diffstat = repo.diff(c.hex, c.parents[0].hex)
rich.inspect(next(diffstat.deltas))
rich.inspect(next(diffstat.stats))
rich.inspect(next(diffstat))
rich.inspect(diffstat)
rich.inspect(diffstat.stats)
rich.inspect(next(diffstat.stats))
rich.inspect(next(diffstat.deltas))
rich.inspect(next(diffstat.deltas).new_file)
history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant