You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/03/05 17:24:40 UTC
[3/5] git commit: [#6301] ticket:536 fixed comment in merge requests
[#6301] ticket:536 fixed comment in merge requests
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/8deb9659
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/8deb9659
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/8deb9659
Branch: refs/heads/master
Commit: 8deb96597e44567a7f6635394ac3036d113a21ed
Parents: 01cb3c6
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Tue Mar 4 02:39:53 2014 +0400
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Mar 5 15:51:21 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/repository.py | 22 +++++++++++++-------
.../templates/repo/merge_request_changed.html | 21 +++++++++++++++++++
.../tests/functional/test_controllers.py | 14 ++++++++-----
3 files changed, 44 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8deb9659/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 7b0afb4..4be5213 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -347,6 +347,7 @@ class MergeRequestController(object):
mr_dispose_form = SCMMergeRequestDisposeWidget()
def __init__(self, num):
+ self.tmpl = g.jinja2_env.get_template('allura:templates/repo/merge_request_changed.html')
self.req = M.MergeRequest.query.get(
app_config_id=c.app.config._id,
request_number=int(num))
@@ -404,26 +405,28 @@ class MergeRequestController(object):
def do_request_merge_edit(self, **kw):
require_access(self.req, 'write')
kw = self.mr_widget_edit.to_python(kw)
- changes = ['Merge request %s has been modified:' % self.req.request_number,
- 'Edited By: %s (%s)' % (c.user.get_pref('display_name'), c.user.username)]
+ changes = dict()
if self.req.summary != kw['summary']:
- changes.append('Summary updated: %r => %r' % (self.req.summary, kw['summary']))
+ changes['Summary'] = [self.req.summary, kw['summary']]
self.req.summary = kw['summary']
if self.req.target_branch != kw['target_branch']:
- changes.append('Target branch updated: %r => %r' % (self.req.target_branch, kw['target_branch']))
+ changes['Target branch'] = [self.req.target_branch, kw['target_branch']]
self.req.target_branch = kw['target_branch']
if self.req.source_branch != kw['source_branch']:
- changes.append('Source branch updated: %r => %r' % (self.req.source_branch, kw['source_branch']))
+ changes['Source branch'] = [self.req.source_branch, kw['source_branch']]
self.req.source_branch = kw['source_branch']
if self.req.description != kw['description']:
- changes.append('Description updated: %r => %r' % (self.req.description, kw['description']))
+ changes['Description'] = [self.req.description, kw['description']]
self.req.description = kw['description']
with self.req.push_downstream_context():
self.req.downstream['commit_id'] = c.app.repo.commit(kw['source_branch'])._id
- self.req.discussion_thread.add_post(text='\n'.join(changes))
+
+ message = self.tmpl.render(changes=changes)
+ self.req.discussion_thread.add_post(text=message, is_meta=True)
+
M.Notification.post(
self.req, 'merge_request',
subject='Merge request: ' + self.req.summary)
@@ -434,7 +437,10 @@ class MergeRequestController(object):
@validate(mr_dispose_form)
def save(self, status=None, **kw):
require_access(self.req, 'write')
- self.req.status = status
+ if self.req.status != status:
+ message = self.tmpl.render(changes={'Status': [self.req.status, status]})
+ self.req.discussion_thread.add_post(text=message, is_meta=True)
+ self.req.status = status
redirect('.')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8deb9659/Allura/allura/templates/repo/merge_request_changed.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request_changed.html b/Allura/allura/templates/repo/merge_request_changed.html
new file mode 100644
index 0000000..1c278e6
--- /dev/null
+++ b/Allura/allura/templates/repo/merge_request_changed.html
@@ -0,0 +1,21 @@
+{#-
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-#}
+{% for field, values in changes.iteritems() %}
+- **{{ field }}**: {{ values[0] }} --> {{ values[1] }}
+{% endfor %}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8deb9659/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index ae7c31e..90230b5 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -631,11 +631,15 @@ class TestFork(_TestCase):
assert '[5c4724]' not in r
assert '<p>changed description</p' in r
assert 'Merge Request #1: changed summary (open)' in r
- assert '''<p>Merge request 1 has been modified:<br />
-Edited By: Test Admin (test-admin)<br />
-Summary updated: u'summary' => u'changed summary'<br />
-Source branch updated: u'zz' => u'master'<br />
-Description updated: u'description' => u'changed description'</p>''' in r
+ assert '''<li>
+<p><strong>Source branch</strong>: zz --> master</p>
+</li>
+<li>
+<p><strong>Description</strong>: description --> changed description</p>
+</li>
+<li>
+<p><strong>Summary</strong>: summary --> changed summary</p>
+</li>''' in r
r = self.app.get('/p/test/src-git/merge-requests')
assert '<a href="1/">changed summary</a>' in r