integrations/perforce: Display changelist ID as a p4web link.
The general regex-based linkify in zulip does not allow '@' as the prefix. In any case we know here that it is definitely a changelist number, which is better. Adding P4_WEB="https://p4web.example.com" to the config will enable this behaviour. If P4_WEB is absent from the config, or has the value None, no link is inserted.
This commit is contained in:
parent
680f453834
commit
99b87dd78d
|
@ -76,6 +76,15 @@ if destination is None:
|
||||||
# Don't forward the notice anywhere
|
# Don't forward the notice anywhere
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
change = metadata["change"]
|
||||||
|
p4web = None
|
||||||
|
if hasattr(config, "P4_WEB"):
|
||||||
|
p4web = config.P4_WEB
|
||||||
|
|
||||||
|
if p4web is not None:
|
||||||
|
# linkify the change number
|
||||||
|
change = '[{change}]({p4web}/{change}?ac=10)'.format(p4web=p4web, change=change)
|
||||||
|
|
||||||
message = """**{user}** committed revision @{change} to `{path}`.
|
message = """**{user}** committed revision @{change} to `{path}`.
|
||||||
|
|
||||||
```quote
|
```quote
|
||||||
|
@ -83,7 +92,7 @@ message = """**{user}** committed revision @{change} to `{path}`.
|
||||||
```
|
```
|
||||||
""".format(
|
""".format(
|
||||||
user=metadata["user"],
|
user=metadata["user"],
|
||||||
change=metadata["change"],
|
change=change,
|
||||||
path=changeroot,
|
path=changeroot,
|
||||||
desc=metadata["desc"]) # type: str
|
desc=metadata["desc"]) # type: str
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ ZULIP_USER = "p4-bot@example.com"
|
||||||
ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
|
ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
|
||||||
ZULIP_SITE = "https://zulip.example.com"
|
ZULIP_SITE = "https://zulip.example.com"
|
||||||
|
|
||||||
|
# Set this to point at a p4web installation to get changelist IDs as links
|
||||||
|
# P4_WEB = "https://p4web.example.com"
|
||||||
|
P4_WEB = None
|
||||||
|
|
||||||
# commit_notice_destination() lets you customize where commit notices
|
# commit_notice_destination() lets you customize where commit notices
|
||||||
# are sent to with the full power of a Python function.
|
# are sent to with the full power of a Python function.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue