Skip to content

Commit 29d3dd8

Browse files
fix: super-linter (#6)
* fix: super-linter - .env and javascript_standard * fix: super-linter - pre-commit * fix: installGitHook gradle task
1 parent 8f62280 commit 29d3dd8

File tree

9 files changed

+67
-59
lines changed

9 files changed

+67
-59
lines changed

.env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# It will force the user to add an e-mail for this project, before committing.
2-
COMMIT_MAIL=[email protected]
2+
COMMIT_MAIL=[email protected]

.github/workflows/linter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ jobs:
3232
VALIDATE_CHECKOV: false
3333
VALIDATE_JSCPD: false
3434
VALIDATE_KOTLIN: false
35+
VALIDATE_JAVASCRIPT_PRETTIER: false
3536
VALIDATE_JSON_PRETTIER: false
3637
VALIDATE_MARKDOWN_PRETTIER: false
3738
VALIDATE_YAML_PRETTIER: false
39+
VALIDATE_BASH_EXEC: false
3840

3941
- name: Set up JDK
4042
uses: actions/[email protected]

build.gradle.kts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ plugins {
44
alias(libs.plugins.jetbrains.kotlin.android) apply false
55
alias(libs.plugins.compose.compiler) apply false
66
}
7-
task<Copy>("installGitHook") {
7+
task("installGitHook") {
88
delete(".git/hooks/pre-commit")
9+
copy {
10+
filePermissions {
11+
user {
12+
read = true
13+
execute = true
14+
}
15+
other.execute = false
16+
}
917

10-
fileMode = 0x777
11-
from(File(rootProject.rootDir, "scripts/pre-commit"))
12-
into(File(rootProject.rootDir, ".git/hooks"))
18+
from("${rootProject.rootDir}/scripts/pre-commit")
19+
into("${rootProject.rootDir}/.git/hooks")
20+
}
1321
}
1422

15-
tasks.getByPath(":app:preBuild").dependsOn(":installGitHook")
23+
tasks.getByPath("buildEnvironment").dependsOn(":installGitHook")

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[versions]
2-
agp = "8.7.1"
2+
agp = "8.7.2"
33
kotlin = "2.0.21"
4-
coreKtx = "1.13.1"
4+
coreKtx = "1.15.0"
55
junit = "4.13.2"
66
junitVersion = "1.2.1"
77
espressoCore = "3.6.1"
88
appcompat = "1.7.0"
9-
composeBom = "2024.10.00"
9+
composeBom = "2024.10.01"
1010
material = "1.12.0"
1111

1212
[libraries]

scripts/check-commit-mail.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

scripts/check-commit-mail.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env node
2+
import * as ChildProcess from 'node:child_process'
3+
import * as process from 'node:process'
4+
5+
const checkCommitMail = () => {
6+
console.warn('Check COMMIT_MAIL')
7+
if (!process.env.COMMIT_MAIL) {
8+
console.error(
9+
"No COMMIT_MAIL set in .env, please take a look at the file '.env.template'"
10+
)
11+
process.exit(1)
12+
}
13+
14+
const currentMail = ChildProcess.execSync('git config user.email')
15+
.toString()
16+
.trim()
17+
.toLowerCase()
18+
const commitMail = process.env.COMMIT_MAIL.trim().toLowerCase()
19+
if (currentMail !== commitMail) {
20+
console.error(`currentMail: ${currentMail} !== initialMail: ${commitMail}`)
21+
console.error(
22+
`Please set your commit user mail for this project like: 'git config user.email '${commitMail}'`
23+
)
24+
process.exit(1)
25+
}
26+
}
27+
28+
checkCommitMail()

scripts/pre-commit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ git stash -q --keep-index
55
echo "Running git pre-commit hook"
66

77
./gradlew lint &&
8-
node --env-file=.env ./scripts/check-commit-mail.js &&
9-
node ./scripts/validate-branch-name.js
8+
node --env-file=.env ./scripts/check-commit-mail.mjs &&
9+
node ./scripts/validate-branch-name.mjs
1010

1111
RESULT=$?
1212

1313
git stash pop -q
1414

1515
# return 1 exit code if running checks fails
1616
[ $RESULT -ne 0 ] && exit 1
17-
exit 0
17+
exit 0

scripts/validate-branch-name.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

scripts/validate-branch-name.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env node
2+
import * as ChildProcess from 'node:child_process'
3+
import * as process from 'node:process'
4+
5+
const checkValidBranchName = () => {
6+
console.warn('Check VALID_BRANCH_NAME')
7+
8+
const currentBranchName = ChildProcess.execSync('git symbolic-ref --short HEAD')
9+
.toString()
10+
.trim()
11+
12+
const regex = /^(feature|fix|hotfix|release)\/.+$/g
13+
const found = currentBranchName.match(regex) !== null
14+
process.exit(found ? 0 : 1)
15+
}
16+
17+
checkValidBranchName()

0 commit comments

Comments
 (0)