ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
187 stars 28 forks source link

Clean repo: marked as not clean #95

Closed tvschuer closed 6 years ago

tvschuer commented 6 years ago

Hi

I've been trying to get this plugin working for me, without success.

gradle:

plugins {
  id 'org.ajoberstar.reckon' version '0.8.0'
}

apply plugin: "java"
apply plugin: "jacoco"

reckon {
  scopeFromProp()
  stageFromProp('milestone', 'rc', 'final')
}
reckonTagCreate.dependsOn check

nothing to commit, working tree clean

- git repo has no tags

Could not evaluate onlyIf predicate for task ':reckonTagCreate'.

Cannot release a final or significant stage without a clean repo.

DEBUG logs show the git repo being detected correctly:

12:39:01.218 [DEBUG] [org.ajoberstar.reckon.core.GitInventorySupplier] Found HEAD commit AnyObjectId[0a4661c5281efbc1f3305d21c439a751ef2d9ada]
12:39:01.223 [DEBUG] [org.ajoberstar.reckon.core.GitInventorySupplier] Found tagged versions: []

As far as I can tell from the code, the git repo is marked as not clean. But I have no idea why. Even if I have everything pushed to origin, I still get the same output.

ajoberstar commented 6 years ago

This is probably a difference between JGit and C Git. If you add a little task to print out the status from Grgit, you should see what it thinks is modified:

task status {
  doLast {
    println grgit.status()
  }
}
tvschuer commented 6 years ago

Great, that was indeed the case!

I had a subfolder with its own git repo. Once I removed the subfolder, my cmd line git did mark the subfolder as removed. After committing the changes, I finally got my version working!

Thx!

ghost commented 5 years ago

Hi,

Im having the same issue when using reckon as part of a Jenkins pipeline. I have tried to add the task status as above, but that does not execute before the pipeline fails. When I run the status task locally the repo appears clean. I have tried to clean the repo using commits such as git clean and so on, but it is still failing. Would you be able to suggest what might fix this?

plugins {
    id 'org.ajoberstar.reckon' version '0.9.0'
}

apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.ajoberstar.reckon'
reckon {
    reckon.scopeFromProp()
    reckon.stageFromProp('dev', 'rc', 'final')
}
reckonTagCreate.dependsOn check

Thank you

sschuberth commented 5 years ago

In my case the cause was an untracked file in a submodule. While I have ignore = untracked in .gitmodules, that setting seems to be ignored by JGit and only honored by the regular Git command line client. So for me the solution was to clean up the working tree of the submodule with the regular Git command line client before executing reckon.

ghost commented 5 years ago

Thank you for your answer. I found the problem, there was a file being produced during the pipeline which I wasn't seeing - just had to add it to the .gitignore file and it worked great.

andysworkshop commented 4 years ago

jgit doesn't play well with cygwin and filemodes. It decided that my gradlew script had changed (filemode 0755 on cygwin) when it hadn't. I had to temporarily set core.filemode = false to run reckon in final mode.