Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squash post merge commits into one #260

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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