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

[BUG] miniver does not detect "dirty" state when all changes are staged #61

Closed
jsacrist opened this issue Apr 16, 2023 · 0 comments · Fixed by #62
Closed

[BUG] miniver does not detect "dirty" state when all changes are staged #61

jsacrist opened this issue Apr 16, 2023 · 0 comments · Fixed by #62

Comments

@jsacrist
Copy link
Contributor

Context

As of the current version (0.7.0), miniver has the following mechanism for detecting a "dirty" state on a tree:

  1. Run in a sub-process: git", "describe", "--long", "--always --first-parent or git", "describe", "--long", "--always (if the first one fails). If both these commands fail, don't go any further see code
  2. Assuming one of the commands in the previous step succeeded, take the plaintext output, sanitize and extract values for 3 fields: release, dev, git (see code)
  3. Figure out the "labels" (such as the "dirty" label) needed to construct a valid PEP440-complient format (see code)

BUG / Explanation

This last step is not properly detecting when a tree is "dirty" in two cases I have observed:

  1. When one ore more files have been modified and all modifications have been staged (i.e. when you're ready to commit changes but haven't yet committed them)
  2. When a completely new file has been added to the tree

This undesired behaviour happens because the current approach uses git diff --quiet which returns a value of 1 when a tracked file in the last commit has been modified

Proposal

A better mechanism would leverage the output of git describe --dirty by looking at the ending of the string (which has the form v0.0.2rc6-1-g409e8dd-dirty) in order to determine if the tree is dirty or not

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 a pull request may close this issue.

1 participant