diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-10-09 11:30:32 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-10-09 13:14:11 +0200 |
commit | 55e8c8fa32972402d47e9e83df5a8bfa663ce825 (patch) | |
tree | c1c193b9215faf7f2b518ed1dfa94a9fcc4f1576 | |
parent | 53f9f401245195d385f024f71695674fe61f6602 (diff) |
GitRepository.list_submodules: use _git_inout
and check exit status
This silences another spurious output to stderr in test_buildpackage_rpm
and makes sure we fail on the first operation on the nonexistent tree
(repo.list_submodules) instead of the second (repo.archive) since the
former ignored the exit status so far.
-rw-r--r-- | gbp/git/repository.py | 14 | ||||
-rw-r--r-- | gbp/scripts/common/buildpackage.py | 3 | ||||
-rw-r--r-- | tests/component/rpm/test_buildpackage_rpm.py | 3 |
3 files changed, 15 insertions, 5 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index bf5d528f..88b4c9ea 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1840,9 +1840,17 @@ class GitRepository(object): if recursive: args += ['-r'] - out, ret = self._git_getoutput('ls-tree', args, cwd=path) - for line in out: - mode, objtype, commit, name = line[:-1].split(None, 3) + out, err, ret = self._git_inout('ls-tree', + args, + cwd=path, + capture_stderr=True) + if ret: + raise GitRepositoryError("Failed to list submodules of %s: %s" % + (treeish, err.strip())) + for line in out.split('\n'): + if not line: + continue + mode, objtype, commit, name = line.split(None, 3) # A submodules is shown as "commit" object in ls-tree: if objtype == "commit": nextpath = os.path.join(path, name) diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py index 5944abf5..72489e54 100644 --- a/gbp/scripts/common/buildpackage.py +++ b/gbp/scripts/common/buildpackage.py @@ -24,6 +24,7 @@ import pipes import tempfile import shutil from gbp.command_wrappers import (CatenateTarArchive, CatenateZipArchive) +from gbp.git import GitRepositoryError from gbp.errors import GbpError import gbp.log @@ -152,7 +153,7 @@ def dump_tree(repo, export_dir, treeish, with_submodules, recursive=True): except OSError as err: gbp.log.err("Error dumping tree to %s: %s" % (output_dir, err[0])) return False - except GbpError as err: + except (GitRepositoryError, GbpError) as err: gbp.log.err(err) return False except Exception as e: diff --git a/tests/component/rpm/test_buildpackage_rpm.py b/tests/component/rpm/test_buildpackage_rpm.py index 7658ff47..71ff7b77 100644 --- a/tests/component/rpm/test_buildpackage_rpm.py +++ b/tests/component/rpm/test_buildpackage_rpm.py @@ -400,7 +400,8 @@ class TestGbpRpm(RpmRepoTestBase): upstr_branch, '--git-ignore-new']), 2) self._check_log(-2, ".*Error generating submodules' archives: " - "Unable to archive [0-9a-f]+: fatal: not a tree object") + "Failed to list submodules of [0-9a-f]{40}: fatal: " + "not a tree object") def test_option_submodules_native(self): """Test the --git-submodules option for native packages""" |