You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2017/09/26 18:39:30 UTC

[3/3] allura git commit: [#8164] creator of merge requests gets subscribed to it

[#8164] creator of merge requests gets subscribed to it


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/63070c1c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/63070c1c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/63070c1c

Branch: refs/heads/db/8164
Commit: 63070c1cf2adacb048c69025db11d2dfedee8899
Parents: 17d8729
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Sep 26 12:22:28 2017 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Sep 26 14:37:18 2017 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         |  1 +
 Allura/allura/templates/mail/MergeRequest.txt   |  2 +-
 .../032-subscribe-merge-request-submitters.py   | 40 ++++++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/63070c1c/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 8a02905..7b4c703 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -197,6 +197,7 @@ class RepoRootController(BaseController, FeedController):
                 source_branch=kw['source_branch'],
                 summary=kw['summary'],
                 description=kw['description'])
+            mr.subscribe(user=c.user)
             M.Notification.post(
                 mr, 'merge_request',
                 subject='Merge request: ' + mr.summary)

http://git-wip-us.apache.org/repos/asf/allura/blob/63070c1c/Allura/allura/templates/mail/MergeRequest.txt
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/mail/MergeRequest.txt b/Allura/allura/templates/mail/MergeRequest.txt
index 34d0af5..3302aba 100644
--- a/Allura/allura/templates/mail/MergeRequest.txt
+++ b/Allura/allura/templates/mail/MergeRequest.txt
@@ -20,6 +20,6 @@
 
 ---
 
-{{ data.creator_name }} has requested that you merge changes from `{{ data.downstream_repo.clone_url_first(anon=False) }}` at commit `{{data.downstream_repo.shorthand_for_commit(data.downstream.commit_id)}}` into the branch `{{ data.target_branch }}`
+{{ data.creator_name }} has requested to merge changes from `{{ data.downstream_repo.clone_url_first(anon=False) }}` at commit `{{data.downstream_repo.shorthand_for_commit(data.downstream.commit_id)}}` into the branch `{{ data.target_branch }}`
 
 {{ data.description }}

http://git-wip-us.apache.org/repos/asf/allura/blob/63070c1c/scripts/migrations/032-subscribe-merge-request-submitters.py
----------------------------------------------------------------------
diff --git a/scripts/migrations/032-subscribe-merge-request-submitters.py b/scripts/migrations/032-subscribe-merge-request-submitters.py
new file mode 100644
index 0000000..3791dd7
--- /dev/null
+++ b/scripts/migrations/032-subscribe-merge-request-submitters.py
@@ -0,0 +1,40 @@
+#       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.
+
+import logging
+
+from ming.odm import ThreadLocalORMSession, state
+
+from allura.lib import utils
+from allura import model as M
+
+log = logging.getLogger(__name__)
+
+
+def main():
+    for chunk in utils.chunked_find(M.MergeRequest):
+        for mr in chunk:
+            try:
+                print 'Processing {0}'.format(mr.url())
+                mr.subscribe(user=mr.creator)
+                ThreadLocalORMSession.flush_all()
+            except:
+                log.exception('Error on %s', mr)
+
+
+if __name__ == '__main__':
+    main()