tools/check-git-repo-availability.py: softwareheritage URL when NoSourceSince

This commit is contained in:
Hans-Christoph Steiner 2025-11-11 19:42:38 +01:00 committed by linsui
parent bba2a364dd
commit 15aa39d1a6

View file

@ -106,8 +106,22 @@ for f in files:
if not f.startswith('metadata/'):
continue
# this rewriting only works with metadata files, not srclibs
url = data.get('SourceCode')
if url and not url.startswith('https://archive.softwareheritage.org/'):
url = url[:-4] if url.endswith('.git') else url
r = requests.get(f'https://archive.softwareheritage.org/api/1/origin/{url}/get/')
get = r.json()
if get.get('url') == url:
newurl = f'https://archive.softwareheritage.org/browse/origin/{url}/directory/'
else:
newurl = url
with open(f, 'w') as fp:
fp.write(re.sub(r'(Repo|RepoType):.*\n{1,2}', r'', raw))
processed = re.sub(r'(Repo|RepoType):.*\n{1,2}', r'', raw)
processed = re.sub(r'\nSourceCode:.*', f'\nSourceCode: {newurl}', processed)
processed = re.sub(r'\n(AutoUpdateMode|UpdateCheckMode):.*', r'\n\1: None', processed)
fp.write(processed)
builds = data.get('Builds')
if builds:
versionName = str(builds[-1]['versionName'])