-
I found the issue at korandoru/hawkeye#150. But in case of you'd like to discuss here, I repost the question: I'd like to get the file in a repository with its created and last modified time. I suppose if we can list commits at a path, this should be implemented. This is possible for But it's a bit challenging to select the proper gix features and methods to implement this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Here is how a library use JGit for achieving this: private RevWalk getGitRevWalk(String repoRelativePath, boolean oldestCommitsFirst) throws IOException {
DiffConfig diffConfig = repository.getConfig().get(DiffConfig.KEY);
RevWalk walk = new RevWalk(repository);
walk.markStart(walk.parseCommit(repository.resolve(Constants.HEAD)));
walk.setTreeFilter(AndTreeFilter.create(Arrays.asList(
PathFilter.create(repoRelativePath),
FollowFilter.create(repoRelativePath, diffConfig), // Allows us to follow files as they move or are renamed
TreeFilter.ANY_DIFF)
));
walk.setRevFilter(MaxCountRevFilter.create(checkCommitsCount));
walk.setRetainBody(false);
if (oldestCommitsFirst) {
walk.sort(RevSort.REVERSE);
}
return walk;
} |
Beta Was this translation helpful? Give feedback.
-
There is nothing to facilitate this at the moment, but I hope one day that will change. Meanwhile, there is example code that diffs the tree of each commit with the previous one, if it's not a merge-commit, and records all obtained changes in a sqlite database. From there it's easy to query, such as with:
The same code could be used to do the same computation on the fly. It stays expensive though, there is nothing one can do about it except for attempting to not do any unnecessary computation. |
Beta Was this translation helpful? Give feedback.
Thank you! I implement it in https://github.com/korandoru/hawkeye/pull/150/files/e9bac68f659b60d4879d77b9f998e70df1ae8165..7de3c3566f4b3176e712318bd57af11349b63e83
Welcome to give a review and see if we can improve the code further.