diff --git a/git_upstream/lib/importupstream.py b/git_upstream/lib/importupstream.py index bdb9d72..4426ba9 100644 --- a/git_upstream/lib/importupstream.py +++ b/git_upstream/lib/importupstream.py @@ -269,8 +269,9 @@ class ImportUpstream(LogDedentMixin, GitMixin): commit_list = list(strategy.filtered_iter()) if len(commit_list) == 0: - self.log.notice("There are no local changes to be applied!") - return False + self.log.notice("All carried changes gone upstream") + self._set_branch(self.import_branch, self.upstream, force=True) + return True self.log.debug( """ diff --git a/git_upstream/tests/commands/import/scenarios/import_everything_already_upstreamed.yaml b/git_upstream/tests/commands/import/scenarios/import_everything_already_upstreamed.yaml new file mode 100644 index 0000000..93c92de --- /dev/null +++ b/git_upstream/tests/commands/import/scenarios/import_everything_already_upstreamed.yaml @@ -0,0 +1,48 @@ +# +# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--- +- desc: | + Test importing where everything is upstreamed + + Checks that importing an upstream where all local changes have + gone upstream, will correctly replace the local master with + the latest upstream branch. + + C---D local/master + / + A---B---E---C1--D1 upstream/master + + tree: + - [A, []] + - [B, [A]] + - [C, [B]] + - [D, [C]] + - [C1, [E]] + - [D1, [C1]] + - [E, [B]] + + branches: + head: [master, D] + upstream: [upstream/master, D1] + + parser_args: + - -q + - import + - --into=master + - upstream/master + + expect_found: [] diff --git a/git_upstream/tests/commands/import/test_import.py b/git_upstream/tests/commands/import/test_import.py index 70bb914..c3dff15 100644 --- a/git_upstream/tests/commands/import/test_import.py +++ b/git_upstream/tests/commands/import/test_import.py @@ -124,3 +124,14 @@ class TestImportCommand(TestWithScenarios, BaseTestCase): self.assertThat( self.logger.output, Contains("No updated additional branch given, nothing to be done")) + + def _verify_import_everything_already_upstreamed(self): + """Additional verification for the finished results""" + + self.assertThat( + self.logger.output, + Contains("All carried changes gone upstream")) + self.assertThat( + self.logger.output, + Contains("Creating branch 'import/test_command' from specified " + "commit 'upstream/master'"))