Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Add commit link for change log items
Browse files Browse the repository at this point in the history
  • Loading branch information
remyroy committed Dec 17, 2020
1 parent 29af671 commit 991a99b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cddagl/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

NEW_ISSUE_URL = 'https://github.com/remyroy/CDDA-Game-Launcher/issues/new'

CHANGELOG_URL = 'http://gorgon.narc.ro:8080/job/Cataclysm-Matrix/api/xml?tree=builds[number,timestamp,building,result,changeSet[items[msg]],runs[result,fullDisplayName]]&xpath=//build&wrapper=builds'
CHANGELOG_URL = 'http://gorgon.narc.ro:8080/job/Cataclysm-Matrix/api/xml?tree=builds[number,timestamp,building,result,changeSet[items[msg,commitId]],runs[result,fullDisplayName]]&xpath=//build&wrapper=builds'
CDDA_ISSUE_URL_ROOT = 'https://github.com/CleverRaven/Cataclysm-DDA/issues/'
CDDA_COMMIT_URL_ROOT = 'https://github.com/CleverRaven/Cataclysm-DDA/commit/'
CDDAGL_ISSUE_URL_ROOT = 'https://github.com/remyroy/CDDA-Game-Launcher/issues/'

GAME_ISSUE_URL = 'https://cataclysmdda.org/#ive-found-a-bug--i-would-like-to-make-a-suggestion-what-should-i-do'
Expand Down
31 changes: 23 additions & 8 deletions cddagl/ui/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3371,10 +3371,18 @@ def run(self):
build_date_text = format_datetime(build_date_local,
format='long', locale=self.app_locale)

build_changes = build_data.findall(r'.//changeSet/item/msg')
build_changes = map(lambda x: html.escape(x.text.strip() if x.text is not None else '',
True), build_changes)
build_changes = list(unique(build_changes))
build_items = build_data.findall(r'.//changeSet/item')
all_items = []
for build_item in build_items:
msg_node = build_item.find('msg')
commitid_node = build_item.find('commitId')
msg = html.escape(msg_node.text.strip() if msg_node.text is not None else '')
commitid = commitid_node.text.strip() if commitid_node.text is not None else ''
all_items.append({
'msg': msg,
'commitid': commitid
})

build_number = int(build_data.find('number').text)
build_desc = _('Build #{build_number}').format(build_number=build_number)
build_link = f'<a href="{cons.BUILD_CHANGES_URL(build_number)}">{build_desc}</a>'
Expand Down Expand Up @@ -3407,15 +3415,22 @@ def run(self):
)

changelog_html.write('<ul>')
if len(build_changes) < 1:
if len(all_items) < 1:
changelog_html.write(
'<li><span style="color:green">{0}</span></li>'
.format(_('No changes, same code as previous build!')))
else:
for change in build_changes:
commit_name = _('Commit')
for item in all_items:
msg = item['msg']
commitid = item['commitid']
link_repl = rf'<a href="{cons.CDDA_ISSUE_URL_ROOT}\g<id>">#\g<id></a>'
change = id_regex.sub(link_repl, change)
changelog_html.write(f'<li>{change}</li>')
msg = id_regex.sub(link_repl, msg)
if commitid:
commit_url = cons.CDDA_COMMIT_URL_ROOT + commitid
changelog_html.write(f'<li>{msg} [<a href="{commit_url}">{commit_name}</a>]</li>')
else:
changelog_html.write(f'<li>{msg}</li>')
changelog_html.write('</ul>')

self.completed.emit(changelog_html)
Expand Down

0 comments on commit 991a99b

Please sign in to comment.