Skip to content

Commit

Permalink
GH-48: fix ktlint version retrieval (#51)
Browse files Browse the repository at this point in the history
Co-authored-by: Ghais Zaher <ghaiszaher@gmail.com>
  • Loading branch information
guil-camp-scacap and ghaiszaher committed Feb 29, 2024
1 parent 104bf9c commit 38262d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ git config --global --add safe.directory $GITHUB_WORKSPACE
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

ktlint_version=$(ktlint --version)
# In newer ktlint versions, the command `ktlint --version` returns "ktlint version x.y.z" and we need to remove "ktlint version " from the string
ktlint_version=${ktlint_version#"ktlint version "}

echo "ktlint version: $ktlint_version"

# ktlint_version > 0.49.1
if [ "$(printf '%s\n' "0.49.1" "$ktlint_version" | sort -V | head -n1)" = "0.49.1" ]; then
# --code-style is deprecated since 1.0.1 and .editorconfig needs to be used: https://pinterest.github.io/ktlint/latest/rules/code-styles/
# ktlint_version <= 1.0.0
if [ "$(printf '%s\n' "1.0.0" "$ktlint_version" | sort -V | tail -n1)" = "1.0.0" ]; then
if [ "$INPUT_ANDROID" = true ]; then
export ANDROID="--code-style=android_studio"
Expand Down

0 comments on commit 38262d0

Please sign in to comment.