Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
use repos.get_content endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
thegreyd committed Jul 27, 2023
1 parent 29ba524 commit 93223bb
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions doozerlib/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1533,22 +1533,10 @@ def get_releases(runtime) -> dict:
raise DoozerFatalError('A GITHUB_TOKEN environment variable must be defined!')
github_token = os.environ['GITHUB_TOKEN']

# TODO: data_path can be a local path in which case this will fail
owner = runtime.data_path.split('/')[-2]
api = GhApi(owner=owner, repo='ocp-build-data', token=github_token)
commitish = runtime.group_commitish

# TODO: this assumes commitish is a branch it doesn't work for tags/shasum. fix it
# api.git.get_ref(shasum) doesn't work
ref = api.git.get_ref(f'heads/{commitish}')
tree = api.git.get_tree(ref.object.sha).tree
releases_file, releases_yaml = 'releases.yml', None
for f in tree:
if f.path == releases_file:
releases_yaml = f
if not releases_yaml:
raise DoozerFatalError(f'Cannot find {releases_file} in {runtime.group_commitish}')

blob = api.git.get_blob(file_sha=releases_yaml['sha'])
blob = api.repos.get_content('releases.yml', ref=runtime.group_commitish)
return yaml.safe_load(base64.b64decode(blob['content']))


Expand Down

0 comments on commit 93223bb

Please sign in to comment.