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

spotless:check does not work with github worktree #2209

Closed
bodote opened this issue Jul 24, 2024 · 3 comments
Closed

spotless:check does not work with github worktree #2209

bodote opened this issue Jul 24, 2024 · 3 comments

Comments

@bodote
Copy link

bodote commented Jul 24, 2024

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

  • [ x] summary of problem
    a spring - boot project with maven and this pom.xml, on a git worktree com.diffplug.spotless:spotless-maven-plugin:2.43.0:check does not work at all with <ratchetFrom>branch-name</ratchetFrom>: Cannot find git repository in any parent directory

  • [ x] Gradle or Maven version: Apache Maven 3.8.6

  • [ x] spotless version : com.diffplug.spotless:spotless-maven-plugin:2.43.0:check

  • [x ] operating system and version: windows 11 including latest patches

  • [x ] copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible

<plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>${com.diffplug.spotless.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <ratchetFrom>origin/develop</ratchetFrom>
          <java>
            <palantirJavaFormat>
            </palantirJavaFormat>
            <importOrder>
              <order>,java|javax,\#
              </order>  
            </importOrder>
          </java>
        </configuration>
</plugin>
  • [ x] copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace

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
Copy link
Author

bodote commented Jul 24, 2024

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
Copy link
Author

bodote commented Jul 24, 2024

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

@nedtwigg
Copy link
Member

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

No branches or pull requests

2 participants