Skip to content

Commit

Permalink
Merge pull request #260 from acsone/avoid-automated-actions-commits-p…
Browse files Browse the repository at this point in the history
…roliferation

Squash post merge commits into one
  • Loading branch information
sbidoul authored Sep 16, 2023
2 parents a3397e6 + 8aba0da commit a90e01a
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/oca_github_bot/tasks/merge_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
check_call(["git", "fetch", "origin", f"refs/pull/{pr}/head:tmp-pr-{pr}"], cwd=cwd)
check_call(["git", "checkout", f"tmp-pr-{pr}"], cwd=cwd)
modified_addon_dirs, _, _ = git_modified_addon_dirs(cwd, target_branch)
# Run main branch bot actions before bump version.
# Do not run the main branch bot if there are no modified addons,
# because it is dedicated to addons repos.
check_call(["git", "checkout", merge_bot_branch], cwd=cwd)

# remove not installable addons (case where an addons becomes no more
# installable).
head_sha = github.git_get_head_sha(cwd)

# list installable modified addons only
modified_installable_addon_dirs = [
d for d in modified_addon_dirs if is_addon_dir(d, installable_only=True)
]
Expand All @@ -158,19 +156,30 @@ def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
cwd,
)

if modified_addon_dirs:
# this includes setup.py and README.rst generation
main_branch_bot_actions(org, repo, target_branch, cwd=cwd)

for addon_dir in modified_installable_addon_dirs:
# TODO wlc lock and push
# TODO msgmerge and commit
if bumpversion_mode != "nobump":
# bump manifest version of modified installable addons
if bumpversion_mode != "nobump":
for addon_dir in modified_installable_addon_dirs:
# bumpversion is last commit (after readme generation etc
# and before building wheel),
# so setuptools-odoo generates a round version number
# (without .dev suffix).
bump_manifest_version(addon_dir, bumpversion_mode, git_commit=True)

# run the main branch bot actions only if there are modified addon directories,
# so we don't run them when the merge bot branch for non-addons repos
if modified_addon_dirs:
# this includes setup.py and README.rst generation
main_branch_bot_actions(org, repo, target_branch, cwd=cwd)

# squash post merge commits into one (bumpversion, readme generator, etc),
# to avoid a proliferation of automated actions commits
if github.git_get_head_sha(cwd) != head_sha:
check_call(["git", "reset", "--soft", head_sha], cwd=cwd)
check_call(
["git", "commit", "-m", "oca-github-bot post-merge updates"], cwd=cwd
)

for addon_dir in modified_installable_addon_dirs:
build_and_check_wheel(addon_dir)

if dry_run:
Expand Down

0 comments on commit a90e01a

Please sign in to comment.