diff --git a/oca_port/app.py b/oca_port/app.py index 28531a8..6a3b049 100644 --- a/oca_port/app.py +++ b/oca_port/app.py @@ -82,6 +82,7 @@ class App(Output): clear_cache: bool = False github_token: str = None cli: bool = False # Not documented, should not be used outside of the CLI + skip_similar_commits: bool = True _available_outputs = ("json",) diff --git a/oca_port/port_addon_pr.py b/oca_port/port_addon_pr.py index e357778..8096adf 100644 --- a/oca_port/port_addon_pr.py +++ b/oca_port/port_addon_pr.py @@ -876,6 +876,23 @@ def get_commits_diff(self): pr_commit_paths = { path for path in pr_commit.paths if not path_to_skip(path) } + if ( + self.app.skip_similar_commits + and len(pr_commit.summary) > 20 + and ( + pr_commit.summary, + pr_commit.author_email, + ) + in [ + (c.summary, c.author_email) + for c in self.to_branch_path_commits + ] + ): + print( + f"SKIPPING '{pr_commit.summary}' because a similar commit " + f"(summary, author_email) was found. {pr_commit_paths} {pr_commit_sha}" + ) + continue pr.paths.update(pr_commit_paths) # Check that this PR commit does not change the current # addon we are interested in, in such case also check diff --git a/oca_port/tests/test_branches_diff.py b/oca_port/tests/test_branches_diff.py index 866c78b..084bdd1 100644 --- a/oca_port/tests/test_branches_diff.py +++ b/oca_port/tests/test_branches_diff.py @@ -42,7 +42,9 @@ def test_with_satellite_changes(self): ] upstream_repo.git.am("-3", "--keep", *patches) # Check if unported change is detected as satellite - app = self._create_app(self.source1, self.target1, fetch=True) + app = self._create_app( + self.source1, self.target1, fetch=True, skip_similar_commits=False + ) diff = BranchesDiff(app) self.assertFalse(diff.commits_diff["addon"]) self.assertTrue(diff.commits_diff["satellite"])