Skip to content

Commit cb5f1f1

Browse files
authored
Merge pull request #106 from acsone/towncrier-sbi
ocabot merge: update HISTORY.rst, using oca-towncrier
2 parents 6aaac47 + 5144102 commit cb5f1f1

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ RUN set -x \
2222
&& python3 -m venv /ocamt \
2323
&& /ocamt/bin/pip install wheel
2424
RUN set -x \
25-
&& /ocamt/bin/pip install -e git+https://github.com/OCA/maintainer-tools@5dbc86310d80229ef0f2f5851933414be719308b#egg=oca-maintainers-tools \
25+
&& /ocamt/bin/pip install -e git+https://github.com/OCA/maintainer-tools@c7ac2741c02df0ad49ba637e2dca8e67d460af47#egg=oca-maintainers-tools \
2626
&& ln -s /ocamt/bin/oca-gen-addons-table /usr/local/bin/ \
2727
&& ln -s /ocamt/bin/oca-gen-addon-readme /usr/local/bin/ \
28-
&& ln -s /ocamt/bin/oca-gen-addon-icon /usr/local/bin/
28+
&& ln -s /ocamt/bin/oca-gen-addon-icon /usr/local/bin/ \
29+
&& ln -s /ocamt/bin/oca-towncrier /usr/local/bin/
2930
RUN set -x \
3031
&& /ocamt/bin/pip install setuptools-odoo>=2.5.0 \
3132
&& ln -s /ocamt/bin/setuptools-odoo-make-default /usr/local/bin/

README.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ as merge request comments.
7171
can be used to ask the bot to do the following:
7272

7373
* merge the PR onto a temporary branch created off the target branch
74-
* run the main branch operations (see above) on it
7574
* merge when tests on the rebased branch are green
7675
* optionally bump the version number of the addons modified by the PR
76+
* when the version was bumped, udate the changelog with ``oca-towncrier``
77+
* run the main branch operations (see above) on it
7778
* when the version was bumped, generate a wheel and rsync it to the PEP 503
7879
simple index
7980

environment.sample

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ODOO_PASSWORD=
3939
# Available tasks:
4040
# delete_branch,tag_approved,tag_ready_to_merge,gen_addons_table,
4141
# gen_addons_readme,gen_addons_icon,setuptools_odoo,mention_maintainer,
42-
# merge_bot,tag_needs_review
42+
# merge_bot,merge_bot_towncrier,tag_needs_review
4343
#BOT_TASKS=all
4444

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

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/>`_.

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,
@@ -67,6 +69,30 @@ def _get_merge_bot_intro_message():
6769
return MERGE_BOT_INTRO_MESSAGES[i]
6870

6971

72+
@switchable("merge_bot_towncrier")
73+
def _merge_bot_towncrier(org, repo, target_branch, addon_dirs, bumpversion_mode, cwd):
74+
for addon_dir in addon_dirs:
75+
# Run oca-towncrier: this updates and git add readme/HISTORY.rst
76+
# if readme/newsfragments contains files and does nothing otherwise.
77+
_logger.info(f"oca-towncrier {org}/{repo}@{target_branch} for {addon_dirs}")
78+
version = bump_version(get_manifest(addon_dir)["version"], bumpversion_mode)
79+
check_call(
80+
[
81+
"oca-towncrier",
82+
"--org",
83+
org,
84+
"--repo",
85+
repo,
86+
"--addon-dir",
87+
addon_dir,
88+
"--version",
89+
version,
90+
"--commit",
91+
],
92+
cwd=cwd,
93+
)
94+
95+
7096
def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
7197
pr, target_branch, username, bumpversion_mode = parse_merge_bot_branch(
7298
merge_bot_branch
@@ -115,6 +141,17 @@ def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
115141
d for d in modified_addon_dirs if is_addon_dir(d, installable_only=True)
116142
]
117143

144+
# update HISTORY.rst using towncrier, before generating README.rst
145+
if bumpversion_mode:
146+
_merge_bot_towncrier(
147+
org,
148+
repo,
149+
target_branch,
150+
modified_installable_addon_dirs,
151+
bumpversion_mode,
152+
cwd,
153+
)
154+
118155
if modified_addon_dirs:
119156
# this includes setup.py and README.rst generation
120157
main_branch_bot_actions(org, repo, target_branch, cwd=cwd)

0 commit comments

Comments
 (0)