-
Notifications
You must be signed in to change notification settings - Fork 538
Filtering Commits Based on Files They Interact With #562
Comments
Hey @zachgersh, You are correct that there is currently no explicit support in the library for this, as there is with the standard git tooling. One way to implement something like this is shown below. No promises that this is a particularly fast algorithm. The basic idea is that we keep track of the version of the path at each commit (by remember the hash of the path contents). We can compare the path hashes between a commit and each of its parents to detect if the path has changed. I believe the standard git tooling would also include a log entry if either the file permissions for the path changed or the file contents changed. This code example does not support changes to file permissions of the path, so that would be an exercise for the reader. 😛
|
@mcuadros has there been any discussion about adding this type of functionality to the library? Do we want to label this issue as "enhancement"? |
@orirawlings - thanks for writing this up, I am going to give it a go. It would actually seem that Somewhat related to #343 - which was looking to pattern match on a partial path. Git log totally supports this behavior though it wasn't clear in the example above :D |
This code works perfectly btw. Really appreciate this @orirawlings - hugely helped me with a project I am working on. |
I'll add the enhancement label on this one. I think it might be feasible to extend some of the example code and work it into the library API. |
Since Something like
This can be also used to exclude some files, by giving |
I don't think it is. Or even maybe |
Should be safe to close since this PR is merged and |
Hey All,
I am essentially trying to replicate this
git log
command in golang and can get most of the way there. Command looks something like this:Git understands when I say this I mean only the commits that interacted with the
some-magical-path
and not any others. With the library I only seem to be able to iterate over all of the commits and then ask about their files. When interrogating a commit for its files it gives me all of the files referenced by the tree (even when they have not been interacted with). Does anyone have a good idea how this would be accomplished?Cheers!
The text was updated successfully, but these errors were encountered: