mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
#1370 install git hooks on prebuild - update editorconfig from project codestyle settings
This commit is contained in:
parent
97d6932062
commit
a596e34ace
@ -1,20 +1,35 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
charset=utf-8
|
||||
end_of_line=lf
|
||||
insert_final_newline=true
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
# android studio / intellij specific, also in squares android style guide:
|
||||
# https://github.com/kiwix/kiwix-android/blob/master/docs/codestyle.md
|
||||
continuation_indent_size = 4
|
||||
|
||||
# windows command files need windows newline
|
||||
[*.{bat, cmd}]
|
||||
end_of_line = crlf
|
||||
[{*.sht,*.html,*.shtm,*.shtml,*.htm}]
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
[*.json]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[*.properties]
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
[.editorconfig]
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
[{*.pyw,*.py}]
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
[{*.yml,*.yaml}]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[{*.markdown,*.md,*.mkd}]
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
|
1
.idea/codeStyles/Project.xml
generated
1
.idea/codeStyles/Project.xml
generated
@ -9,6 +9,7 @@
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="LINE_SEPARATOR" value=" " />
|
||||
<option name="RIGHT_MARGIN" value="100" />
|
||||
<AndroidXmlCodeStyleSettings>
|
||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
||||
|
@ -457,6 +457,10 @@ play {
|
||||
resolutionStrategy = "fail"
|
||||
}
|
||||
|
||||
ktlint{
|
||||
android = true
|
||||
}
|
||||
|
||||
class TestDroidUpload extends TestServer {
|
||||
def buildNumber = System.getenv("TRAVIS_BUILD_NUMBER")
|
||||
def API_KEY = System.getenv("PUBLIC_TESTDROID_API_KEY")
|
||||
@ -497,3 +501,10 @@ class TestDroidUpload extends TestServer {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
apply from: "${rootDir}/team-props/git-hooks.gradle"
|
||||
afterEvaluate {
|
||||
android.applicationVariants.all { variant ->
|
||||
variant.preBuild.dependsOn(installGitHooks)
|
||||
}
|
||||
}
|
||||
|
26
team-props/git-hooks.gradle
Normal file
26
team-props/git-hooks.gradle
Normal file
@ -0,0 +1,26 @@
|
||||
static def isLinuxOrMacOs() {
|
||||
def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
|
||||
return osName.contains('linux') || osName.contains('mac os') || osName.contains('macos')
|
||||
}
|
||||
|
||||
task copyGitHooks(type: Copy) {
|
||||
description 'Copies the git hooks from team-props/git-hooks to the .git folder.'
|
||||
from("${rootDir}/team-props/git-hooks/") {
|
||||
include '**/*.sh'
|
||||
rename '(.*).sh', '$1'
|
||||
}
|
||||
into "${rootDir}/.git/hooks"
|
||||
}
|
||||
|
||||
task installGitHooks(type: Exec) {
|
||||
description 'Installs the pre-commit git hooks from team-props/git-hooks.'
|
||||
group 'git hooks'
|
||||
workingDir rootDir
|
||||
commandLine 'chmod'
|
||||
args '-R', '+x', '.git/hooks/'
|
||||
onlyIf { isLinuxOrMacOs() }
|
||||
dependsOn copyGitHooks
|
||||
doLast {
|
||||
logger.info('Git hook installed successfully.')
|
||||
}
|
||||
}
|
16
team-props/git-hooks/pre-commit.sh
Normal file
16
team-props/git-hooks/pre-commit.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Running formatter..."
|
||||
# Format code using KtLint, analyze with KtLint & Lint
|
||||
|
||||
./gradlew app:ktlintKiwixDebugFormat app:ktlintKiwixDebugCheck app:lintKiwixDebug --daemon
|
||||
|
||||
status=$?
|
||||
|
||||
if [ "$status" = 0 ] ; then
|
||||
echo "Static analysis found no problems."
|
||||
exit 0
|
||||
else
|
||||
echo 1>&2 "Static analysis found violations it could not fix."
|
||||
exit 1
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user