From 46510575744e10abec9cc0b7af632215a199e28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Wed, 20 Nov 2024 10:47:51 +0100 Subject: [PATCH] [FIX] give the priority to the target repository Allows to support migration/porting session for modules that have been moved from one repository to another. The target repository is the one that should have the priority. --- oca_port/app.py | 2 +- oca_port/port_addon_pr.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/oca_port/app.py b/oca_port/app.py index c9b4f9b..1eda9c9 100644 --- a/oca_port/app.py +++ b/oca_port/app.py @@ -185,8 +185,8 @@ def _prepare_parameters(self): self.repo_path = pathlib.Path(self.repo_path) self.repo_name = ( self.repo_name - or self.source.repo or self.target.repo + or self.source.repo or self.repo_path.absolute().name ) if not self.repo_path: diff --git a/oca_port/port_addon_pr.py b/oca_port/port_addon_pr.py index 72f1489..ccf0e0b 100644 --- a/oca_port/port_addon_pr.py +++ b/oca_port/port_addon_pr.py @@ -850,10 +850,11 @@ def _get_original_pr(self, commit: g.Commit): # Request GitHub to get them if not any("github.com" in remote.url for remote in self.app.repo.remotes): return + src_repo_name = self.app.source.repo or self.app.repo_name try: raw_data = self.app.github.get_original_pr( self.app.upstream_org, - self.app.repo_name, + src_repo_name, self.app.from_branch.name, commit.hexsha, ) @@ -866,7 +867,7 @@ def _get_original_pr(self, commit: g.Commit): # NOTE: commits fetched from PR are already in the right order pr_number = raw_data["number"] pr_commits_data = self.app.github.request( - f"repos/{self.app.upstream_org}/{self.app.repo_name}" + f"repos/{self.app.upstream_org}/{src_repo_name}" f"/pulls/{pr_number}/commits?per_page=100" ) pr_commits = [pr["sha"] for pr in pr_commits_data]