Skip to content
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

Don't use recursive search in git manager, limit depth #64

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions terrarium/dl_gitmanager/dl_gitmanager/git_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from git.repo.base import Repo as GitRepo


MAX_HISTORY_DEPTH = 300


@attr.s
class GitManager:
git_repo: GitRepo = attr.ib(kw_only=True)
Expand Down Expand Up @@ -133,12 +136,8 @@ def get_list_diff_paths(self, commits: Collection[str], absolute: bool = False)
return self._collect_paths_from_diffs(diff_iterable=self._iter_list_diffs(commits=commits, absolute=absolute))

def get_all_ancestor_commits(self, commit: str) -> set[str]:
result: set[str] = {commit}
commit_obj = self.git_repo.commit(commit)
for parent in commit_obj.parents:
result |= {*self.get_all_ancestor_commits(parent.hexsha)}

return result
commits = [commit.hexsha for commit in self.git_repo.iter_commits(commit, max_count=MAX_HISTORY_DEPTH)]
return set(commits)

def get_missing_commits(self, base: str, head: str) -> set[str]:
return self.get_all_ancestor_commits(head) - self.get_all_ancestor_commits(base)
Expand Down
Loading