From af955c932eb97433199781b5d4f7fb5fb5af8a6f Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 16 Oct 2018 15:10:35 +0100 Subject: [PATCH] Don't set topic when submitting no-topic patches Change-Id: I8f8880791ad7e46fb9e18623ab8bd295457424b2 Signed-off-by: Stephen Finucane --- git_review/cmd.py | 4 ++++ git_review/tests/test_git_review.py | 12 ++++++++++++ ...re-topic-for-master-patches-9ba01c0762d3df65.yaml | 6 ++++++ 3 files changed, 22 insertions(+) create mode 100644 releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml diff --git a/git_review/cmd.py b/git_review/cmd.py index 7f6e444d..15b04700 100644 --- a/git_review/cmd.py +++ b/git_review/cmd.py @@ -943,6 +943,10 @@ def get_topic(target_branch): branch_parts = branch_name.split("/") if len(branch_parts) >= 3 and branch_parts[0] == "review": + # We don't want to set the review number as the topic + if branch_parts[2].isdigit(): + return + topic = "/".join(branch_parts[2:]) if VERBOSE: print("Using change number %s for the topic of the change " diff --git a/git_review/tests/test_git_review.py b/git_review/tests/test_git_review.py index a02f44d7..e7b335a2 100644 --- a/git_review/tests/test_git_review.py +++ b/git_review/tests/test_git_review.py @@ -383,6 +383,18 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase): finally: os.environ.update(LANG=lang_env) + def test_no_topic(self): + """Test on change with no topic. + + This will be checked out as 'review/{owner}/{ID}'. We don't want to set + the topic to '{ID}'. + """ + self._run_git_review('-s') + curr_branch = self._run_git('rev-parse', '--abbrev-ref', 'HEAD') + self._run_git('checkout', '-b', 'review/johndoe/123456') + self._simple_change('test file modified', 'derp derp derp') + self._assert_branch_would_be(curr_branch) + def test_git_review_t(self): self._run_git_review('-s') self._simple_change('test file modified', 'commit message for bug 654') diff --git a/releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml b/releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml new file mode 100644 index 00000000..82ed9b98 --- /dev/null +++ b/releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + If a patch has no topic, downloading it will result in a topic of + ``review/{owner}/{ID}``. Previously, submitting this would then set the + topic to ``{ID}``. This was incorrect behavior and is now resolved.