-
-
Notifications
You must be signed in to change notification settings - Fork 346
Feat/traversal sort by committer date #272
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
Feat/traversal sort by committer date #272
Conversation
51302dd
to
e9ff883
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite it being a WIP, it looks pretty complete to me, great work!
git-object/src/commit/ref_iter.rs
Outdated
/// TODO: | ||
pub fn committer(&mut self) -> Option<git_actor::SignatureRef<'_>> { | ||
self.filter_map(Result::ok) | ||
.find(|t| matches!(t, Token::Committer { .. })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With find_map(…)
one could reduce complexity.
git-traverse/src/commit.rs
Outdated
fn next_by_commit_date(&mut self) -> Option<Result<ObjectId, Error>> { | ||
let state = self.state.borrow_mut(); | ||
let res = state.next.pop_front(); | ||
let mut parents_with_date = vec![]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This array should be part of the state to avoid re-allocation each time one calls next()
.
With that in place, one would probably clear it here.
b45302a
to
8187883
Compare
I have updated according to your review, let me know if I still need to change anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This time around I took a closer look at the tests and thank you very much for cleaning them up before adding more.
git-traverse/src/commit.rs
Outdated
for token in commit_iter { | ||
match token { | ||
Ok(git_object::commit::ref_iter::Token::Parent { id }) => { | ||
let mut vec = vec![]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed this the first time around. Since another buffer is needed, it should probably be part of the state as well.
git-traverse/src/commit.rs
Outdated
|
||
state | ||
.parents_with_date | ||
.sort_by(|(_, time), (_, other_time)| other_time.cmp(&time)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would find time.cmp(&other_time).reverse()
clearer, the reverse()
makes a bit more obvious that this is going to be descending, as opposed to comparing the arguments in another order.
8187883
to
2ab315f
Compare
Just updated according to the latest review |
2ab315f
to
eb36a3d
Compare
Thanks a lot for contributing! I hope thus far the experience was enjoyable, and if so, I would be happy to help you find another task. (And if not, I'd be eager to learn so the experience can be improved, of course). |
Definitely an enjoyable experience :). I'd be eager to work on something else ! |
Awesome, thank you! Candidates for a similar amount of work, give or take, would be #251 or #11. If these aren't for you, you could give me a hint of what interests you, or peruse the collaboration board yourself for clues. |
This is a work in progress for #270