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

Finding file paths affected by a commit #277

Open
eddiesholl opened this issue Mar 27, 2022 · 1 comment
Open

Finding file paths affected by a commit #277

eddiesholl opened this issue Mar 27, 2022 · 1 comment

Comments

@eddiesholl
Copy link

I've been trying to work out how to filter file paths affected by a specific commit. Or in other words, show me the files modified by a particular commit, or maybe all the files affected when a particular merge happens.

As far as I can tell, each commit hash in the files table has a record for every file in the tree at that time. I'm struggling to see where in the data model the file paths changed in each commit might be available.

Thanks!

@patrickdevivo
Copy link
Contributor

Hi @eddiesholl - I think what you're asking about can be achieved using the stats table-valued function. For instance:

SELECT * FROM commits, stats('', commits.hash)

Will return the stats (additions/deletions) for every file modified in a commit. In this case, since you mainly are looking for the files modified, the stats name is a bit misleading, but the query will give a list of the file paths modified by the commit (and you can ignore the "stats").

SELECT * FROM stats('', 'some-commit-sha')

Will return results only for a known commit hash.

SELECT * FROM commits, stats('', commits.hash)
WHERE commits.parents > 1

Will return stats only for merge commits (a commit with more than 1 parent).

Hope that helps!

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

2 participants