Overhaul project changelog links for upgrade pkg diff table
This commit is contained in:
parent
fdcf23f65f
commit
1283a794df
|
@ -288,30 +288,62 @@ class UpgradeView(MasterView):
|
||||||
|
|
||||||
commit_hash_pattern = re.compile(r'^.{40}$')
|
commit_hash_pattern = re.compile(r'^.{40}$')
|
||||||
|
|
||||||
def get_changelog_url(self, project, old_version, new_version):
|
def get_changelog_projects(self):
|
||||||
projects = {
|
projects = {
|
||||||
'rattail': 'rattail',
|
'rattail': {
|
||||||
'Tailbone': 'tailbone',
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-project/rattail/changelog/{new_version}/?size=10',
|
||||||
'pyCatapult': 'pycatapult',
|
'release_url': 'https://kallithea.rattailproject.org/rattail-project/rattail/files/{new_version}/CHANGES.rst',
|
||||||
'rattail-catapult': 'rattail-catapult',
|
},
|
||||||
'rattail-tempmon': 'rattail-tempmon',
|
'Tailbone': {
|
||||||
'tailbone-catapult': 'tailbone-catapult',
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-project/tailbone/changelog/{new_version}/?size=10',
|
||||||
|
'release_url': 'https://kallithea.rattailproject.org/rattail-project/tailbone/files/{new_version}/CHANGES.rst',
|
||||||
|
},
|
||||||
|
'pyCOREPOS': {
|
||||||
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-project/pycorepos/changelog/{new_version}/?size=10',
|
||||||
|
'release_url': 'https://kallithea.rattailproject.org/rattail-project/pycorepos/files/{new_version}/CHANGES.rst',
|
||||||
|
},
|
||||||
|
'rattail_corepos': {
|
||||||
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-project/rattail-corepos/changelog/{new_version}/?size=10',
|
||||||
|
'release_url': 'https://kallithea.rattailproject.org/rattail-project/rattail-corepos/files/{new_version}/CHANGES.rst',
|
||||||
|
},
|
||||||
|
'tailbone_corepos': {
|
||||||
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-project/tailbone-corepos/changelog/{new_version}/?size=10',
|
||||||
|
'release_url': 'https://kallithea.rattailproject.org/rattail-project/tailbone-corepos/files/{new_version}/CHANGES.rst',
|
||||||
|
},
|
||||||
|
'onager': {
|
||||||
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-restricted/onager/changelog/{new_version}/?size=10',
|
||||||
|
'release_url': 'https://kallithea.rattailproject.org/rattail-restricted/onager/files/{new_version}/CHANGES.rst',
|
||||||
|
},
|
||||||
|
'rattail-onager': {
|
||||||
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-restricted/rattail-onager/changelog/{new_version}/?size=10',
|
||||||
|
'release_url': 'https://kallithea.rattailproject.org/rattail-restricted/rattail-onager/files/{new_version}/CHANGELOG.md',
|
||||||
|
},
|
||||||
|
'rattail_tempmon': {
|
||||||
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-project/rattail-tempmon/changelog/{new_version}/?size=10',
|
||||||
|
'release_url': 'https://kallithea.rattailproject.org/rattail-project/rattail-tempmon/files/{new_version}/CHANGES.rst',
|
||||||
|
},
|
||||||
|
'tailbone-onager': {
|
||||||
|
'commit_url': 'https://kallithea.rattailproject.org/rattail-restricted/tailbone-onager/changelog/{new_version}/?size=10',
|
||||||
|
'release_url': 'https://kallithea.rattailproject.org/rattail-restricted/tailbone-onager/files/{new_version}/CHANGELOG.md',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
if project not in projects:
|
return projects
|
||||||
|
|
||||||
|
def get_changelog_url(self, project, old_version, new_version):
|
||||||
|
projects = self.get_changelog_projects()
|
||||||
|
|
||||||
|
project_name = project
|
||||||
|
if project_name not in projects:
|
||||||
|
# cannot generate a changelog URL for unknown project
|
||||||
return
|
return
|
||||||
|
|
||||||
|
project = projects[project_name]
|
||||||
|
|
||||||
if self.commit_hash_pattern.match(new_version):
|
if self.commit_hash_pattern.match(new_version):
|
||||||
if new_version == old_version:
|
return project['commit_url'].format(new_version=new_version, old_version=old_version)
|
||||||
return 'https://rattailproject.org/trac/log/{}/?rev={}&limit=100'.format(
|
|
||||||
projects[project], new_version)
|
|
||||||
else:
|
|
||||||
return 'https://rattailproject.org/trac/log/{}/?rev={}&stop_rev={}&limit=100'.format(
|
|
||||||
projects[project], new_version, old_version)
|
|
||||||
elif re.match(r'^\d+\.\d+\.\d+$', new_version):
|
elif re.match(r'^\d+\.\d+\.\d+$', new_version):
|
||||||
return 'https://rattailproject.org/trac/browser/{}/CHANGES.rst?rev=v{}'.format(
|
return project['release_url'].format(new_version=new_version, old_version=old_version)
|
||||||
projects[project], new_version)
|
|
||||||
else:
|
|
||||||
return 'https://rattailproject.org/trac/browser/{}/CHANGES.rst'.format(
|
|
||||||
projects[project])
|
|
||||||
|
|
||||||
def render_diff_field(self, field, diff):
|
def render_diff_field(self, field, diff):
|
||||||
old_version = diff.old_value(field)
|
old_version = diff.old_value(field)
|
||||||
|
|
Loading…
Reference in a new issue