yaniksoeltzer / git_inspector

Inspect git repositories and report best practices violations.
MIT License
2 stars 1 forks source link

Improve check if HEAD is ahead of remote #30

Closed lschade closed 2 years ago

lschade commented 2 years ago

The check if my local branch is ahead of remote was really slow for me with a branch that is ~100 commits ahead of the remote branch (I merged some other branch into the branch). It was stuck in depth_search_commit.

Found a faster way to check if local is ahead of remote. https://stackoverflow.com/questions/17224134/check-status-of-local-python-relative-to-remote-with-gitpython No sure though if it does exactly the same as is_ancestors_of

yaniksoeltzer commented 2 years ago

Nice, thank you for noticing!

This improves performance by about 90% according to profile/reports/is_ahead_is_ancestor for searching through 1000 commits.

Elapsed time for 'is_ahead_of' 15.791177749633789 ms Elapsed time for 'is_ancestors_of' 174.46517944335938 ms