diffplug / spotless

Keep your code spotless
Apache License 2.0
4.51k stars 455 forks source link

spotless:check does not work with github worktree #2209

Closed bodote closed 2 months ago

bodote commented 2 months ago

If you are submitting a bug, please include the following:

If you're just submitting a feature request or question, no need for the above.


git worktree add ../myproject-worktree-test  test/worktree-test

"C:\Program Files\Java\jdk17\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\tf80206\dev\clcp-be-pact_test -Djansi.passthrough=true "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA UE\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA UE\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA UE\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA UE\lib\idea_rt.jar=50872:C:\Program Files\JetBrains\IntelliJ IDEA UE\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA UE\plugins\maven\lib\maven3\boot\plexus-classworlds-2.7.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA UE\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version=2024.1.3 com.diffplug.spotless:spotless-maven-plugin:2.43.0:check

[INFO] ---------------------< bodo.clcp:myproject>---------------------
[INFO] Building myproject 0.0.223-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- spotless:2.43.0:check (default-cli) @ myproject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.028 s
[INFO] Finished at: 2024-07-24T08:12:15+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.43.0:check (default-cli) on project myproject : 
Execution default-cli of goal com.diffplug.spotless:spotless-maven-plugin:2.43.0:check failed: 
Cannot find git repository in any parent directory -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
bodote commented 2 months ago

I can reproduce the error also on MacOS. You can use this project to reproduce the problem:

git@github.com:bodote/mongo_change_stream.git (ignore that this project was actually about mongo_change_streams)

Once you have this project on your local machine:

mvn spotless:apply
git branch feature1
git worktree add ../feature1-worktree feature1
cd ../feature1-worktree
mvn spotless:apply
bodote commented 2 months ago

Workaround: don't use <ratchetFrom>...</ratchetFrom>

nedtwigg commented 2 months ago