1
0
Fork 0
mirror of https://github.com/Findus23/new-github-changelog-generator.git synced 2024-08-27 19:52:18 +02:00

add debian changelog output

This commit is contained in:
Lukas Winkler 2019-02-03 19:36:40 +01:00
parent 9803536bbe
commit a364cb6e00
4 changed files with 29 additions and 2 deletions

View file

@ -24,6 +24,8 @@ def main():
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--html', action='store_const', const="html", dest="output", help="output as HTML")
group.add_argument('--markdown', action='store_const', const="markdown", dest="output", help="output as markdown")
group.add_argument('--debian-changelog', action='store_const', const="debianchangelog", dest="output",
help="output as debian changelog file")
args = parser.parse_args()
generate_changelog(args.since, args.output,args.previous_version)
generate_changelog(args.since, args.output, args.previous_version)

View file

@ -1,3 +1,4 @@
from .base import BaseFormatter
from .debianchangelog import DebianChangelogFormatter
from .html import HTMLFormatter
from .markdown import MarkdownFormatter

View file

@ -0,0 +1,22 @@
import textwrap
from generator.formatters import BaseFormatter
class DebianChangelogFormatter(BaseFormatter):
def __str__(self) -> str:
text = ""
for repo in self.repos:
if repo.issues:
if len(self.repos) > 1:
text += "\n [ {} ]\n".format(repo.path)
for issue in repo.issues:
line = ""
line += " * {title}".format(title=issue.title)
if issue.authors:
line += " [by {}] ".format(
", ".join("@" + author.username for author in issue.authors)
)
line += "(Closes: #{})\n".format(issue.number)
text += textwrap.fill(line, 75, subsequent_indent=" " * 4) + "\n"
return text

View file

@ -2,7 +2,7 @@ from datetime import datetime
from typing import List
from generator import GithubAPI, config, Issue, Repo
from generator.formatters import HTMLFormatter, MarkdownFormatter
from generator.formatters import HTMLFormatter, MarkdownFormatter, DebianChangelogFormatter
api = GithubAPI(token=config.api_token)
@ -63,6 +63,8 @@ def generate_changelog(since: datetime, output_format, previous_version):
print(HTMLFormatter(repos))
elif output_format == "markdown":
print(MarkdownFormatter(repos))
elif output_format == "debianchangelog":
print(DebianChangelogFormatter(repos))
else:
raise ValueError()
generate_statistics(repos)