Skip to content
Open
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
32 changes: 2 additions & 30 deletions oca_port/port_addon_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import hashlib
import itertools
import pathlib
import shutil
import tempfile
import urllib.parse
from collections import defaultdict

Expand Down Expand Up @@ -421,41 +419,15 @@ def _port_pull_request_commits(self, pr, commits, base_ref, branch):
self._print("\t\t\tℹ️ Nothing to port from this commit, skipping")
continue
try:
# Generate patches to port from source module
patches_dir = tempfile.mkdtemp()
self.app.repo.git.format_patch(
"--keep-subject",
"-o",
patches_dir,
"-1",
commit.hexsha,
"--",
*paths_to_port,
)
patches = [
os.path.join(patches_dir, f)
for f in sorted(os.listdir(patches_dir))
]
# Apply patches on target module (could be the same than source one
# or a new one if it has been renamed).
n_leading_paths = len(self.app.source.addon_path.parts) + 1
self.app.repo.git.am(
"-3",
"--keep",
*patches,
f"-p{n_leading_paths}", # Remove 'a/my_module' from patch
"--directory",
self.app.target.addon_path, # Prepend 'my_module[_renamed]' to patch
)
shutil.rmtree(patches_dir)
self.app.repo.git.cherry_pick(commit.hexsha)
except git.exc.GitCommandError as exc:
self._print(f"{bc.FAIL}ERROR:{bc.ENDC}\n{exc}\n")
# High chance a conflict occurs, ask the user to resolve it
if not click.confirm(
"⚠️ A conflict occurs, please resolve it and "
"confirm to continue the process (y) or skip this commit (N)."
):
self.app.repo.git.am("--abort")
self.app.repo.git.cherry_pick("--abort")
continue
return True

Expand Down