Skip to content

Commit

Permalink
[ADD] oca-patch-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed May 1, 2024
1 parent 1faff6d commit 030ca3b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"oca-configure-travis= tools.configure_travis:main",
"oca-create-branch = tools.create_branch:main",
"oca-copier-update = tools.copier_update:main",
"oca-patch-branch = tools.patch_branch:main",
],
},
)
35 changes: 35 additions & 0 deletions tools/patch_branch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Apply a patch with git am on a branch in all addons project.
"""
import os
import subprocess

import click

from .oca_projects import BranchNotFoundError, get_repositories, temporary_clone


@click.command()
@click.argument("branch")
@click.argument("patch-file", type=click.Path(exists=True, dir_okay=False))
def main(branch, patch_file):
patch_file = os.path.abspath(patch_file)
for repo in get_repositories():
try:
with temporary_clone(repo, branch):
print("=" * 10, repo, "=" * 10)
# set git user/email
subprocess.check_call(
["git", "config", "user.name", "oca-git-bot"],
)
subprocess.check_call(
["git", "config", "user.email", "oca-git-bot@odoo-community.org"],
)
# apply patch and commit
r = subprocess.call(["git", "am", patch_file])
if r != 0:
continue
# subprocess.check_call(["pre-commit", "run", "-a"])
# subprocess.check_call(["git", "commit", "-am", commit_message])
subprocess.check_call(["git", "push"])
except BranchNotFoundError:
pass

0 comments on commit 030ca3b

Please sign in to comment.