mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] tests: better tree-reading support
- add support for reading commit entries - add support for reading tree entries in non-recursive mode Previously the helper would only return blob entries, which does not allow testing submodule support.
This commit is contained in:
parent
a0e237fbfc
commit
5210cfb59f
14
conftest.py
14
conftest.py
@ -760,11 +760,15 @@ class Repo:
|
||||
# read tree's blobs
|
||||
tree = {}
|
||||
for t in r.json()['tree']:
|
||||
if t['type'] != 'blob':
|
||||
continue # only keep blobs
|
||||
r = self._session.get('https://api.github.com/repos/{}/git/blobs/{}'.format(self.name, t['sha']))
|
||||
assert 200 <= r.status_code < 300, r.text
|
||||
tree[t['path']] = base64.b64decode(r.json()['content']).decode()
|
||||
match t['type']:
|
||||
case 'commit':
|
||||
tree[t['path']] = f"@{t['sha']}"
|
||||
case 'blob':
|
||||
r = self._session.get('https://api.github.com/repos/{}/git/blobs/{}'.format(self.name, t['sha']))
|
||||
assert 200 <= r.status_code < 300, r.text
|
||||
tree[t['path']] = base64.b64decode(r.json()['content']).decode()
|
||||
case 'tree' if not recursive:
|
||||
tree[t['path']] = t['sha']
|
||||
|
||||
return tree
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user