jacob-meacham / serverless-plugin-git-variables

:zap: Expose git variables to serverless
MIT License
87 stars 32 forks source link

Staged changes are not counted as 'dirty' by git:isDirty #70

Open mfogel opened 3 years ago

mfogel commented 3 years ago

Not sure if this is by design or not. But this is different than I was expecting, so if nothing else it might be worth mentioning this in the docs if it's by design.

I can see here that to compute isDirty the command being used is git diff --stat. That doesn't display staged changes. Ex:

$ git status
On branch master
nothing to commit, working tree clean
$ echo 'a change' > tmp
$ git diff --stat
 tmp | 1 +
 1 file changed, 1 insertion(+)
$ git add tmp
$ git diff --stat

I would love to be able to have a way to track if there are any changes between the working directory and the upstream repository state, staged or not. From my testing, it doesn't appear that any of the variables are sensitive to staged changes.

Perhaps this ticket isn't so much a bug with with git:isDirty but maybe more a feature request for a new variable git:hasStagedChanges. Either would work fine for my purposes.

Let me know what you think, and if there's the solution to this that you'd be open to merging and addresses my needs, I can write up a PR. Thanks a bunch for the plugin & happy holidays.

f00f commented 2 years ago

I second this. Any modifications should be considered dirty. Another case: