mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00

Previously PR descriptions were displayed as raw text in the PR dashboard. While not wrong per se, this was pretty ugly and not always convenient as e.g. links had to be copied by hand. Push descriptions through pymarkdown for rendering them, with a few customisations: - Enabled footnotes & tables & fenced code blocks because GFM has that, this doesn't quite put pymarkdown's base behaviour on par with gfm (and py-gfm ultimately gave up on that effort moving to just wrap github's own markdown renderer instead). - Don't allow raw html because too much of a hassle to do it correctly, and very few people ever do it (mostly me I think). - Added a bespoke handler / renderer for github-style references. Note: uses positional captures because it started that way and named captures are not removed from that sequence so mixing and matching is not very useful, plus python does not support identically named groups (even exclusive) so all 4 repo captures and all 3 issue number captures would need different names... - And added a second bespoke handler for our own opw/issue references leading to odoo.com, that's something we can't do via github[^1] so it's a genuine value-add. Fixes #889 [^1]: github can do it (though possibly not with the arbitrary unspecified nonsense I got when I tried to list some of the reference styles, some folks need therapy), but it's not available on our plan
73 lines
3.8 KiB
Python
73 lines
3.8 KiB
Python
from odoo.addons.runbot_merge.models.utils import dfm
|
|
|
|
def test_odoo_links():
|
|
assert dfm("", "OPW-42") == '<p><a href="https://www.odoo.com/web#model=project.task&id=42">opw-42</a></p>'
|
|
assert dfm("", "taskid : 42") == '<p><a href="https://www.odoo.com/web#model=project.task&id=42">task-42</a></p>'
|
|
assert dfm("", "I was doing task foo") == '<p>I was doing task foo</p>'
|
|
assert dfm("", "Task 687d3") == "<p>Task 687d3</p>"
|
|
|
|
def p(*content):
|
|
return f'<p>{"".join(content)}</p>'
|
|
def a(label, url):
|
|
return f'<a href="{url}">{label}</a>'
|
|
def test_gh_issue_links():
|
|
# same-repository link
|
|
assert dfm("odoo/runbot", "thing thing #26") == p("thing thing ", a('#26', 'https://github.com/odoo/runbot/issues/26'))
|
|
assert dfm("odoo/runbot", "GH-26") == p(a('GH-26', 'https://github.com/odoo/runbot/issues/26'))
|
|
assert dfm(
|
|
"odoo/runbot", "https://github.com/odoo/runbot/issues/26"
|
|
) == p(a('#26', 'https://github.com/odoo/runbot/issues/26'))
|
|
|
|
# cross-repo link
|
|
assert dfm(
|
|
"odoo/runbot", "jlord/sheetsee.js#26"
|
|
) == p(a('jlord/sheetsee.js#26', 'https://github.com/jlord/sheetsee.js/issues/26'))
|
|
assert dfm(
|
|
"odoo/runbot", "https://github.com/jlord/sheetsee.js/pull/26"
|
|
) == p(a('jlord/sheetsee.js#26', 'https://github.com/jlord/sheetsee.js/issues/26'))
|
|
|
|
# cross-repo link with comment
|
|
assert dfm(
|
|
"odoo/runbot", "https://github.com/odoo/odoo/pull/173061#issuecomment-2227874482"
|
|
) == p(a("odoo/odoo#173061 (comment)", "https://github.com/odoo/odoo/issues/173061#issuecomment-2227874482"))
|
|
|
|
|
|
def test_gh_commit_link():
|
|
# same repository
|
|
assert dfm(
|
|
"odoo/runbot", "https://github.com/odoo/runbot/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"
|
|
) == p(a("a5c3785ed8d6a35868bc169f07e40e889087fd2e", "https://github.com/odoo/runbot/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"))
|
|
# cross fork
|
|
assert dfm(
|
|
"odoo/runbot", "jlord@a5c3785ed8d6a35868bc169f07e40e889087fd2e"
|
|
) == p(a("jlord@a5c3785ed8d6a35868bc169f07e40e889087fd2e", "https://github.com/jlord/runbot/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"))
|
|
assert dfm(
|
|
"odoo/runbot", "https://github.com/jlord/runbot/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"
|
|
) == p(a("jlord@a5c3785ed8d6a35868bc169f07e40e889087fd2e", "https://github.com/jlord/runbot/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"))
|
|
# cross repo
|
|
assert dfm(
|
|
"odoo/runbot", "jlord/sheetsee.js@a5c3785ed8d6a35868bc169f07e40e889087fd2e"
|
|
) == p(a("jlord/sheetsee.js@a5c3785ed8d6a35868bc169f07e40e889087fd2e", "https://github.com/jlord/sheetsee.js/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"))
|
|
assert dfm(
|
|
"odoo/runbot", "https://github.com/jlord/sheetsee.js/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"
|
|
) == p(a("jlord/sheetsee.js@a5c3785ed8d6a35868bc169f07e40e889087fd2e", "https://github.com/jlord/sheetsee.js/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"))
|
|
|
|
def test_standalone_hash():
|
|
assert dfm(
|
|
"odoo/runbot", "a5c3785ed8d6a35868bc169f07e40e889087fd2e"
|
|
) == p(a("a5c3785ed8d6a35868bc169f07e40e889087fd2e", "https://github.com/odoo/runbot/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e"))
|
|
assert dfm(
|
|
"odoo/runbot", "a5c3785ed8d6a35868bc169f07e4"
|
|
) == p(a("a5c3785ed8d6a35868bc169f07e4", "https://github.com/odoo/runbot/commit/a5c3785ed8d6a35868bc169f07e4"))
|
|
assert dfm(
|
|
"odoo/runbot", "a5c3785"
|
|
) == p(a("a5c3785", "https://github.com/odoo/runbot/commit/a5c3785"))
|
|
assert dfm(
|
|
"odoo/runbot", "a5c378"
|
|
) == p("a5c378")
|
|
|
|
def test_ignore_tel():
|
|
assert dfm("", "[ok](https://github.com)") == p(a("ok", "https://github.com"))
|
|
assert dfm("", "[nope](tel:+1-212-555-0100)") == "<p>nope</p>"
|
|
assert dfm("", "[lol](rdar://10198949)") == "<p>lol</p>"
|