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

Add an option to skip non-existent files in diff-related dl-git commands #38

Closed
wants to merge 1 commit into from

Conversation

KonstantAnxiety
Copy link
Contributor

No description provided.

@github-actions
Copy link

github-actions bot commented Oct 24, 2023

Test Results

5 tests   5 ✔️  0s ⏱️
1 suites  0 💤
1 files    0

Results for commit ab308f3.

♻️ This comment has been updated with latest results.

@KonstantAnxiety KonstantAnxiety marked this pull request as ready for review October 25, 2023 09:04
result.add(str(base_path / diff_item.a_path))
if diff_item.b_path:
result.add(str(base_path / diff_item.b_path))
for diff_path in (diff_item.a_path, diff_item.b_path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to do this in a separate cycle - first we collect and deduplicate all the paths, and then we apply filters.
It would be a bit more flexible and would save some CPU time if there is a lot of commits for the same paths.

result: set[str] = set()
for base_path, diff_item in diff_iterable:
if diff_item.a_path:
result.add(str(base_path / diff_item.a_path))
if diff_item.b_path:
result.add(str(base_path / diff_item.b_path))

if without_deleted:
result = {path for path in result if os.path.exists(path)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to check for existence via the git file tree for the head state because it will not necessarily be the same as the real FS (i.e. the current repository state might (and probably will) be different from head).

@KonstantAnxiety KonstantAnxiety deleted the gitmgr-diff-wo-deleted branch February 7, 2024 09:20
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