diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a38dfc6f29..fcb75e56aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,8 +75,18 @@ jobs: with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./diktat-cli/build/diktat-cli-${{ github.ref }} - asset_name: diktat-cli-${{ github.ref }} + asset_name: diktat asset_content_type: application/zip + - name: Upload Diktat CLI for Windows to GitHub release + id: upload-release-asset-cli-win + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./diktat-cli/src/main/script/diktat.cmd + asset_name: diktat.cmd + asset_content_type: application/octet-stream - name: Upload Diktat ruleset for KtLint to GitHub release id: upload-release-asset-ruleset uses: actions/upload-release-asset@v1 diff --git a/diktat-cli/build.gradle.kts b/diktat-cli/build.gradle.kts index 2c916a577f..642b3da448 100644 --- a/diktat-cli/build.gradle.kts +++ b/diktat-cli/build.gradle.kts @@ -72,7 +72,7 @@ tasks.register("shadowExecutableJar") { group = "Distribution" dependsOn(tasks.shadowJar) - val scriptFile = project.file("src/main/script/diktat.sh") + val scriptFile = project.file("src/main/script/header-diktat.sh") val shadowJarFile = tasks.shadowJar .get() .outputs diff --git a/diktat-cli/src/main/script/diktat.cmd b/diktat-cli/src/main/script/diktat.cmd new file mode 100644 index 0000000000..4dd7b9ccb0 --- /dev/null +++ b/diktat-cli/src/main/script/diktat.cmd @@ -0,0 +1,19 @@ +@echo off + +rem +rem diKTat command-line client for Windows +rem +rem Uses Git Bash, so requires Git to be installed. +rem + +set "git_install_location=%ProgramFiles%\Git" +set "git_url=https://github.com/git-for-windows/git/releases/latest" + +if exist "%git_install_location%" ( + setlocal + set "PATH=%git_install_location%\usr\bin;%PATH%" + for /f "usebackq tokens=*" %%p in (`cygpath "%~dpn0"`) do bash --noprofile --norc %%p %* +) else ( + echo Expecting Git for Windows at %git_install_location%; please install it from %git_url% + start %git_url% +) diff --git a/diktat-cli/src/main/script/diktat.sh b/diktat-cli/src/main/script/header-diktat.sh similarity index 100% rename from diktat-cli/src/main/script/diktat.sh rename to diktat-cli/src/main/script/header-diktat.sh diff --git a/diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatReporterFactoryImpl.kt b/diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatReporterFactoryImpl.kt index 16d2b9a9c2..c572668674 100644 --- a/diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatReporterFactoryImpl.kt +++ b/diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatReporterFactoryImpl.kt @@ -42,13 +42,8 @@ class DiktatReporterFactoryImpl : DiktatReporterFactory { } val opts = if (args is PlainDiktatReporterCreationArguments) { buildMap { - args.colorName?.let { - put("color", true) - put("color_name", it) - } ?: run { - put("color", false) - put("color_name", Color.DARK_GRAY) - } + put("color", args.colorName?.let { true } ?: false) + put("color_name", args.colorName ?: Color.DARK_GRAY) args.groupByFile?.let { put("group_by_file", it) } }.mapValues { it.value.toString() } } else if (args.reporterType == DiktatReporterType.PLAIN) {