aboutsummaryrefslogtreecommitdiff
path: root/tests/component/deb/test_import_dsc.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2015-11-19 09:22:11 +0100
committerGuido Günther <agx@sigxcpu.org>2015-11-19 09:26:33 +0100
commit8583e0364cf785f9d036b25a778c6c20690c44a8 (patch)
tree45de2b14ee39d2ce0864538d3a8f692acdb236f5 /tests/component/deb/test_import_dsc.py
parentcbd40e5f49a43b6b5e525be8048c0407dbb783cb (diff)
import-dsc: Bail out if target dir exists
If import-dsc is not run from within a Git repository it tries to create one named like the souce package. If that directory already exists we get confusing message like: gbp:info: No git repository found, creating one. gbp:warning: Version 0.7.0 already imported. gbp:info: Everything imported under /foo/git-buildpackage Avoid this by checking if the directory exists and aborting in this case. Closes: #766350
Diffstat (limited to 'tests/component/deb/test_import_dsc.py')
-rw-r--r--tests/component/deb/test_import_dsc.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py
index 2360f5f..760b365 100644
--- a/tests/component/deb/test_import_dsc.py
+++ b/tests/component/deb/test_import_dsc.py
@@ -99,3 +99,25 @@ class TestImportDsc(ComponentTestBase):
'--upstream-branch=upstream',
dsc]) == 1
self._check_log(0, "gbp:error: Cannot import package with additional tarballs but found 'hello-debhelper_2.8.orig-foo.tar.gz")
+
+ def test_existing_dir(self):
+ """
+ Importing outside of git repository with existing target
+ dir must fail
+ """
+ def _dsc(version):
+ return os.path.join(DEB_TEST_DATA_DIR,
+ 'dsc-3.0',
+ 'hello-debhelper_%s.dsc' % version)
+
+ # Create directory we should stumble upon
+ os.makedirs('hello-debhelper')
+ dsc = _dsc('2.8-1')
+ assert import_dsc(['arg0',
+ '--verbose',
+ '--pristine-tar',
+ '--debian-branch=master',
+ '--upstream-branch=upstream',
+ dsc]) == 1
+ self._check_log(0, "gbp:error: Directory 'hello-debhelper' already exists. If you want to import into it, "
+ "please change into this directory otherwise move it away first")