Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/68135
Change subject: morebots: auto-link SHA1s and Gerrit change IDs
......................................................................
morebots: auto-link SHA1s and Gerrit change IDs
This change will cause morebots to wrap full and partial SHA1s and Gerrit
change IDs with {{Gerrit|}} when logging to MediaWiki.
Bug: 35876
Change-Id: I0a7ca5450f9f74ebd36fb47f8e30d2fc8135df97
---
M adminlog.py
1 file changed, 8 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/debs/adminbot
refs/changes/35/68135/1
diff --git a/adminlog.py b/adminlog.py
index 0aa85f5..4e16cf6 100644
--- a/adminlog.py
+++ b/adminlog.py
@@ -1,9 +1,14 @@
import mwclient
import datetime
+import re
months = ["January", "February", "March", "April", "May", "June", "July",
"August", "September",
"October", "November", "December"]
+
+# Matches full and partial SHA1s, provided they contain at least one digit and
+# do not start with 'dbN' (to avoid matching 'db1047').
+sha1_re = re.compile(r'\b(?!db\d)[A-F0-9]+[0-9]+[A-F0-9]+\b', re.I | re.M)
def log(config, message, project, author):
@@ -26,7 +31,9 @@
position = 0
# Um, check the date
now = datetime.datetime.utcnow()
- logline = "* %02d:%02d %s: %s" % (now.hour, now.minute, author, message)
+ wikitext_message = sha1_re.sub(r'{{Gerrit|\g<0>}}', message)
+ logline = "* %02d:%02d %s: %s" % (now.hour, now.minute, author,
+ wikitext_message)
month = str(now.month)
day = str(now.day)
# Try extracting latest date header
--
To view, visit https://gerrit.wikimedia.org/r/68135
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a7ca5450f9f74ebd36fb47f8e30d2fc8135df97
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/adminbot
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits