Set change url to gitweb URL.
So that status pages can easily link to gitweb urls of ref-update
triggered changes.
Change-Id: Id9b708a473d92c30727f66578a0174f18c657723
Reviewed-on: https://review.openstack.org/18602
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
diff --git a/zuul/model.py b/zuul/model.py
index aa55561..2b5f5b3 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -247,6 +247,8 @@
ret = {}
if hasattr(changeish, 'url') and changeish.url is not None:
ret['url'] = changeish.url
+ else:
+ ret['url'] = None
ret['id'] = changeish._id()
ret['project'] = changeish.project.name
ret['jobs'] = []
@@ -607,6 +609,7 @@
change.ref = self.ref
change.oldrev = self.oldrev
change.newrev = self.newrev
+ change.url = trigger.getGitwebUrl(project, sha=self.newrev)
return change
diff --git a/zuul/trigger/gerrit.py b/zuul/trigger/gerrit.py
index 892eb36..d57c201 100644
--- a/zuul/trigger/gerrit.py
+++ b/zuul/trigger/gerrit.py
@@ -342,3 +342,9 @@
port = 29418
url = 'ssh://%s@%s:%s/%s' % (user, server, port, project.name)
return url
+
+ def getGitwebUrl(self, project, sha=None):
+ url = '%s/gitweb?p=%s.git' % (self.baseurl, project)
+ if sha:
+ url += ';a=commitdiff;h=' + sha
+ return url