-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4256 from Holzhaus/changelog-missing-links
Changelog: Add missing links
- Loading branch information
Showing
3 changed files
with
110 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import pathlib | ||
import re | ||
|
||
|
||
def add_missing_links(changelog): | ||
"""Ensure that all the changelog conforms to our common format.""" | ||
# Ensure that all launchpad issues are hyperlinks | ||
changelog = re.sub( | ||
r"(?!\[)\blp:?(?P<lpid>\d+)\b(?!\])", | ||
r"[lp:\g<lpid>](https://bugs.launchpad.net/mixxx/+bug/\g<lpid>)", | ||
changelog, | ||
) | ||
|
||
# Ensure that all GitHub PRs are hyperlinks | ||
changelog = re.sub( | ||
r"(?!\[)#\b(?P<ghid>\d+)\b(?!\])", | ||
r"[#\g<ghid>](https://github.com/mixxxdj/mixxx/pull/\g<ghid>)", | ||
changelog, | ||
) | ||
|
||
return changelog | ||
|
||
|
||
def main(argv=None): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("file", type=pathlib.Path) | ||
args = parser.parse_args(argv) | ||
|
||
# Fetch changelog and convert to RST | ||
with args.file.open("r") as fp: | ||
changelog = fp.read() | ||
|
||
fixed_changelog = add_missing_links(changelog) | ||
if changelog != fixed_changelog: | ||
with args.file.open("w") as fp: | ||
fp.write(fixed_changelog) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |