Skip to content

git diff deleted_file returns True when the file is not being deleted #1597

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

Closed
virvirlopez opened this issue May 24, 2023 · 0 comments
Closed

Comments

@virvirlopez
Copy link

virvirlopez commented May 24, 2023

Git diff deleted_file is returning:

  • False when the file is deleted.
  • True when the file is not being deleted.

The code:

repo = Repo(".")
diff_list = repo.commit("HEAD").diff("HEAD~1")

for diff_file in diff_list:
    file_path = diff_file.b_path

    # this means that the file has been deleted.
    if not diff_file.deleted_file:
        logger.info(f"The usecase in the file path {file_path} has been deleted.")
        continue

The requirements:

GitPython==3.1.31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant