Skip to content

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

Merged

Conversation

oknozor
Copy link
Contributor

@oknozor oknozor commented Dec 6, 2021

This is a work in progress for #270

@oknozor oknozor force-pushed the feat/traversal-sort-by-committer-date branch 2 times, most recently from 51302dd to e9ff883 Compare December 6, 2021 15:24
Copy link
Member

@Byron Byron left a 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!

/// TODO:
pub fn committer(&mut self) -> Option<git_actor::SignatureRef<'_>> {
self.filter_map(Result::ok)
.find(|t| matches!(t, Token::Committer { .. }))
Copy link
Member

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.

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![];
Copy link
Member

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.

@oknozor oknozor force-pushed the feat/traversal-sort-by-committer-date branch 3 times, most recently from b45302a to 8187883 Compare December 7, 2021 10:04
@oknozor
Copy link
Contributor Author

oknozor commented Dec 7, 2021

I have updated according to your review, let me know if I still need to change anything.

Copy link
Member

@Byron Byron left a 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.

for token in commit_iter {
match token {
Ok(git_object::commit::ref_iter::Token::Parent { id }) => {
let mut vec = vec![];
Copy link
Member

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.


state
.parents_with_date
.sort_by(|(_, time), (_, other_time)| other_time.cmp(&time));
Copy link
Member

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.

@oknozor oknozor force-pushed the feat/traversal-sort-by-committer-date branch from 8187883 to 2ab315f Compare December 7, 2021 13:32
@oknozor
Copy link
Contributor Author

oknozor commented Dec 7, 2021

Just updated according to the latest review

@oknozor oknozor force-pushed the feat/traversal-sort-by-committer-date branch from 2ab315f to eb36a3d Compare December 7, 2021 13:36
@Byron Byron merged commit eb36a3d into GitoxideLabs:main Dec 8, 2021
@Byron
Copy link
Member

Byron commented Dec 8, 2021

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).

@oknozor
Copy link
Contributor Author

oknozor commented Dec 8, 2021

Definitely an enjoyable experience :). I'd be eager to work on something else !

@Byron
Copy link
Member

Byron commented Dec 8, 2021

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.

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

Successfully merging this pull request may close these issues.

2 participants