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

Update index before diff-index to check if there are changes #17

Merged
merged 1 commit into from
Sep 12, 2024
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
13 changes: 11 additions & 2 deletions bin/main
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ _GIT = (


def _has_changes(*, src_repo: str) -> bool:
cmd = (
# Without updating the index, diff-index may say that there
# are changes when there are not.
# For example, if a file has been written to but its contents
# have not changed.
update_index_cmd = (
*_GIT, '-C', src_repo, 'update-index', '--refresh',
)
subprocess.call(update_index_cmd)

diff_index_cmd = (
*_GIT, '-C', src_repo, 'diff-index',
'--quiet', '--no-ext-diff', 'HEAD', '--',
)
return subprocess.call(cmd) == 1
return subprocess.call(diff_index_cmd) == 1


def _rev_parse(*, repo: str, ref: str) -> str:
Expand Down
Loading