Skip to content

Commit

Permalink
Merge pull request #261 from ForgeFlow/master-add-tags-to-commits
Browse files Browse the repository at this point in the history
[IMP] Add the [BOT] tag to oca-github-bot commits
  • Loading branch information
sbidoul authored Sep 20, 2023
2 parents a90e01a + 8f424cb commit 0919fac
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/oca_github_bot/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def bump_manifest_version(addon_dir, mode, git_commit=False):
"git",
"commit",
"-m",
f"{addon_name} {version}",
f"[BOT] {addon_name} {version}",
"--",
get_manifest_file_name(addon_dir),
],
Expand Down
4 changes: 1 addition & 3 deletions src/oca_github_bot/tasks/merge_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
# 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
)
check_call(["git", "commit", "-m", "[BOT] post-merge updates"], cwd=cwd)

for addon_dir in modified_installable_addon_dirs:
build_and_check_wheel(addon_dir)
Expand Down
4 changes: 3 additions & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def make_addon(git_clone, addon_name, **manifest_keys):
def commit_addon(git_clone, addon_name):
addon_dir = git_clone / addon_name
subprocess.check_call(["git", "add", addon_dir], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", f"add {addon_name}"], cwd=git_clone)
subprocess.check_call(
["git", "commit", "-m", f"[BOT] add {addon_name}"], cwd=git_clone
)


@contextmanager
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def git_clone(tmp_path):
with somefile.open("w"):
pass
subprocess.check_call(["git", "add", "somefile"], cwd=clone)
subprocess.check_call(["git", "commit", "-m", "add somefile"], cwd=clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] add somefile"], cwd=clone)
subprocess.check_call(["git", "push", "origin", "master"], cwd=clone)
yield clone

Expand Down
4 changes: 3 additions & 1 deletion tests/test_build_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def _make_addon(
)
)
subprocess.check_call(["git", "add", addon_name], cwd=addons_dir)
subprocess.check_call(["git", "commit", "-m", "add " + addon_name], cwd=addons_dir)
subprocess.check_call(
["git", "commit", "-m", "[BOT] add " + addon_name], cwd=addons_dir
)
subprocess.check_call(["git", "clean", "-ffdx", "--", "setup"], cwd=addons_dir)
if setup_py:
cmd = ["setuptools-odoo-make-default", "-d", str(addons_dir), "--commit"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_git_push_if_needed.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_git_push_if_needed(git_clone):
with afile.open("w"):
pass
subprocess.check_call(["git", "add", "afile"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "add afile"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] add afile"], cwd=git_clone)
assert git_push_if_needed("origin", "master", cwd=git_clone)
assert not git_push_if_needed("origin", "master", cwd=git_clone)
subprocess.check_call(["git", "reset", "--hard", "HEAD^"], cwd=git_clone)
Expand Down
22 changes: 13 additions & 9 deletions tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_git_modified_addons(git_clone):
manifest_path = addon_dir / "__manifest__.py"
manifest_path.write_text("{'name': 'the addon'}")
subprocess.check_call(["git", "add", "."], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "add addon"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] add addon"], cwd=git_clone)
assert git_modified_addons(git_clone, "origin/master") == ({"addon"}, False)
# push and check addon is not modified
subprocess.check_call(["git", "push", "origin", "master"], cwd=git_clone)
Expand All @@ -131,12 +131,16 @@ def test_git_modified_addons(git_clone):
setup_dir.mkdir(parents=True)
(setup_dir / "setup.py").write_text("")
subprocess.check_call(["git", "add", "setup"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "add addon setup"], cwd=git_clone)
subprocess.check_call(
["git", "commit", "-m", "[BOT] add addon setup"], cwd=git_clone
)
assert git_modified_addons(git_clone, "origin/master") == (set(), True)
(setup_dir / "odoo" / "addons").mkdir(parents=True)
(setup_dir / "odoo" / "addons" / "addon").symlink_to("../../../../addon")
subprocess.check_call(["git", "add", "setup"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "add addon setup"], cwd=git_clone)
subprocess.check_call(
["git", "commit", "-m", "[BOT] add addon setup"], cwd=git_clone
)
assert git_modified_addons(git_clone, "origin/master") == ({"addon"}, False)
assert git_modified_addon_dirs(git_clone, "origin/master") == (
[str(git_clone / "addon")],
Expand All @@ -151,15 +155,15 @@ def test_git_modified_addons(git_clone):
(addon_dir / "__init__.py").write_text("")
(git_clone / "README").write_text("")
subprocess.check_call(["git", "add", "."], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "add addon2"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] add addon2"], cwd=git_clone)
assert git_modified_addons(git_clone, "origin/master") == (
{"addon", "addon2"},
True, # because of README at repo root
)
# remove the first and test it does not appear in result
subprocess.check_call(["git", "tag", "beforerm"], cwd=git_clone)
subprocess.check_call(["git", "rm", "-r", "addon"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "rm addon"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] rm addon"], cwd=git_clone)
assert git_modified_addons(git_clone, "beforerm") == (set(), True)


Expand All @@ -169,21 +173,21 @@ def test_git_modified_addons_merge_base(git_clone):
addon2_dir.mkdir()
(addon2_dir / "__manifest__.py").write_text("{'name': 'addon2'}")
subprocess.check_call(["git", "add", "addon2"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "add addon2"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] add addon2"], cwd=git_clone)
assert git_modified_addons(git_clone, "origin/master") == ({"addon2"}, False)
# create addon1 on a new branch
subprocess.check_call(["git", "checkout", "-b" "addon1"], cwd=git_clone)
addon1_dir = git_clone / "addon1"
addon1_dir.mkdir()
(addon1_dir / "__manifest__.py").write_text("{'name': 'addon1'}")
subprocess.check_call(["git", "add", "addon1"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "add addon1"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] add addon1"], cwd=git_clone)
assert git_modified_addons(git_clone, "master") == ({"addon1"}, False)
# modify addon2 on master
subprocess.check_call(["git", "checkout", "master"], cwd=git_clone)
(addon2_dir / "__manifest__.py").write_text("{'name': 'modified addon2'}")
subprocess.check_call(["git", "add", "addon2"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "upd addon2"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] upd addon2"], cwd=git_clone)
# check comparison of addon1 to master only gives addon1
subprocess.check_call(["git", "checkout", "addon1"], cwd=git_clone)
assert git_modified_addons(git_clone, "master") == ({"addon1"}, False)
Expand All @@ -193,7 +197,7 @@ def test_git_modified_addons_merge_base(git_clone):
addon3_dir.mkdir()
(addon3_dir / "__manifest__.py").write_text("{'name': 'addon3'}")
subprocess.check_call(["git", "add", "addon3"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "add addon3"], cwd=git_clone)
subprocess.check_call(["git", "commit", "-m", "[BOT] add addon3"], cwd=git_clone)
assert git_modified_addons(git_clone, "HEAD^") == ({"addon3"}, False)
commit = git_get_head_sha(cwd=git_clone)
subprocess.check_call(["git", "checkout", "addon1"], cwd=git_clone)
Expand Down

0 comments on commit 0919fac

Please sign in to comment.