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

Dirty tree when untracked files exist #55

Open
tueda opened this issue Nov 19, 2018 · 2 comments
Open

Dirty tree when untracked files exist #55

tueda opened this issue Nov 19, 2018 · 2 comments

Comments

@tueda
Copy link

tueda commented Nov 19, 2018

It seems that the definition of "dirty" in the plugin is a bit different from that of git describe: untracked files always make the working copy dirty. If this is intended behaviour, it would be nice to have an option to ignore untracked files.

Steps to reproduce the problem

git clone https://github.com/nemerosa/versioning.git
cd versioning
touch tmp
git status
git describe --always --tags --dirty
./gradlew versionDisplay

Expected behaviour

When git describe --dirty does not say the working tree is dirty, the plugin does not, either.

Actual behaviour

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        tmp

nothing added to commit but untracked files present (use "git add" to track)
$ git describe --always --tags --dirty
2.8.2-2-gc1d3ce2
$ ./gradlew versionDisplay
[version] scm        = git
[version] branch     = master
[version] branchType = master
[version] branchId   = master
[version] commit     = c1d3ce261c2449b792663db4e258d5790eb6e7f4
[version] full       = master-c1d3ce2-dirty
[version] base       =
[version] build      = c1d3ce2
[version] display    = master-c1d3ce2-dirty
[version] tag        =
[version] lastTag    = 2.8.2
[version] dirty      = true
@dcoraboeuf
Copy link
Contributor

Hi @tueda ,

Thanks for reporting this. As of the current version (2.8.2), any change in the status list is reporting as making the working copy considered dirty. It has been made this way to prevent having uncontrolled workspaces in a CI/CD environment.

However, if this suits any need, I could introduce a configuration parameter to ignore any unstaged change. I find this a bit dangerous since the current library I use (grgit) does not make any difference between unstaged changes and untracked changes.

@tueda
Copy link
Author

tueda commented Nov 20, 2018

Thank you for the answer.

I understand the change may introduce some problems to others, so it would be good to have a configuration parameter to ignore untracked files.

I am not sure how much other people want this behaviour: To me, it would be a nice occasion to reconsider my bad habit to have many untracked files (logs, test inputs...) in development, or I could just ignore the "dirty" flag in development, or maybe I could just write a script to use git describe for versioning by myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants