Skip to content

Commit f5a20c5

Browse files
committed
add pre-commit
1 parent 85c2d78 commit f5a20c5

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

.github/workflows/android.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
pre-commit run flutter-l10n-gen --all-files
4646
pre-commit run dart-format --all-files
4747
pre-commit run flutter-analyze --all-files
48+
pre-commit run spotless-apply --all-files
4849
flutter test
4950
working-directory: ./app
5051

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
pipx install pre-commit
6666
pre-commit run flutter-l10n-gen --all-files
6767
pre-commit run dart-format --all-files
68+
pre-commit run spotless-apply --all-files
6869
pre-commit run flutter-analyze --all-files
6970
flutter test
7071
working-directory: ./app

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ repos:
3232
language: script
3333
entry: update_android_strings.py
3434
require_serial: true
35+
- id: spotless-apply
36+
name: spotless-apply
37+
files: \.kt$
38+
language: script
39+
entry: spotless_apply.py
40+
require_serial: true
3541

3642
# Python
3743
- repo: local

spotless_apply.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright (C) 2023 Yubico.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import os
18+
import subprocess
19+
import sys
20+
21+
22+
def main():
23+
android_dir = os.path.join(os.path.dirname(__file__), "android")
24+
os.chdir(android_dir)
25+
gradlew = "./gradlew" if sys.platform != "win32" else "gradlew.bat"
26+
result = subprocess.run([gradlew, "spotlessApply"], check=True)
27+
sys.exit(result.returncode)
28+
29+
30+
if __name__ == "__main__":
31+
main()

0 commit comments

Comments
 (0)