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

Pre Commit Hook Error #562

Closed
PaulWoitaschek opened this issue Jan 5, 2022 · 5 comments · Fixed by #564
Closed

Pre Commit Hook Error #562

PaulWoitaschek opened this issue Jan 5, 2022 · 5 comments · Fixed by #564

Comments

@PaulWoitaschek
Copy link

PaulWoitaschek commented Jan 5, 2022

When running the precommit hook it always fails with the message:

.git/hooks/pre-commit: line 22: =0: command not found

This is probably because of this line:

$gradleCommandExitCode=$?

Imo the leading $ should be removed.

This also has the very bad sideffect that the old stash is not applied and the code that wasn't staged is lost.

Tested on macos, Ktlint 10.2.1

@jmbarroso
Copy link

Found the same problem. Edited manually the file and it worked as expected

@paulohc
Copy link

paulohc commented Jan 6, 2022

I am getting the same error. I didn't find this line after applying the plugin to the project.
Is there any workaround to make the pre-commit hook work fine?

@jmbarroso
Copy link

@paulohc, after installing the pre-commit, it should be available in .git/hooks/pre-commit. Line 22 should look like $gradleCommandExitCode=$? . The workaround is to change it to gradleCommandExitCode=$?

@paulohc
Copy link

paulohc commented Jan 6, 2022

I found the line here. Now the hook is working. Thank you very much @jmbarroso !

@G00fY2
Copy link

G00fY2 commented Jan 24, 2022

I created PR #568 to address this. Duplicate of #564 😄

JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Feb 7, 2022
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Feb 7, 2022
rbleuse added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 11, 2022
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 14, 2022
* master:
  testAnnotations use version_current and upload memory dump
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 14, 2022
* master:
  Also grab the replay_pid log file on crash
  Log test events during test execution
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 14, 2022
* master:
  Fix formatting of build file
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 14, 2022
* master:
  Disable the Gradle Daemon on Windows tests
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 14, 2022
* master:
  Fix failing test from Daemon disable
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 14, 2022
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 18, 2022
* master:
  Fix "Unknown command-line option '--no-daemon'" error
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 21, 2022
* master:
  Remove windows tests from critical path
JLLeitschuh added a commit to rbleuse/ktlint-gradle that referenced this issue Mar 22, 2022
* master:
  Fix `fail-fast` declaration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants