serverless-plugin-git-variables icon indicating copy to clipboard operation
serverless-plugin-git-variables copied to clipboard

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

Open mfogel opened this issue 4 years ago • 1 comments

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.

mfogel avatar Dec 25 '20 17:12 mfogel

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

  • Have a clean repo
  • echo $bogus_config > .env.prod
  • Seems like untracked files do not show up in git diff --stat

f00f avatar May 06 '22 07:05 f00f