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

Integration with pre-commit(.com) #332

Open
1Mark opened this issue May 31, 2023 · 4 comments
Open

Integration with pre-commit(.com) #332

1Mark opened this issue May 31, 2023 · 4 comments

Comments

@1Mark
Copy link

1Mark commented May 31, 2023

Hi there,

I was trying to write a simple
pre-commit-config.yaml like so

repos:
- repo: local
  hooks:
  - id: formatKotlin
    name: formatting files using kolinter
    entry: ./gradlew formatKotlin
    language: system

However, since pre-commit.com passes the changed files to ./gradlew formatKotlin it fails with

Task src/blah/file.kt not found in root project 'blahblah'.

I have seen #207 and #155 but I was still unsure how to resolve. I considered using https://github.com/macisamuele/language-formatters-pre-commit-hooks/blob/f5149294026e063cf1b9e28670e43ee5c624d2f9/.pre-commit-hooks.yaml#L25-L30 but was worried that klint would fall out of sync with kolinter.

Please advise

@1Mark 1Mark changed the title Integration with pre-commit.org Integration with pre-commit(.com) May 31, 2023
@jeremymailen
Copy link
Owner

Generally I think the ktlint cli tool is better suited to running git hooks since it's designed to target a list of files rather than sourceSets which are out of date to Gradle.

I understand some people have concerns that if they have both ktlint and the gradle plugin in their dev environment they will drift to different versions. Would it makes sense if kotlinter-gradle just packaged the CLI Main class within the plugin and people could write a JavaExec task to invoke it?

@1Mark
Copy link
Author

1Mark commented Jun 4, 2023

Works for me.

@1Mark
Copy link
Author

1Mark commented Sep 7, 2023

Any update on this pls?

@jeremymailen
Copy link
Owner

Not yet I'm afraid, but open to contributions.

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