Skip to content

Commit

Permalink
dch: Allow to run from subdirectory
Browse files Browse the repository at this point in the history
Resolves #1
  • Loading branch information
agx committed Jan 23, 2017
1 parent 06ae8c9 commit 53b5af5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gbp/deb/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion gbp/scripts/dch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('.')))

Expand Down Expand Up @@ -566,6 +568,8 @@ def main(argv):
if str(err):
gbp.log.err(err)
ret = 1
finally:
os.chdir(old_cwd)
return ret


Expand Down
7 changes: 6 additions & 1 deletion tests/11_test_dch_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def run_dch(self, dch_options=None):
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"""
Expand Down Expand Up @@ -399,3 +400,7 @@ def test_dch_main_no_git_author(self):
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()

0 comments on commit 53b5af5

Please sign in to comment.