-
Notifications
You must be signed in to change notification settings - Fork 48
/
mk_core_addons
executable file
·108 lines (92 loc) · 3.17 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
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
("16.0", True, "16"),
("15.0", True, "15"),
("14.0", True, "14"),
# ("13.0", True, "13"),
# ("12.0", True, "12"),
# ("11.0", True, "11"),
# ('10.0', True, "10"),
# ('9.0', True, "9"),
# ('8.0', False, "8"),
]
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 / "setuptools_odoo" / 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("newsfragments").is_dir()
check_call("git", "checkout", "-B", "update-core-addon-lists", "origin/master")
check_call("git", "add", "setuptools_odoo")
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("newsfragments") / 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()