Skip to content

Commit c00e27d

Browse files
committed
[ADD] merge bot: towncrier support
1 parent 4e653ae commit c00e27d

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

Diff for: Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ RUN set -x \
2121
RUN set -x \
2222
&& python3 -m venv /ocamt \
2323
&& /ocamt/bin/pip install wheel
24+
# TODO update sha to get oca-towncrier
2425
RUN set -x \
2526
&& /ocamt/bin/pip install -e git+https://github.com/OCA/maintainer-tools@5dbc86310d80229ef0f2f5851933414be719308b#egg=oca-maintainers-tools \
2627
&& ln -s /ocamt/bin/oca-gen-addons-table /usr/local/bin/ \
2728
&& ln -s /ocamt/bin/oca-gen-addon-readme /usr/local/bin/ \
28-
&& ln -s /ocamt/bin/oca-gen-addon-icon /usr/local/bin/
29+
&& ln -s /ocamt/bin/oca-gen-addon-icon /usr/local/bin/ \
30+
&& ln -s /ocamt/bin/oca-towncrier /usr/local/bin/
2931
RUN set -x \
3032
&& /ocamt/bin/pip install setuptools-odoo>=2.5.0 \
3133
&& ln -s /ocamt/bin/setuptools-odoo-make-default /usr/local/bin/

Diff for: README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ can be used to ask the bot to the following:
7474
* run the main branch operations (see above) on it
7575
* optionally bump the version number of the addons modified by the PR
7676
* merge when tests on the rebased branch are green
77-
* when the version was bumped, generate a wheel and rsync it to the PEP 503
78-
simple index
77+
* when the version was bumped, udate the changelog with ``oca-towncrier``,
78+
generate a wheel and rsync it to the PEP 503 simple index
7979

8080
TODO (help wanted)
8181
------------------

Diff for: environment.sample

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ODOO_PASSWORD=
3434
# Available tasks:
3535
# delete_branch,tag_approved,tag_ready_to_merge,gen_addons_table,
3636
# gen_addons_readme,gen_addons_icon,setuptools_odoo,mention_maintainer,
37-
# merge_bot,tag_needs_review
37+
# merge_bot,merge_bot_towncrier,tag_needs_review
3838
#BOT_TASKS=all
3939

4040
# Root of the PEP 503 simple index where wheels are published

Diff for: newsfragments/106.feature

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make the "ocabot merge" command update ``HISTORY.rst`` from news fragments in
2+
``readme/newsfragments`` using `towncrier <https://pypi.org/project/towncrier/>`_.

Diff for: src/oca_github_bot/tasks/merge_bot.py

+37
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
)
1616
from ..manifest import (
1717
bump_manifest_version,
18+
bump_version,
19+
get_manifest,
1820
git_modified_addon_dirs,
1921
is_addon_dir,
2022
is_maintainer,
@@ -55,6 +57,30 @@ def _get_merge_bot_intro_message():
5557
return MERGE_BOT_INTRO_MESSAGES[i]
5658

5759

60+
@switchable("merge_bot_towncrier")
61+
def _merge_bot_towncrier(org, repo, target_branch, addon_dirs, bumpversion_mode, cwd):
62+
for addon_dir in addon_dirs:
63+
# Run oca-towncrier: this updates and git add readme/HISTORY.rst
64+
# if readme/newsfragments contains files and does nothing otherwise.
65+
_logger.info(f"oca-towncrier {org}/{repo}@{target_branch} for {addon_dirs}")
66+
version = bump_version(get_manifest(addon_dir)["version"], bumpversion_mode)
67+
check_call(
68+
[
69+
"oca-towncrier",
70+
"--org",
71+
org,
72+
"--repo",
73+
repo,
74+
"--addon-dir",
75+
addon_dir,
76+
"--version",
77+
version,
78+
"--commit",
79+
],
80+
cwd=cwd,
81+
)
82+
83+
5884
def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
5985
pr, target_branch, username, bumpversion_mode = parse_merge_bot_branch(
6086
merge_bot_branch
@@ -103,6 +129,17 @@ def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
103129
d for d in modified_addon_dirs if is_addon_dir(d, installable_only=True)
104130
]
105131

132+
# update HISTORY.rst using towncrier, before generating README.rst
133+
if bumpversion_mode:
134+
_merge_bot_towncrier(
135+
org,
136+
repo,
137+
target_branch,
138+
modified_installable_addon_dirs,
139+
bumpversion_mode,
140+
cwd,
141+
)
142+
106143
if modified_addon_dirs:
107144
# this includes setup.py and README.rst generation
108145
main_branch_bot_actions(org, repo, target_branch, cwd=cwd)

0 commit comments

Comments
 (0)