diff options
| author | Romaric Jodin <rjodin@google.com> | 2026-10-29 08:52:04 +0100 |
|---|---|---|
| committer | gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-11-03 00:10:19 -0800 |
| commit | 365629015667e04739f59070e745548a728549c8 (patch) | |
| tree | dc4fee64bdec9157fe232c5689a3763fbcb70057 /tests/test_subcmds_upload.py | |
| parent | b90c7cd8f9e14418c4a486f424fc9afc84d3ff18 (diff) | |
| download | git-repo-2.72.tar.gz | |
When uploading a branch that merges another remote-tracking branch (such
as an upstream branch into the destination branch), ReviewableBranch
only excludes the destination tracking branch (^base). As a result, git
rev-list walks the merged parent and counts all merged commits even
though they already exist on a remote branch, triggering the unusual
commit count warning in _VerifyPendingCommits.
Add --ignore-remote-commits to `repo upload` to pass --not --remotes to
git rev-list in ReviewableBranch so commits already reachable from
refs/remotes/* are excluded from the pending commit list.
Test: ./run_tests tests/test_project.py tests/test_subcmds_upload.py
Change-Id: Ib1fb864982729e20a621144580fe95daa478eaee
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/651284
Tested-by: Romaric Jodin <rjodin@google.com>
Reviewed-by: Brian Gan <brgan@google.com>
Commit-Queue: Romaric Jodin <rjodin@google.com>
Diffstat (limited to 'tests/test_subcmds_upload.py')
| -rw-r--r-- | tests/test_subcmds_upload.py | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/test_subcmds_upload.py b/tests/test_subcmds_upload.py index 4c9008f55..53cc651a1 100644 --- a/tests/test_subcmds_upload.py +++ b/tests/test_subcmds_upload.py | |||
| @@ -116,11 +116,46 @@ def test_GatherOne_returns_resolved_current_branch( | |||
| 116 | "get_parallel_context", | 116 | "get_parallel_context", |
| 117 | lambda: {"projects": [project]}, | 117 | lambda: {"projects": [project]}, |
| 118 | ) | 118 | ) |
| 119 | opt = mock.MagicMock(current_branch=True) | 119 | opt = mock.MagicMock(current_branch=True, ignore_remote_commits=False) |
| 120 | 120 | ||
| 121 | assert upload.Upload._GatherOne(opt, 0) == (0, [branch], "topic") | 121 | assert upload.Upload._GatherOne(opt, 0) == (0, [branch], "topic") |
| 122 | 122 | ||
| 123 | project.GetUploadableBranch.assert_called_once_with("topic") | 123 | project.GetUploadableBranch.assert_called_once_with( |
| 124 | "topic", ignore_remote_commits=False | ||
| 125 | ) | ||
| 126 | |||
| 127 | |||
| 128 | def test_GatherOne_forwards_ignore_remote_commits( | ||
| 129 | cmd: upload.Upload, | ||
| 130 | monkeypatch: pytest.MonkeyPatch, | ||
| 131 | ) -> None: | ||
| 132 | """_GatherOne forwards --ignore-remote-commits to project methods.""" | ||
| 133 | project = mock.MagicMock() | ||
| 134 | project.CurrentBranch = "topic" | ||
| 135 | branch = mock.sentinel.branch | ||
| 136 | project.GetUploadableBranch.return_value = branch | ||
| 137 | project.GetUploadableBranches.return_value = [branch] | ||
| 138 | monkeypatch.setattr( | ||
| 139 | upload.Upload, | ||
| 140 | "get_parallel_context", | ||
| 141 | lambda: {"projects": [project]}, | ||
| 142 | ) | ||
| 143 | |||
| 144 | opt_cbr, _ = cmd.OptionParser.parse_args( | ||
| 145 | ["--cbr", "--ignore-remote-commits"] | ||
| 146 | ) | ||
| 147 | assert upload.Upload._GatherOne(opt_cbr, 0) == (0, [branch], "topic") | ||
| 148 | project.GetUploadableBranch.assert_called_once_with( | ||
| 149 | "topic", ignore_remote_commits=True | ||
| 150 | ) | ||
| 151 | |||
| 152 | opt_br, _ = cmd.OptionParser.parse_args( | ||
| 153 | ["--br", "topic", "--ignore-remote-commits"] | ||
| 154 | ) | ||
| 155 | assert upload.Upload._GatherOne(opt_br, 0) == (0, [branch], None) | ||
| 156 | project.GetUploadableBranches.assert_called_once_with( | ||
| 157 | "topic", ignore_remote_commits=True | ||
| 158 | ) | ||
| 124 | 159 | ||
| 125 | 160 | ||
| 126 | def _create_mock_branch( | 161 | def _create_mock_branch( |
