This repository was archived by the owner on Sep 11, 2020. It is now read-only.
repository.Log: add alternatives for commit traversal order #771
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The new option
Order
torepo.Log
allows customizing the order of commits.Specially because the current algorithm is not compatible with
git log
, the current algorithm use a stack (Depth-first Search?), whilegit log
uses timestamp of commit (committer time).So if we want to have the same order as
git log
we specifyOrder: git.LogOrderCommitterTime
.In the CommitterTime implementation, the stack of iterators is replaced with a BinaryHeap of commits (to avoid sorting the commits every time a commit is added). Also
start
property is removed (we start with a heap of length 1) so the code is simpler and cleaner.For the BinaryHeap we use this library: https://github.com/emirpasic/gods
The default behavior (commits order) of
repo.Log
is unchanged.