From 59bf3a6e709d929a98d5bec97227c5f586f00772 Mon Sep 17 00:00:00 2001 From: Doesnot Matter Date: Thu, 26 May 2022 12:28:47 +0200 Subject: repository: list_tree: Handle '-' This is returned for git submodules and broke the the clone test like: ====================================================================== ERROR: Test that cloning from github urls works ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/scratch/src/git-buildpackage/git-buildpackage/tests/component/deb/test_clone.py", line 81, in test_clone_github ret = clone(['arg0', "github:agx/git-buildpackage", dest]) File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/clone.py", line 214, in main if options.defuse_gitattributes.is_on() or not repo_setup.check_gitattributes(repo, 'HEAD'): File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/common/repo_setup.py", line 43, in check_gitattributes for mode, _type, sha1, size, path in repo.list_tree(treeish, recurse=True, sizes=True): File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/repository.py", line 1105, in list_tree yield mode, type, sha1, int(size), filename ValueError: invalid literal for int() with base 10: '-' -------------------- >> begin captured logging << -------------------- gbp: info: Cloning from 'https://github.com/agx/git-buildpackage.git' into '/.../git-buildpackage/gbp_TestClone_730g3vkb/tmp_test_clone_github_i9jrqgmy/cloned_repo' --------------------- >> end captured logging << --------------------- --- gbp/git/repository.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gbp/git') diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 176be9bf..01226804 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1102,6 +1102,8 @@ class GitRepository(object): filename = parts.pop() if sizes: mode, type, sha1, size = (part.decode() for part in parts) + # Git submodules report '-' instead of a size + size = size if size != '-' else 0 yield mode, type, sha1, int(size), filename else: mode, type, sha1 = (part.decode() for part in parts) -- cgit v1.2.3