Skip to content

Commit

Permalink
Fix links to ChangeLog and upgrade guidelines for projects other than…
Browse files Browse the repository at this point in the history
… "weechat"
  • Loading branch information
flashcode committed Jun 1, 2024
1 parent 61b9426 commit bd54a9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 10 additions & 5 deletions weechat/common/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from weechat.common.path import project_path_join


GITHUB_REPO = 'https://github.com/weechat/weechat'
GITHUB_LINK_ISSUE = f'{GITHUB_REPO}/issues/%s'
GITHUB_REPO = 'https://github.com/weechat/%(project)s'
GITHUB_LINK_ISSUE = f'{GITHUB_REPO}/issues/%(issue)s'
GITHUB_ISSUE_PATTERN = re.compile(r'(issue|close|closes|closed|fix|fixes|fixed|'
'resolve|resolves|resolved) #([0-9]+)')
GITHUB_LINK_FILE = f'{GITHUB_REPO}/blob/%(ref)s/%(filename)s'
Expand All @@ -45,7 +45,10 @@
def _replace_github_link(match):
"""Replace a match of GitHub keyword (like "closes #123") by URL."""
name = match.group(0)
url = GITHUB_LINK_ISSUE % match.group(2)
url = GITHUB_LINK_ISSUE % {
'project': 'weechat',
'issue': match.group(2),
}
return f'<a href="{url}">{name}</a>'


Expand Down Expand Up @@ -125,16 +128,18 @@ def commits_links(commits):
return mark_safe(' '.join(images))


def repo_link_file(filename, ref='master'):
def repo_link_file(project, ref, filename):
"""Return link to a file in a given version on GitHub."""
return GITHUB_LINK_FILE % {
'project': project,
'ref': ref,
'filename': filename,
}


def repo_link_release(version):
def repo_link_release(project, version):
"""Return link to a release on GitHub."""
return GITHUB_LINK_RELEASE % {
'project': project,
'version': version,
}
8 changes: 4 additions & 4 deletions weechat/download/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def changelog_url(self):
version = self.description if self.version == 'stable' else self.version
if version == 'devel':
# devel version: link to CHANGELOG.md
return repo_link_file('CHANGELOG.md')
return repo_link_file(self.project.name, 'master', 'CHANGELOG.md')
if version_to_list(version) >= [4, 0]:
# version ≥ 4.0.0: link to release on GitHub
return repo_link_release(version)
return repo_link_release(self.project.name, version)
# version < 4.0.0: link to ChangeLog-x.y.z.html
filename = f'ChangeLog-{version}.html'
return f'/files/doc/{self.project.name}/{filename}'
Expand All @@ -96,10 +96,10 @@ def upgrading_url(self):
version = self.description if self.version == 'stable' else self.version
if version == 'devel':
# devel version: link to UPGRADING.md
return repo_link_file('UPGRADING.md')
return repo_link_file(self.project.name, 'master', 'UPGRADING.md')
if version_to_list(version) >= [4, 4]:
# version ≥ 4.4.0: link to UPGRADING.md of this version
return repo_link_file('UPGRADING.md', ref=f'v{version}')
return repo_link_file(self.project.name, f'v{version}', 'UPGRADING.md')
# version < 4.4.0: link to ReleaseNotes-x.y.z.html
filename = f'ReleaseNotes-{version}.html'
return f'/files/doc/{self.project.name}/{filename}'
Expand Down

0 comments on commit bd54a9a

Please sign in to comment.