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

--include-only is not working #69

Closed
akfpnd opened this issue Apr 13, 2022 · 4 comments
Closed

--include-only is not working #69

akfpnd opened this issue Apr 13, 2022 · 4 comments

Comments

@akfpnd
Copy link

akfpnd commented Apr 13, 2022

🐛 Describe the bug

Running gradle task ./gradlew ktfmtPrecommit --include-only=path/to/file.kt is not including specified file to format.
Without --include-only everything works well

⚠️ Current behavior

command ./gradlew ktfmtPrecommit --include-only=path/to/file.kt is not including specified file to format

✅ Expected behavior

command ./gradlew ktfmtPrecommit --include-only=path/to/file.kt should include specified file to format

💣 Steps to reproduce

setup task in build.gradle file

tasks.register("ktfmtPrecommit", com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask) {
    source = project.fileTree(rootDir)
    include("**/*.kt")
}

do the change in any Kotlin file of the project then check the change by
git diff --name-only
then run command ./gradlew ktfmtPrecommit --include-only=path/to/file/from/git/diff/file.kt
gradle task will ignore specified file

I tried to use absolute path, tried to use --include-only="path/to/file.kt" nothing help

📷 Log

[ktfmt] Skipping for: /absolute/path/to/file.kt because: Not included inside --include-only
But is actually included!

📱 Tech info

Sytem: macOS 12.2.1
Android Studio: 2021.1.1 Patch 3
JVM version: 11
Gradle version: 7.1.3 (gradle-7.2-bin)
Library version: 0.8.0

@cortinico
Copy link
Owner

Thanks for the issue report @akfpnd

[ktfmt] Skipping for: /absolute/path/to/file.kt because: Not included inside --include-only
But is actually included!

I'm not able to reproduce this behavior. I just tried on the example project with the snippet you posted. It works fine for me. Are you sure you're not invoking any other task or you don't have any formatter that are running from your IDE?

@akfpnd
Copy link
Author

akfpnd commented Apr 25, 2022

Thanks for the issue report @akfpnd

[ktfmt] Skipping for: /absolute/path/to/file.kt because: Not included inside --include-only
But is actually included!

I'm not able to reproduce this behavior. I just tried on the example project with the snippet you posted. It works fine for me. Are you sure you're not invoking any other task or you don't have any formatter that are running from your IDE?

Could you please create separate project from scratch with Android Studio version I mentioned and setup gradle task in app module build.gradle

tasks.register("ktfmtPrecommit", com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask) {
    source = project.fileTree(rootDir)
    include("**/*.kt")
}

use id 'com.ncorti.ktfmt.gradle' version '0.8.0'

@cortinico
Copy link
Owner

I've added you to the repro here (it's private)
https://github.com/cortinico/reproducer-ktfmt-69/invitations

If you invoke

./gradlew ktfmtPrecommit --include-only=src/main/java/com/ncorti/kotlin/template/app/HelloWorld.kt

you'll see that the other file (MainActivity.kt) is not reformatted.

@cortinico
Copy link
Owner

@akfpnd where you able to test it?

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