diff --git a/.changelog/021.yaml b/.changelog/021.yaml new file mode 100644 index 0000000..4792637 --- /dev/null +++ b/.changelog/021.yaml @@ -0,0 +1,7 @@ +name: copy +ts: 2026-02-13 10:39:28.526332+00:00 +type: fix +author: Espen Albert +changelog_message: 'fix(copy): skip PR close when running with --local/--skip-commit' +message: 'fix(copy): skip PR close when running with --local/--skip-commit' +short_sha: c98900 diff --git a/docs/copy/index.md b/docs/copy/index.md index 713f00e..178f29e 100644 --- a/docs/copy/index.md +++ b/docs/copy/index.md @@ -52,6 +52,7 @@ Copy files from SRC to DEST repositories. | Version | Change | |---------|--------| +| unreleased | fix(copy): skip PR close when running with --local/--skip-commit | | 0.7.1 | fix(cmd_copy): add warning for unknown comment prefix in sync process | | 0.6.0 | fix(copy): apply skip_sections when creating new files with sections | | 0.6.0 | fix(copy): commit synced files before running verify steps | diff --git a/path_sync/_internal/cmd_copy.py b/path_sync/_internal/cmd_copy.py index c251a42..cfa3e27 100644 --- a/path_sync/_internal/cmd_copy.py +++ b/path_sync/_internal/cmd_copy.py @@ -221,7 +221,7 @@ def _run_copy(config: SrcConfig, src_root: Path, dest_filter: str, opts: CopyOpt def _close_stale_pr(dest_root: Path, copy_branch: str, opts: CopyOptions, config: SrcConfig) -> None: - if opts.dry_run or opts.no_pr or config.keep_pr_on_no_changes: + if opts.dry_run or opts.skip_commit or opts.no_pr or config.keep_pr_on_no_changes: return if git_ops.has_open_pr(dest_root, copy_branch): git_ops.close_pr(dest_root, copy_branch, "Closing: source and destination are in sync, no changes needed") diff --git a/path_sync/cmd_copy_test.py b/path_sync/cmd_copy_test.py index 7e92303..ea8c258 100644 --- a/path_sync/cmd_copy_test.py +++ b/path_sync/cmd_copy_test.py @@ -552,6 +552,14 @@ def test_close_stale_pr_skipped_when_keep_pr_on_no_changes(tmp_path: Path): mock_git.has_open_pr.assert_not_called() +def test_close_stale_pr_skipped_when_skip_commit(tmp_path: Path): + opts = CopyOptions(skip_commit=True) + config = _make_src_config() + with patch(f"{COPY_MODULE}.git_ops") as mock_git: + _close_stale_pr(tmp_path, "sync/test", opts, config) + mock_git.has_open_pr.assert_not_called() + + def test_close_stale_pr_runs_by_default(tmp_path: Path): opts = CopyOptions() config = _make_src_config()