forked from acsone/manifestoo-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk_core_addons
executable file
·114 lines (98 loc) · 3.25 KB
/
mk_core_addons
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python3
import subprocess
import tempfile
import time
from pathlib import Path
from typing import Iterator
from manifestoo_core.addon import Addon, AddonNotFound
from manifestoo_core.odoo_series import OdooEdition
SERIES = [
# branch, enterprise, target
("17.0", True, None),
("16.0", True, None),
("15.0", True, None),
("14.0", True, None),
# ("13.0", True, None),
# ("12.0", True, None),
# ("11.0", True, None),
# ('10.0', True, None),
# ('9.0', True, None),
# ('8.0', False, None),
]
def _list_addons(addons_dir: Path, add_base: bool) -> Iterator[str]:
if add_base:
yield "base"
for addon_dir in addons_dir.iterdir():
try:
yield Addon.from_addon_dir(addon_dir, allow_not_installable=True).name
except AddonNotFound:
pass
def _write_addons_list(addons_dir: Path, suffix: str, add_base: bool) -> None:
list_path = (
Path(__file__).parent
/ "src"
/ "manifestoo_core"
/ "core_addons"
/ f"addons-{suffix}.txt"
)
with list_path.open("w") as f:
print("# generated on", time.asctime(), file=f)
for addon_name in sorted(_list_addons(addons_dir, add_base)):
print(addon_name, file=f)
def check_call(*cmd: str) -> None:
print(" ".join(cmd))
subprocess.check_call(cmd)
def check_output(*cmd: str) -> None:
print(" ".join(cmd))
return subprocess.check_output(cmd, text=True)
def main() -> None:
for branch, enterprise, target in SERIES:
with tempfile.TemporaryDirectory() as tmpdir:
check_call(
"git",
"clone",
"--depth=1",
"--branch",
branch,
"https://github.com/odoo/odoo",
tmpdir,
)
_write_addons_list(
Path(tmpdir) / "addons",
f"{target or branch}-{OdooEdition.CE.value}",
add_base=True,
)
if enterprise:
with tempfile.TemporaryDirectory() as tmpdir:
check_call(
"git",
"clone",
"--depth=1",
"--branch",
branch,
"[email protected]:odoo/enterprise",
tmpdir,
)
_write_addons_list(
Path(tmpdir),
f"{target or branch}-{OdooEdition.EE.value}",
add_base=False,
)
def pr():
assert Path("news").is_dir()
check_call("git", "checkout", "-B", "update-core-addon-lists", "origin/main")
check_call("git", "add", "src/manifestoo_core/core_addons")
check_call("git", "commit", "-m", "Update core addon lists")
check_call("git", "push", "-f", "origin")
output = check_output(
"gh", "pr", "create", "--title", "Update core addon lists", "--body", ""
)
pr = output.strip().rpartition("/")[-1]
news_path = Path("news") / f"{pr}.feature"
news_path.write_text("Update core addon lists.\n")
check_call("git", "add", str(news_path))
check_call("git", "commit", "--amend", "--no-edit")
check_call("git", "push", "-f")
if __name__ == "__main__":
main()
pr()