aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-01-23 08:44:53 +0100
committerGuido Günther <agx@sigxcpu.org>2017-01-23 08:44:53 +0100
commit53b5af5898a8be27ec5f03d88e3e6c76232f6292 (patch)
tree9e9a7fd0c52f36cf44ee3f2ace2171f83f051aab
parent06ae8c94198ff280e01d0e04658e096c4dc55711 (diff)
dch: Allow to run from subdirectory
Resolves #1
-rw-r--r--gbp/deb/git.py4
-rw-r--r--gbp/scripts/dch.py6
-rw-r--r--tests/11_test_dch_main.py7
3 files changed, 13 insertions, 4 deletions
diff --git a/gbp/deb/git.py b/gbp/deb/git.py
index 23d3ee7..f4c7eaf 100644
--- a/gbp/deb/git.py
+++ b/gbp/deb/git.py
@@ -32,8 +32,8 @@ class DebianGitRepository(GitRepository):
'%(?P<R>([^%]|\\%))+'
'\)s')
- def __init__(self, path):
- super(DebianGitRepository, self).__init__(path)
+ def __init__(self, *args, **kwargs):
+ super(DebianGitRepository, self).__init__(*args, **kwargs)
self.pristine_tar = DebianPristineTar(self)
def tree_drop_dirs(self, tree, dirs):
diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
index 59e920b..18e86de 100644
--- a/gbp/scripts/dch.py
+++ b/gbp/scripts/dch.py
@@ -423,8 +423,10 @@ def main(argv):
return ExitCodes.parse_error
try:
+ old_cwd = os.path.abspath(os.path.curdir)
try:
- repo = DebianGitRepository('.')
+ repo = DebianGitRepository('.', toplevel=False)
+ os.chdir(repo.path)
except GitRepositoryError:
raise GbpError("%s is not a git repository" % (os.path.abspath('.')))
@@ -566,6 +568,8 @@ def main(argv):
if str(err):
gbp.log.err(err)
ret = 1
+ finally:
+ os.chdir(old_cwd)
return ret
diff --git a/tests/11_test_dch_main.py b/tests/11_test_dch_main.py
index a9b2146..5857168 100644
--- a/tests/11_test_dch_main.py
+++ b/tests/11_test_dch_main.py
@@ -81,7 +81,8 @@ class TestScriptDch(DebianGitTestRepo):
options.extend(dch_options)
ret = dch.main(options)
self.assertEqual(ret, 0)
- return open("debian/changelog").readlines()
+ cl = os.path.join(self.repo.path, 'debian/changelog')
+ return open(cl).readlines()
def test_dch_main_new_upstream_version(self):
"""Test dch.py like gbp dch script does: new upstream version"""
@@ -399,3 +400,7 @@ class TestScriptDch(DebianGitTestRepo):
options = ["--no-git-author", '-S', '-a']
lines = self.run_dch(options)
self.assertNotIn("-- gbp test user", "\n".join(lines))
+
+ def test_dch_subdir(self):
+ os.chdir('debian/')
+ self.run_dch()