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

[ADD] oca-patch-branch #481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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", "[email protected]"],
)
# 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
Loading