-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.82 KB
/
Copy pathheader.yml
File metadata and controls
87 lines (74 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Kotlin Header
on: workflow_dispatch
jobs:
kotlin-header:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Add or Update Kotlin headers
run: |
python3 <<'PY'
from pathlib import Path
SOLSTICE_HEADER = """/*
* Solstice (2026)
* © Stark — github.com/urstark
*
* Based on ArchiveTune (2026)
* © Rukamori — github.com/rukamori
*
* GPL-3.0 License | Contributors: see git history
* Do not remove or alter this notice. - Per GPL-3.0 Section 4 & Section 5
*/
"""
SOLSTICE_ONLY_HEADER = """/*
* Solstice (2026)
* © Stark — github.com/urstark
*
* GPL-3.0 License | Contributors: see git history
* Do not remove or alter this notice. - Per GPL-3.0 Section 4 & Section 5
*/
"""
total_updated = 0
for path in Path(".").rglob("*.kt"):
if ".git" in path.parts or "build" in path.parts:
continue
try:
content = path.read_text(encoding="utf-8")
except UnicodeDecodeError:
continue
has_rukamori = False
has_stark = False
text_without_header = content
while text_without_header.startswith("/*"):
end = text_without_header.find("*/")
if end == -1:
break
header = text_without_header[:end + 2]
if "GPL-3.0 License" in header:
if "© Rukamori" in header:
has_rukamori = True
if "© Stark" in header:
has_stark = True
text_without_header = text_without_header[end + 2:].lstrip("\r\n")
else:
break
# Now prepend the new header
new_content = content
if has_rukamori or has_stark:
if has_rukamori:
new_content = SOLSTICE_HEADER + text_without_header
else:
new_content = SOLSTICE_ONLY_HEADER + text_without_header
else:
new_content = SOLSTICE_ONLY_HEADER + text_without_header
if content != new_content:
path.write_text(new_content, encoding="utf-8")
total_updated += 1
print(f"{path}: updated header")
print(f"Updated {total_updated} Kotlin header(s).")
PY
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: Update Kotlin Headers