diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-11-16 23:56:06 +0200 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-11-16 23:56:06 +0200 |
commit | 494fed58663aace4c0cdc51e7ab1466872d542df (patch) | |
tree | f71fb0ad3fbef6351b265ec97d4cb6b74e5cf218 /pomu/util | |
parent | Remote hotfixes (diff) | |
download | pomu-494fed58663aace4c0cdc51e7ab1466872d542df.tar.gz pomu-494fed58663aace4c0cdc51e7ab1466872d542df.tar.bz2 pomu-494fed58663aace4c0cdc51e7ab1466872d542df.zip |
remote git repo fixes
fixed imports in remote repo sources
fixed logic in repository package fetching
Diffstat (limited to 'pomu/util')
-rw-r--r-- | pomu/util/git.py | 16 | ||||
-rw-r--r-- | pomu/util/remote.py | 8 |
2 files changed, 14 insertions, 10 deletions
diff --git a/pomu/util/git.py b/pomu/util/git.py index 611b27c..985087c 100644 --- a/pomu/util/git.py +++ b/pomu/util/git.py @@ -5,10 +5,12 @@ import zlib from pomu.util.result import Result -def parse_tree(blob, path=''): +def parse_tree(blob, path=b''): """Parses a git tree""" res = [] leng, _, tree = blob.partition(b'\0') + if path is str: + path = path.encode('utf-8') if not tree: return Result.Err('Invalid tree') while len(tree) > 0: @@ -19,15 +21,15 @@ def parse_tree(blob, path=''): if not name or not sha: return Result.Err() is_dir = mode[0:1] != b'1' - res.append((is_dir, sha, path.encode('utf-8') + b'/' + name)) + res.append((is_dir, sha, path + b'/' + name)) return Result.Ok(res) def parse_blob(blob): """Parses a git blob""" - data = zlib.decompress(blob) - leng, _, data = data.partition('\0') + leng, _, data = blob.partition(b'\0') if not leng or not data: return Result.Err() + return Result.Ok(data) def commit_head(blob): if not blob[7:] == 'commit ': @@ -38,11 +40,13 @@ def commit_head(blob): return Result.Err() return tid[5:] -def parse_object(obj): +def parse_object(obj, tpath=b''): """Parses a git object""" + if tpath is str: + tpath = tpath.encode('utf-8') data = zlib.decompress(obj) if data[0:5] == b'blob ': return parse_blob(data[5:]) elif data[0:5] == b'tree ': - return parse_tree(data[5:]) + return parse_tree(data[5:], tpath) return Result.Err('Unsupported object type') diff --git a/pomu/util/remote.py b/pomu/util/remote.py index 9e3875a..c0c6554 100644 --- a/pomu/util/remote.py +++ b/pomu/util/remote.py @@ -13,7 +13,7 @@ def filelist_to_cpvs(tree): """Converts a list of files to list of cpvs""" res = [] for opath in tree: - comps = opath.split('/') + comps = opath.split('/')[1:] if (opath.endswith('/') or any(opath.startswith('/' + x + '/') for x in misc_dirs) or len(comps) != 3 or @@ -21,18 +21,18 @@ def filelist_to_cpvs(tree): continue category, name, ebuild = comps[0], comps[1], comps[2][:-7] c, n, v, s, r = cpv_split(ebuild) - if category or n != name: + if not category or n != name: continue ver = ver_str(v, s, r) res.append((category, name, ver)) return res def get_full_cpv(cpvs, name, category=None, version=None): - cpvl = cpvs.filter(lambda x: x[1] == name and (not category or x[0] == category)) + cpvl = filter(lambda x: x[1] == name and (not category or x[0] == category), cpvs) if not cpvl: return Result.Err() if version: cpvl = cpvl.filter(lambda x: x[2] == version)[:1] - b = best('{}/{}-{}'.format(c, n, v) for c, n, v in cpvl) + b = best(list('{}/{}-{}'.format(c, n, v) for c, n, v in cpvl)) if b: cat, name, v, s, r = cpv_split(b) ver = ver_str(v, s, r) |