Use default branch for querying README blobs

GETting "{_gitsrht}/api/repos/{repo_name}/refdb/HEAD" would also have
worked, but it's hardly necessary

Ref: ~sircmpwn/hub.sr.ht#50
This commit is contained in:
наб 2020-08-17 19:07:06 +02:00 committed by Drew DeVault
parent de106cf291
commit dff8093560
1 changed files with 2 additions and 3 deletions

View File

@ -97,10 +97,9 @@ class GitService(SrhtService):
def get_readme(self, user, repo_name, repo_url):
# TODO: Cache?
# TODO: Use default branch
link_prefix = repo_url + "/blob/refs/heads/master/"
link_prefix = repo_url + "/blob/HEAD/"
for readme_name in readme_names:
r = self.session.get(f"{_gitsrht}/api/repos/{repo_name}/blob/master/{readme_name}",
r = self.session.get(f"{_gitsrht}/api/repos/{repo_name}/blob/HEAD/{readme_name}",
headers=get_authorization(user))
if r.status_code == 404:
continue