mtkennerly / dunamai

Dynamic versioning library and CLI
https://dunamai.readthedocs.io/en/latest
MIT License
312 stars 24 forks source link

Detect untracked files as dirty (for git) #4

Closed jpc4242 closed 3 years ago

jpc4242 commented 3 years ago

Hi Mathhew , first of all, thanks for for dunamai and poetry_dynamic_versioning.

One question: When working with git, have you considered detecting if untracked files are present? Or are you purposely ignoring them?

I think it would be as easy as adding this to __init__.py

       code, msg = _run_cmd("git describe --always --dirty")
       dirty = msg.endswith("-dirty")
       # above lines already in your code, just for context
       if not dirty:
         code, msg = _run_cmd("git status --porcelain=v1")
         if msg.strip() == "" #strip probably never needed but just in case
           dirty = True
       # end of my suggested changes

I can fork and create a pull request if you prefer

mtkennerly commented 3 years ago

I think that would make sense to add. I don't remember why I didn't do something like that to begin with 😅 A PR would be great if you're interested, but I don't mind taking care of it either.