##// END OF EJS Templates
pull-requests: use merge info to show how Pull requests will be merged....
marcink -
r2053:bad6294f default
parent child Browse files
Show More
@@ -1,1191 +1,1193 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2011-2017 RhodeCode GmbH
3 # Copyright (C) 2011-2017 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import logging
22 import collections
22 import collections
23
23
24 import formencode
24 import formencode
25 import peppercorn
25 import peppercorn
26 from pyramid.httpexceptions import (
26 from pyramid.httpexceptions import (
27 HTTPFound, HTTPNotFound, HTTPForbidden, HTTPBadRequest)
27 HTTPFound, HTTPNotFound, HTTPForbidden, HTTPBadRequest)
28 from pyramid.view import view_config
28 from pyramid.view import view_config
29 from pyramid.renderers import render
29 from pyramid.renderers import render
30
30
31 from rhodecode import events
31 from rhodecode import events
32 from rhodecode.apps._base import RepoAppView, DataGridAppView
32 from rhodecode.apps._base import RepoAppView, DataGridAppView
33
33
34 from rhodecode.lib import helpers as h, diffs, codeblocks, channelstream
34 from rhodecode.lib import helpers as h, diffs, codeblocks, channelstream
35 from rhodecode.lib.base import vcs_operation_context
35 from rhodecode.lib.base import vcs_operation_context
36 from rhodecode.lib.ext_json import json
36 from rhodecode.lib.ext_json import json
37 from rhodecode.lib.auth import (
37 from rhodecode.lib.auth import (
38 LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous, CSRFRequired)
38 LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous, CSRFRequired)
39 from rhodecode.lib.utils2 import str2bool, safe_str, safe_unicode
39 from rhodecode.lib.utils2 import str2bool, safe_str, safe_unicode
40 from rhodecode.lib.vcs.backends.base import EmptyCommit, UpdateFailureReason
40 from rhodecode.lib.vcs.backends.base import EmptyCommit, UpdateFailureReason
41 from rhodecode.lib.vcs.exceptions import (CommitDoesNotExistError,
41 from rhodecode.lib.vcs.exceptions import (CommitDoesNotExistError,
42 RepositoryRequirementError, NodeDoesNotExistError, EmptyRepositoryError)
42 RepositoryRequirementError, NodeDoesNotExistError, EmptyRepositoryError)
43 from rhodecode.model.changeset_status import ChangesetStatusModel
43 from rhodecode.model.changeset_status import ChangesetStatusModel
44 from rhodecode.model.comment import CommentsModel
44 from rhodecode.model.comment import CommentsModel
45 from rhodecode.model.db import (func, or_, PullRequest, PullRequestVersion,
45 from rhodecode.model.db import (func, or_, PullRequest, PullRequestVersion,
46 ChangesetComment, ChangesetStatus, Repository)
46 ChangesetComment, ChangesetStatus, Repository)
47 from rhodecode.model.forms import PullRequestForm
47 from rhodecode.model.forms import PullRequestForm
48 from rhodecode.model.meta import Session
48 from rhodecode.model.meta import Session
49 from rhodecode.model.pull_request import PullRequestModel, MergeCheck
49 from rhodecode.model.pull_request import PullRequestModel, MergeCheck
50 from rhodecode.model.scm import ScmModel
50 from rhodecode.model.scm import ScmModel
51
51
52 log = logging.getLogger(__name__)
52 log = logging.getLogger(__name__)
53
53
54
54
55 class RepoPullRequestsView(RepoAppView, DataGridAppView):
55 class RepoPullRequestsView(RepoAppView, DataGridAppView):
56
56
57 def load_default_context(self):
57 def load_default_context(self):
58 c = self._get_local_tmpl_context(include_app_defaults=True)
58 c = self._get_local_tmpl_context(include_app_defaults=True)
59 # TODO(marcink): remove repo_info and use c.rhodecode_db_repo instead
59 # TODO(marcink): remove repo_info and use c.rhodecode_db_repo instead
60 c.repo_info = self.db_repo
60 c.repo_info = self.db_repo
61 c.REVIEW_STATUS_APPROVED = ChangesetStatus.STATUS_APPROVED
61 c.REVIEW_STATUS_APPROVED = ChangesetStatus.STATUS_APPROVED
62 c.REVIEW_STATUS_REJECTED = ChangesetStatus.STATUS_REJECTED
62 c.REVIEW_STATUS_REJECTED = ChangesetStatus.STATUS_REJECTED
63 self._register_global_c(c)
63 self._register_global_c(c)
64 return c
64 return c
65
65
66 def _get_pull_requests_list(
66 def _get_pull_requests_list(
67 self, repo_name, source, filter_type, opened_by, statuses):
67 self, repo_name, source, filter_type, opened_by, statuses):
68
68
69 draw, start, limit = self._extract_chunk(self.request)
69 draw, start, limit = self._extract_chunk(self.request)
70 search_q, order_by, order_dir = self._extract_ordering(self.request)
70 search_q, order_by, order_dir = self._extract_ordering(self.request)
71 _render = self.request.get_partial_renderer(
71 _render = self.request.get_partial_renderer(
72 'data_table/_dt_elements.mako')
72 'data_table/_dt_elements.mako')
73
73
74 # pagination
74 # pagination
75
75
76 if filter_type == 'awaiting_review':
76 if filter_type == 'awaiting_review':
77 pull_requests = PullRequestModel().get_awaiting_review(
77 pull_requests = PullRequestModel().get_awaiting_review(
78 repo_name, source=source, opened_by=opened_by,
78 repo_name, source=source, opened_by=opened_by,
79 statuses=statuses, offset=start, length=limit,
79 statuses=statuses, offset=start, length=limit,
80 order_by=order_by, order_dir=order_dir)
80 order_by=order_by, order_dir=order_dir)
81 pull_requests_total_count = PullRequestModel().count_awaiting_review(
81 pull_requests_total_count = PullRequestModel().count_awaiting_review(
82 repo_name, source=source, statuses=statuses,
82 repo_name, source=source, statuses=statuses,
83 opened_by=opened_by)
83 opened_by=opened_by)
84 elif filter_type == 'awaiting_my_review':
84 elif filter_type == 'awaiting_my_review':
85 pull_requests = PullRequestModel().get_awaiting_my_review(
85 pull_requests = PullRequestModel().get_awaiting_my_review(
86 repo_name, source=source, opened_by=opened_by,
86 repo_name, source=source, opened_by=opened_by,
87 user_id=self._rhodecode_user.user_id, statuses=statuses,
87 user_id=self._rhodecode_user.user_id, statuses=statuses,
88 offset=start, length=limit, order_by=order_by,
88 offset=start, length=limit, order_by=order_by,
89 order_dir=order_dir)
89 order_dir=order_dir)
90 pull_requests_total_count = PullRequestModel().count_awaiting_my_review(
90 pull_requests_total_count = PullRequestModel().count_awaiting_my_review(
91 repo_name, source=source, user_id=self._rhodecode_user.user_id,
91 repo_name, source=source, user_id=self._rhodecode_user.user_id,
92 statuses=statuses, opened_by=opened_by)
92 statuses=statuses, opened_by=opened_by)
93 else:
93 else:
94 pull_requests = PullRequestModel().get_all(
94 pull_requests = PullRequestModel().get_all(
95 repo_name, source=source, opened_by=opened_by,
95 repo_name, source=source, opened_by=opened_by,
96 statuses=statuses, offset=start, length=limit,
96 statuses=statuses, offset=start, length=limit,
97 order_by=order_by, order_dir=order_dir)
97 order_by=order_by, order_dir=order_dir)
98 pull_requests_total_count = PullRequestModel().count_all(
98 pull_requests_total_count = PullRequestModel().count_all(
99 repo_name, source=source, statuses=statuses,
99 repo_name, source=source, statuses=statuses,
100 opened_by=opened_by)
100 opened_by=opened_by)
101
101
102 data = []
102 data = []
103 comments_model = CommentsModel()
103 comments_model = CommentsModel()
104 for pr in pull_requests:
104 for pr in pull_requests:
105 comments = comments_model.get_all_comments(
105 comments = comments_model.get_all_comments(
106 self.db_repo.repo_id, pull_request=pr)
106 self.db_repo.repo_id, pull_request=pr)
107
107
108 data.append({
108 data.append({
109 'name': _render('pullrequest_name',
109 'name': _render('pullrequest_name',
110 pr.pull_request_id, pr.target_repo.repo_name),
110 pr.pull_request_id, pr.target_repo.repo_name),
111 'name_raw': pr.pull_request_id,
111 'name_raw': pr.pull_request_id,
112 'status': _render('pullrequest_status',
112 'status': _render('pullrequest_status',
113 pr.calculated_review_status()),
113 pr.calculated_review_status()),
114 'title': _render(
114 'title': _render(
115 'pullrequest_title', pr.title, pr.description),
115 'pullrequest_title', pr.title, pr.description),
116 'description': h.escape(pr.description),
116 'description': h.escape(pr.description),
117 'updated_on': _render('pullrequest_updated_on',
117 'updated_on': _render('pullrequest_updated_on',
118 h.datetime_to_time(pr.updated_on)),
118 h.datetime_to_time(pr.updated_on)),
119 'updated_on_raw': h.datetime_to_time(pr.updated_on),
119 'updated_on_raw': h.datetime_to_time(pr.updated_on),
120 'created_on': _render('pullrequest_updated_on',
120 'created_on': _render('pullrequest_updated_on',
121 h.datetime_to_time(pr.created_on)),
121 h.datetime_to_time(pr.created_on)),
122 'created_on_raw': h.datetime_to_time(pr.created_on),
122 'created_on_raw': h.datetime_to_time(pr.created_on),
123 'author': _render('pullrequest_author',
123 'author': _render('pullrequest_author',
124 pr.author.full_contact, ),
124 pr.author.full_contact, ),
125 'author_raw': pr.author.full_name,
125 'author_raw': pr.author.full_name,
126 'comments': _render('pullrequest_comments', len(comments)),
126 'comments': _render('pullrequest_comments', len(comments)),
127 'comments_raw': len(comments),
127 'comments_raw': len(comments),
128 'closed': pr.is_closed(),
128 'closed': pr.is_closed(),
129 })
129 })
130
130
131 data = ({
131 data = ({
132 'draw': draw,
132 'draw': draw,
133 'data': data,
133 'data': data,
134 'recordsTotal': pull_requests_total_count,
134 'recordsTotal': pull_requests_total_count,
135 'recordsFiltered': pull_requests_total_count,
135 'recordsFiltered': pull_requests_total_count,
136 })
136 })
137 return data
137 return data
138
138
139 @LoginRequired()
139 @LoginRequired()
140 @HasRepoPermissionAnyDecorator(
140 @HasRepoPermissionAnyDecorator(
141 'repository.read', 'repository.write', 'repository.admin')
141 'repository.read', 'repository.write', 'repository.admin')
142 @view_config(
142 @view_config(
143 route_name='pullrequest_show_all', request_method='GET',
143 route_name='pullrequest_show_all', request_method='GET',
144 renderer='rhodecode:templates/pullrequests/pullrequests.mako')
144 renderer='rhodecode:templates/pullrequests/pullrequests.mako')
145 def pull_request_list(self):
145 def pull_request_list(self):
146 c = self.load_default_context()
146 c = self.load_default_context()
147
147
148 req_get = self.request.GET
148 req_get = self.request.GET
149 c.source = str2bool(req_get.get('source'))
149 c.source = str2bool(req_get.get('source'))
150 c.closed = str2bool(req_get.get('closed'))
150 c.closed = str2bool(req_get.get('closed'))
151 c.my = str2bool(req_get.get('my'))
151 c.my = str2bool(req_get.get('my'))
152 c.awaiting_review = str2bool(req_get.get('awaiting_review'))
152 c.awaiting_review = str2bool(req_get.get('awaiting_review'))
153 c.awaiting_my_review = str2bool(req_get.get('awaiting_my_review'))
153 c.awaiting_my_review = str2bool(req_get.get('awaiting_my_review'))
154
154
155 c.active = 'open'
155 c.active = 'open'
156 if c.my:
156 if c.my:
157 c.active = 'my'
157 c.active = 'my'
158 if c.closed:
158 if c.closed:
159 c.active = 'closed'
159 c.active = 'closed'
160 if c.awaiting_review and not c.source:
160 if c.awaiting_review and not c.source:
161 c.active = 'awaiting'
161 c.active = 'awaiting'
162 if c.source and not c.awaiting_review:
162 if c.source and not c.awaiting_review:
163 c.active = 'source'
163 c.active = 'source'
164 if c.awaiting_my_review:
164 if c.awaiting_my_review:
165 c.active = 'awaiting_my'
165 c.active = 'awaiting_my'
166
166
167 return self._get_template_context(c)
167 return self._get_template_context(c)
168
168
169 @LoginRequired()
169 @LoginRequired()
170 @HasRepoPermissionAnyDecorator(
170 @HasRepoPermissionAnyDecorator(
171 'repository.read', 'repository.write', 'repository.admin')
171 'repository.read', 'repository.write', 'repository.admin')
172 @view_config(
172 @view_config(
173 route_name='pullrequest_show_all_data', request_method='GET',
173 route_name='pullrequest_show_all_data', request_method='GET',
174 renderer='json_ext', xhr=True)
174 renderer='json_ext', xhr=True)
175 def pull_request_list_data(self):
175 def pull_request_list_data(self):
176
176
177 # additional filters
177 # additional filters
178 req_get = self.request.GET
178 req_get = self.request.GET
179 source = str2bool(req_get.get('source'))
179 source = str2bool(req_get.get('source'))
180 closed = str2bool(req_get.get('closed'))
180 closed = str2bool(req_get.get('closed'))
181 my = str2bool(req_get.get('my'))
181 my = str2bool(req_get.get('my'))
182 awaiting_review = str2bool(req_get.get('awaiting_review'))
182 awaiting_review = str2bool(req_get.get('awaiting_review'))
183 awaiting_my_review = str2bool(req_get.get('awaiting_my_review'))
183 awaiting_my_review = str2bool(req_get.get('awaiting_my_review'))
184
184
185 filter_type = 'awaiting_review' if awaiting_review \
185 filter_type = 'awaiting_review' if awaiting_review \
186 else 'awaiting_my_review' if awaiting_my_review \
186 else 'awaiting_my_review' if awaiting_my_review \
187 else None
187 else None
188
188
189 opened_by = None
189 opened_by = None
190 if my:
190 if my:
191 opened_by = [self._rhodecode_user.user_id]
191 opened_by = [self._rhodecode_user.user_id]
192
192
193 statuses = [PullRequest.STATUS_NEW, PullRequest.STATUS_OPEN]
193 statuses = [PullRequest.STATUS_NEW, PullRequest.STATUS_OPEN]
194 if closed:
194 if closed:
195 statuses = [PullRequest.STATUS_CLOSED]
195 statuses = [PullRequest.STATUS_CLOSED]
196
196
197 data = self._get_pull_requests_list(
197 data = self._get_pull_requests_list(
198 repo_name=self.db_repo_name, source=source,
198 repo_name=self.db_repo_name, source=source,
199 filter_type=filter_type, opened_by=opened_by, statuses=statuses)
199 filter_type=filter_type, opened_by=opened_by, statuses=statuses)
200
200
201 return data
201 return data
202
202
203 def _get_pr_version(self, pull_request_id, version=None):
203 def _get_pr_version(self, pull_request_id, version=None):
204 at_version = None
204 at_version = None
205
205
206 if version and version == 'latest':
206 if version and version == 'latest':
207 pull_request_ver = PullRequest.get(pull_request_id)
207 pull_request_ver = PullRequest.get(pull_request_id)
208 pull_request_obj = pull_request_ver
208 pull_request_obj = pull_request_ver
209 _org_pull_request_obj = pull_request_obj
209 _org_pull_request_obj = pull_request_obj
210 at_version = 'latest'
210 at_version = 'latest'
211 elif version:
211 elif version:
212 pull_request_ver = PullRequestVersion.get_or_404(version)
212 pull_request_ver = PullRequestVersion.get_or_404(version)
213 pull_request_obj = pull_request_ver
213 pull_request_obj = pull_request_ver
214 _org_pull_request_obj = pull_request_ver.pull_request
214 _org_pull_request_obj = pull_request_ver.pull_request
215 at_version = pull_request_ver.pull_request_version_id
215 at_version = pull_request_ver.pull_request_version_id
216 else:
216 else:
217 _org_pull_request_obj = pull_request_obj = PullRequest.get_or_404(
217 _org_pull_request_obj = pull_request_obj = PullRequest.get_or_404(
218 pull_request_id)
218 pull_request_id)
219
219
220 pull_request_display_obj = PullRequest.get_pr_display_object(
220 pull_request_display_obj = PullRequest.get_pr_display_object(
221 pull_request_obj, _org_pull_request_obj)
221 pull_request_obj, _org_pull_request_obj)
222
222
223 return _org_pull_request_obj, pull_request_obj, \
223 return _org_pull_request_obj, pull_request_obj, \
224 pull_request_display_obj, at_version
224 pull_request_display_obj, at_version
225
225
226 def _get_diffset(self, source_repo_name, source_repo,
226 def _get_diffset(self, source_repo_name, source_repo,
227 source_ref_id, target_ref_id,
227 source_ref_id, target_ref_id,
228 target_commit, source_commit, diff_limit, fulldiff,
228 target_commit, source_commit, diff_limit, fulldiff,
229 file_limit, display_inline_comments):
229 file_limit, display_inline_comments):
230
230
231 vcs_diff = PullRequestModel().get_diff(
231 vcs_diff = PullRequestModel().get_diff(
232 source_repo, source_ref_id, target_ref_id)
232 source_repo, source_ref_id, target_ref_id)
233
233
234 diff_processor = diffs.DiffProcessor(
234 diff_processor = diffs.DiffProcessor(
235 vcs_diff, format='newdiff', diff_limit=diff_limit,
235 vcs_diff, format='newdiff', diff_limit=diff_limit,
236 file_limit=file_limit, show_full_diff=fulldiff)
236 file_limit=file_limit, show_full_diff=fulldiff)
237
237
238 _parsed = diff_processor.prepare()
238 _parsed = diff_processor.prepare()
239
239
240 def _node_getter(commit):
240 def _node_getter(commit):
241 def get_node(fname):
241 def get_node(fname):
242 try:
242 try:
243 return commit.get_node(fname)
243 return commit.get_node(fname)
244 except NodeDoesNotExistError:
244 except NodeDoesNotExistError:
245 return None
245 return None
246
246
247 return get_node
247 return get_node
248
248
249 diffset = codeblocks.DiffSet(
249 diffset = codeblocks.DiffSet(
250 repo_name=self.db_repo_name,
250 repo_name=self.db_repo_name,
251 source_repo_name=source_repo_name,
251 source_repo_name=source_repo_name,
252 source_node_getter=_node_getter(target_commit),
252 source_node_getter=_node_getter(target_commit),
253 target_node_getter=_node_getter(source_commit),
253 target_node_getter=_node_getter(source_commit),
254 comments=display_inline_comments
254 comments=display_inline_comments
255 )
255 )
256 diffset = diffset.render_patchset(
256 diffset = diffset.render_patchset(
257 _parsed, target_commit.raw_id, source_commit.raw_id)
257 _parsed, target_commit.raw_id, source_commit.raw_id)
258
258
259 return diffset
259 return diffset
260
260
261 @LoginRequired()
261 @LoginRequired()
262 @HasRepoPermissionAnyDecorator(
262 @HasRepoPermissionAnyDecorator(
263 'repository.read', 'repository.write', 'repository.admin')
263 'repository.read', 'repository.write', 'repository.admin')
264 @view_config(
264 @view_config(
265 route_name='pullrequest_show', request_method='GET',
265 route_name='pullrequest_show', request_method='GET',
266 renderer='rhodecode:templates/pullrequests/pullrequest_show.mako')
266 renderer='rhodecode:templates/pullrequests/pullrequest_show.mako')
267 def pull_request_show(self):
267 def pull_request_show(self):
268 pull_request_id = self.request.matchdict['pull_request_id']
268 pull_request_id = self.request.matchdict['pull_request_id']
269
269
270 c = self.load_default_context()
270 c = self.load_default_context()
271
271
272 version = self.request.GET.get('version')
272 version = self.request.GET.get('version')
273 from_version = self.request.GET.get('from_version') or version
273 from_version = self.request.GET.get('from_version') or version
274 merge_checks = self.request.GET.get('merge_checks')
274 merge_checks = self.request.GET.get('merge_checks')
275 c.fulldiff = str2bool(self.request.GET.get('fulldiff'))
275 c.fulldiff = str2bool(self.request.GET.get('fulldiff'))
276
276
277 (pull_request_latest,
277 (pull_request_latest,
278 pull_request_at_ver,
278 pull_request_at_ver,
279 pull_request_display_obj,
279 pull_request_display_obj,
280 at_version) = self._get_pr_version(
280 at_version) = self._get_pr_version(
281 pull_request_id, version=version)
281 pull_request_id, version=version)
282 pr_closed = pull_request_latest.is_closed()
282 pr_closed = pull_request_latest.is_closed()
283
283
284 if pr_closed and (version or from_version):
284 if pr_closed and (version or from_version):
285 # not allow to browse versions
285 # not allow to browse versions
286 raise HTTPFound(h.route_path(
286 raise HTTPFound(h.route_path(
287 'pullrequest_show', repo_name=self.db_repo_name,
287 'pullrequest_show', repo_name=self.db_repo_name,
288 pull_request_id=pull_request_id))
288 pull_request_id=pull_request_id))
289
289
290 versions = pull_request_display_obj.versions()
290 versions = pull_request_display_obj.versions()
291
291
292 c.at_version = at_version
292 c.at_version = at_version
293 c.at_version_num = (at_version
293 c.at_version_num = (at_version
294 if at_version and at_version != 'latest'
294 if at_version and at_version != 'latest'
295 else None)
295 else None)
296 c.at_version_pos = ChangesetComment.get_index_from_version(
296 c.at_version_pos = ChangesetComment.get_index_from_version(
297 c.at_version_num, versions)
297 c.at_version_num, versions)
298
298
299 (prev_pull_request_latest,
299 (prev_pull_request_latest,
300 prev_pull_request_at_ver,
300 prev_pull_request_at_ver,
301 prev_pull_request_display_obj,
301 prev_pull_request_display_obj,
302 prev_at_version) = self._get_pr_version(
302 prev_at_version) = self._get_pr_version(
303 pull_request_id, version=from_version)
303 pull_request_id, version=from_version)
304
304
305 c.from_version = prev_at_version
305 c.from_version = prev_at_version
306 c.from_version_num = (prev_at_version
306 c.from_version_num = (prev_at_version
307 if prev_at_version and prev_at_version != 'latest'
307 if prev_at_version and prev_at_version != 'latest'
308 else None)
308 else None)
309 c.from_version_pos = ChangesetComment.get_index_from_version(
309 c.from_version_pos = ChangesetComment.get_index_from_version(
310 c.from_version_num, versions)
310 c.from_version_num, versions)
311
311
312 # define if we're in COMPARE mode or VIEW at version mode
312 # define if we're in COMPARE mode or VIEW at version mode
313 compare = at_version != prev_at_version
313 compare = at_version != prev_at_version
314
314
315 # pull_requests repo_name we opened it against
315 # pull_requests repo_name we opened it against
316 # ie. target_repo must match
316 # ie. target_repo must match
317 if self.db_repo_name != pull_request_at_ver.target_repo.repo_name:
317 if self.db_repo_name != pull_request_at_ver.target_repo.repo_name:
318 raise HTTPNotFound()
318 raise HTTPNotFound()
319
319
320 c.shadow_clone_url = PullRequestModel().get_shadow_clone_url(
320 c.shadow_clone_url = PullRequestModel().get_shadow_clone_url(
321 pull_request_at_ver)
321 pull_request_at_ver)
322
322
323 c.pull_request = pull_request_display_obj
323 c.pull_request = pull_request_display_obj
324 c.pull_request_latest = pull_request_latest
324 c.pull_request_latest = pull_request_latest
325
325
326 if compare or (at_version and not at_version == 'latest'):
326 if compare or (at_version and not at_version == 'latest'):
327 c.allowed_to_change_status = False
327 c.allowed_to_change_status = False
328 c.allowed_to_update = False
328 c.allowed_to_update = False
329 c.allowed_to_merge = False
329 c.allowed_to_merge = False
330 c.allowed_to_delete = False
330 c.allowed_to_delete = False
331 c.allowed_to_comment = False
331 c.allowed_to_comment = False
332 c.allowed_to_close = False
332 c.allowed_to_close = False
333 else:
333 else:
334 can_change_status = PullRequestModel().check_user_change_status(
334 can_change_status = PullRequestModel().check_user_change_status(
335 pull_request_at_ver, self._rhodecode_user)
335 pull_request_at_ver, self._rhodecode_user)
336 c.allowed_to_change_status = can_change_status and not pr_closed
336 c.allowed_to_change_status = can_change_status and not pr_closed
337
337
338 c.allowed_to_update = PullRequestModel().check_user_update(
338 c.allowed_to_update = PullRequestModel().check_user_update(
339 pull_request_latest, self._rhodecode_user) and not pr_closed
339 pull_request_latest, self._rhodecode_user) and not pr_closed
340 c.allowed_to_merge = PullRequestModel().check_user_merge(
340 c.allowed_to_merge = PullRequestModel().check_user_merge(
341 pull_request_latest, self._rhodecode_user) and not pr_closed
341 pull_request_latest, self._rhodecode_user) and not pr_closed
342 c.allowed_to_delete = PullRequestModel().check_user_delete(
342 c.allowed_to_delete = PullRequestModel().check_user_delete(
343 pull_request_latest, self._rhodecode_user) and not pr_closed
343 pull_request_latest, self._rhodecode_user) and not pr_closed
344 c.allowed_to_comment = not pr_closed
344 c.allowed_to_comment = not pr_closed
345 c.allowed_to_close = c.allowed_to_merge and not pr_closed
345 c.allowed_to_close = c.allowed_to_merge and not pr_closed
346
346
347 c.forbid_adding_reviewers = False
347 c.forbid_adding_reviewers = False
348 c.forbid_author_to_review = False
348 c.forbid_author_to_review = False
349 c.forbid_commit_author_to_review = False
349 c.forbid_commit_author_to_review = False
350
350
351 if pull_request_latest.reviewer_data and \
351 if pull_request_latest.reviewer_data and \
352 'rules' in pull_request_latest.reviewer_data:
352 'rules' in pull_request_latest.reviewer_data:
353 rules = pull_request_latest.reviewer_data['rules'] or {}
353 rules = pull_request_latest.reviewer_data['rules'] or {}
354 try:
354 try:
355 c.forbid_adding_reviewers = rules.get(
355 c.forbid_adding_reviewers = rules.get(
356 'forbid_adding_reviewers')
356 'forbid_adding_reviewers')
357 c.forbid_author_to_review = rules.get(
357 c.forbid_author_to_review = rules.get(
358 'forbid_author_to_review')
358 'forbid_author_to_review')
359 c.forbid_commit_author_to_review = rules.get(
359 c.forbid_commit_author_to_review = rules.get(
360 'forbid_commit_author_to_review')
360 'forbid_commit_author_to_review')
361 except Exception:
361 except Exception:
362 pass
362 pass
363
363
364 # check merge capabilities
364 # check merge capabilities
365 _merge_check = MergeCheck.validate(
365 _merge_check = MergeCheck.validate(
366 pull_request_latest, user=self._rhodecode_user)
366 pull_request_latest, user=self._rhodecode_user)
367 c.pr_merge_errors = _merge_check.error_details
367 c.pr_merge_errors = _merge_check.error_details
368 c.pr_merge_possible = not _merge_check.failed
368 c.pr_merge_possible = not _merge_check.failed
369 c.pr_merge_message = _merge_check.merge_msg
369 c.pr_merge_message = _merge_check.merge_msg
370
370
371 c.pr_merge_info = MergeCheck.get_merge_conditions(pull_request_latest)
372
371 c.pull_request_review_status = _merge_check.review_status
373 c.pull_request_review_status = _merge_check.review_status
372 if merge_checks:
374 if merge_checks:
373 self.request.override_renderer = \
375 self.request.override_renderer = \
374 'rhodecode:templates/pullrequests/pullrequest_merge_checks.mako'
376 'rhodecode:templates/pullrequests/pullrequest_merge_checks.mako'
375 return self._get_template_context(c)
377 return self._get_template_context(c)
376
378
377 comments_model = CommentsModel()
379 comments_model = CommentsModel()
378
380
379 # reviewers and statuses
381 # reviewers and statuses
380 c.pull_request_reviewers = pull_request_at_ver.reviewers_statuses()
382 c.pull_request_reviewers = pull_request_at_ver.reviewers_statuses()
381 allowed_reviewers = [x[0].user_id for x in c.pull_request_reviewers]
383 allowed_reviewers = [x[0].user_id for x in c.pull_request_reviewers]
382
384
383 # GENERAL COMMENTS with versions #
385 # GENERAL COMMENTS with versions #
384 q = comments_model._all_general_comments_of_pull_request(pull_request_latest)
386 q = comments_model._all_general_comments_of_pull_request(pull_request_latest)
385 q = q.order_by(ChangesetComment.comment_id.asc())
387 q = q.order_by(ChangesetComment.comment_id.asc())
386 general_comments = q
388 general_comments = q
387
389
388 # pick comments we want to render at current version
390 # pick comments we want to render at current version
389 c.comment_versions = comments_model.aggregate_comments(
391 c.comment_versions = comments_model.aggregate_comments(
390 general_comments, versions, c.at_version_num)
392 general_comments, versions, c.at_version_num)
391 c.comments = c.comment_versions[c.at_version_num]['until']
393 c.comments = c.comment_versions[c.at_version_num]['until']
392
394
393 # INLINE COMMENTS with versions #
395 # INLINE COMMENTS with versions #
394 q = comments_model._all_inline_comments_of_pull_request(pull_request_latest)
396 q = comments_model._all_inline_comments_of_pull_request(pull_request_latest)
395 q = q.order_by(ChangesetComment.comment_id.asc())
397 q = q.order_by(ChangesetComment.comment_id.asc())
396 inline_comments = q
398 inline_comments = q
397
399
398 c.inline_versions = comments_model.aggregate_comments(
400 c.inline_versions = comments_model.aggregate_comments(
399 inline_comments, versions, c.at_version_num, inline=True)
401 inline_comments, versions, c.at_version_num, inline=True)
400
402
401 # inject latest version
403 # inject latest version
402 latest_ver = PullRequest.get_pr_display_object(
404 latest_ver = PullRequest.get_pr_display_object(
403 pull_request_latest, pull_request_latest)
405 pull_request_latest, pull_request_latest)
404
406
405 c.versions = versions + [latest_ver]
407 c.versions = versions + [latest_ver]
406
408
407 # if we use version, then do not show later comments
409 # if we use version, then do not show later comments
408 # than current version
410 # than current version
409 display_inline_comments = collections.defaultdict(
411 display_inline_comments = collections.defaultdict(
410 lambda: collections.defaultdict(list))
412 lambda: collections.defaultdict(list))
411 for co in inline_comments:
413 for co in inline_comments:
412 if c.at_version_num:
414 if c.at_version_num:
413 # pick comments that are at least UPTO given version, so we
415 # pick comments that are at least UPTO given version, so we
414 # don't render comments for higher version
416 # don't render comments for higher version
415 should_render = co.pull_request_version_id and \
417 should_render = co.pull_request_version_id and \
416 co.pull_request_version_id <= c.at_version_num
418 co.pull_request_version_id <= c.at_version_num
417 else:
419 else:
418 # showing all, for 'latest'
420 # showing all, for 'latest'
419 should_render = True
421 should_render = True
420
422
421 if should_render:
423 if should_render:
422 display_inline_comments[co.f_path][co.line_no].append(co)
424 display_inline_comments[co.f_path][co.line_no].append(co)
423
425
424 # load diff data into template context, if we use compare mode then
426 # load diff data into template context, if we use compare mode then
425 # diff is calculated based on changes between versions of PR
427 # diff is calculated based on changes between versions of PR
426
428
427 source_repo = pull_request_at_ver.source_repo
429 source_repo = pull_request_at_ver.source_repo
428 source_ref_id = pull_request_at_ver.source_ref_parts.commit_id
430 source_ref_id = pull_request_at_ver.source_ref_parts.commit_id
429
431
430 target_repo = pull_request_at_ver.target_repo
432 target_repo = pull_request_at_ver.target_repo
431 target_ref_id = pull_request_at_ver.target_ref_parts.commit_id
433 target_ref_id = pull_request_at_ver.target_ref_parts.commit_id
432
434
433 if compare:
435 if compare:
434 # in compare switch the diff base to latest commit from prev version
436 # in compare switch the diff base to latest commit from prev version
435 target_ref_id = prev_pull_request_display_obj.revisions[0]
437 target_ref_id = prev_pull_request_display_obj.revisions[0]
436
438
437 # despite opening commits for bookmarks/branches/tags, we always
439 # despite opening commits for bookmarks/branches/tags, we always
438 # convert this to rev to prevent changes after bookmark or branch change
440 # convert this to rev to prevent changes after bookmark or branch change
439 c.source_ref_type = 'rev'
441 c.source_ref_type = 'rev'
440 c.source_ref = source_ref_id
442 c.source_ref = source_ref_id
441
443
442 c.target_ref_type = 'rev'
444 c.target_ref_type = 'rev'
443 c.target_ref = target_ref_id
445 c.target_ref = target_ref_id
444
446
445 c.source_repo = source_repo
447 c.source_repo = source_repo
446 c.target_repo = target_repo
448 c.target_repo = target_repo
447
449
448 c.commit_ranges = []
450 c.commit_ranges = []
449 source_commit = EmptyCommit()
451 source_commit = EmptyCommit()
450 target_commit = EmptyCommit()
452 target_commit = EmptyCommit()
451 c.missing_requirements = False
453 c.missing_requirements = False
452
454
453 source_scm = source_repo.scm_instance()
455 source_scm = source_repo.scm_instance()
454 target_scm = target_repo.scm_instance()
456 target_scm = target_repo.scm_instance()
455
457
456 # try first shadow repo, fallback to regular repo
458 # try first shadow repo, fallback to regular repo
457 try:
459 try:
458 commits_source_repo = pull_request_latest.get_shadow_repo()
460 commits_source_repo = pull_request_latest.get_shadow_repo()
459 except Exception:
461 except Exception:
460 log.debug('Failed to get shadow repo', exc_info=True)
462 log.debug('Failed to get shadow repo', exc_info=True)
461 commits_source_repo = source_scm
463 commits_source_repo = source_scm
462
464
463 c.commits_source_repo = commits_source_repo
465 c.commits_source_repo = commits_source_repo
464 commit_cache = {}
466 commit_cache = {}
465 try:
467 try:
466 pre_load = ["author", "branch", "date", "message"]
468 pre_load = ["author", "branch", "date", "message"]
467 show_revs = pull_request_at_ver.revisions
469 show_revs = pull_request_at_ver.revisions
468 for rev in show_revs:
470 for rev in show_revs:
469 comm = commits_source_repo.get_commit(
471 comm = commits_source_repo.get_commit(
470 commit_id=rev, pre_load=pre_load)
472 commit_id=rev, pre_load=pre_load)
471 c.commit_ranges.append(comm)
473 c.commit_ranges.append(comm)
472 commit_cache[comm.raw_id] = comm
474 commit_cache[comm.raw_id] = comm
473
475
474 # Order here matters, we first need to get target, and then
476 # Order here matters, we first need to get target, and then
475 # the source
477 # the source
476 target_commit = commits_source_repo.get_commit(
478 target_commit = commits_source_repo.get_commit(
477 commit_id=safe_str(target_ref_id))
479 commit_id=safe_str(target_ref_id))
478
480
479 source_commit = commits_source_repo.get_commit(
481 source_commit = commits_source_repo.get_commit(
480 commit_id=safe_str(source_ref_id))
482 commit_id=safe_str(source_ref_id))
481
483
482 except CommitDoesNotExistError:
484 except CommitDoesNotExistError:
483 log.warning(
485 log.warning(
484 'Failed to get commit from `{}` repo'.format(
486 'Failed to get commit from `{}` repo'.format(
485 commits_source_repo), exc_info=True)
487 commits_source_repo), exc_info=True)
486 except RepositoryRequirementError:
488 except RepositoryRequirementError:
487 log.warning(
489 log.warning(
488 'Failed to get all required data from repo', exc_info=True)
490 'Failed to get all required data from repo', exc_info=True)
489 c.missing_requirements = True
491 c.missing_requirements = True
490
492
491 c.ancestor = None # set it to None, to hide it from PR view
493 c.ancestor = None # set it to None, to hide it from PR view
492
494
493 try:
495 try:
494 ancestor_id = source_scm.get_common_ancestor(
496 ancestor_id = source_scm.get_common_ancestor(
495 source_commit.raw_id, target_commit.raw_id, target_scm)
497 source_commit.raw_id, target_commit.raw_id, target_scm)
496 c.ancestor_commit = source_scm.get_commit(ancestor_id)
498 c.ancestor_commit = source_scm.get_commit(ancestor_id)
497 except Exception:
499 except Exception:
498 c.ancestor_commit = None
500 c.ancestor_commit = None
499
501
500 c.statuses = source_repo.statuses(
502 c.statuses = source_repo.statuses(
501 [x.raw_id for x in c.commit_ranges])
503 [x.raw_id for x in c.commit_ranges])
502
504
503 # auto collapse if we have more than limit
505 # auto collapse if we have more than limit
504 collapse_limit = diffs.DiffProcessor._collapse_commits_over
506 collapse_limit = diffs.DiffProcessor._collapse_commits_over
505 c.collapse_all_commits = len(c.commit_ranges) > collapse_limit
507 c.collapse_all_commits = len(c.commit_ranges) > collapse_limit
506 c.compare_mode = compare
508 c.compare_mode = compare
507
509
508 # diff_limit is the old behavior, will cut off the whole diff
510 # diff_limit is the old behavior, will cut off the whole diff
509 # if the limit is applied otherwise will just hide the
511 # if the limit is applied otherwise will just hide the
510 # big files from the front-end
512 # big files from the front-end
511 diff_limit = c.visual.cut_off_limit_diff
513 diff_limit = c.visual.cut_off_limit_diff
512 file_limit = c.visual.cut_off_limit_file
514 file_limit = c.visual.cut_off_limit_file
513
515
514 c.missing_commits = False
516 c.missing_commits = False
515 if (c.missing_requirements
517 if (c.missing_requirements
516 or isinstance(source_commit, EmptyCommit)
518 or isinstance(source_commit, EmptyCommit)
517 or source_commit == target_commit):
519 or source_commit == target_commit):
518
520
519 c.missing_commits = True
521 c.missing_commits = True
520 else:
522 else:
521
523
522 c.diffset = self._get_diffset(
524 c.diffset = self._get_diffset(
523 c.source_repo.repo_name, commits_source_repo,
525 c.source_repo.repo_name, commits_source_repo,
524 source_ref_id, target_ref_id,
526 source_ref_id, target_ref_id,
525 target_commit, source_commit,
527 target_commit, source_commit,
526 diff_limit, c.fulldiff, file_limit, display_inline_comments)
528 diff_limit, c.fulldiff, file_limit, display_inline_comments)
527
529
528 c.limited_diff = c.diffset.limited_diff
530 c.limited_diff = c.diffset.limited_diff
529
531
530 # calculate removed files that are bound to comments
532 # calculate removed files that are bound to comments
531 comment_deleted_files = [
533 comment_deleted_files = [
532 fname for fname in display_inline_comments
534 fname for fname in display_inline_comments
533 if fname not in c.diffset.file_stats]
535 if fname not in c.diffset.file_stats]
534
536
535 c.deleted_files_comments = collections.defaultdict(dict)
537 c.deleted_files_comments = collections.defaultdict(dict)
536 for fname, per_line_comments in display_inline_comments.items():
538 for fname, per_line_comments in display_inline_comments.items():
537 if fname in comment_deleted_files:
539 if fname in comment_deleted_files:
538 c.deleted_files_comments[fname]['stats'] = 0
540 c.deleted_files_comments[fname]['stats'] = 0
539 c.deleted_files_comments[fname]['comments'] = list()
541 c.deleted_files_comments[fname]['comments'] = list()
540 for lno, comments in per_line_comments.items():
542 for lno, comments in per_line_comments.items():
541 c.deleted_files_comments[fname]['comments'].extend(
543 c.deleted_files_comments[fname]['comments'].extend(
542 comments)
544 comments)
543
545
544 # this is a hack to properly display links, when creating PR, the
546 # this is a hack to properly display links, when creating PR, the
545 # compare view and others uses different notation, and
547 # compare view and others uses different notation, and
546 # compare_commits.mako renders links based on the target_repo.
548 # compare_commits.mako renders links based on the target_repo.
547 # We need to swap that here to generate it properly on the html side
549 # We need to swap that here to generate it properly on the html side
548 c.target_repo = c.source_repo
550 c.target_repo = c.source_repo
549
551
550 c.commit_statuses = ChangesetStatus.STATUSES
552 c.commit_statuses = ChangesetStatus.STATUSES
551
553
552 c.show_version_changes = not pr_closed
554 c.show_version_changes = not pr_closed
553 if c.show_version_changes:
555 if c.show_version_changes:
554 cur_obj = pull_request_at_ver
556 cur_obj = pull_request_at_ver
555 prev_obj = prev_pull_request_at_ver
557 prev_obj = prev_pull_request_at_ver
556
558
557 old_commit_ids = prev_obj.revisions
559 old_commit_ids = prev_obj.revisions
558 new_commit_ids = cur_obj.revisions
560 new_commit_ids = cur_obj.revisions
559 commit_changes = PullRequestModel()._calculate_commit_id_changes(
561 commit_changes = PullRequestModel()._calculate_commit_id_changes(
560 old_commit_ids, new_commit_ids)
562 old_commit_ids, new_commit_ids)
561 c.commit_changes_summary = commit_changes
563 c.commit_changes_summary = commit_changes
562
564
563 # calculate the diff for commits between versions
565 # calculate the diff for commits between versions
564 c.commit_changes = []
566 c.commit_changes = []
565 mark = lambda cs, fw: list(
567 mark = lambda cs, fw: list(
566 h.itertools.izip_longest([], cs, fillvalue=fw))
568 h.itertools.izip_longest([], cs, fillvalue=fw))
567 for c_type, raw_id in mark(commit_changes.added, 'a') \
569 for c_type, raw_id in mark(commit_changes.added, 'a') \
568 + mark(commit_changes.removed, 'r') \
570 + mark(commit_changes.removed, 'r') \
569 + mark(commit_changes.common, 'c'):
571 + mark(commit_changes.common, 'c'):
570
572
571 if raw_id in commit_cache:
573 if raw_id in commit_cache:
572 commit = commit_cache[raw_id]
574 commit = commit_cache[raw_id]
573 else:
575 else:
574 try:
576 try:
575 commit = commits_source_repo.get_commit(raw_id)
577 commit = commits_source_repo.get_commit(raw_id)
576 except CommitDoesNotExistError:
578 except CommitDoesNotExistError:
577 # in case we fail extracting still use "dummy" commit
579 # in case we fail extracting still use "dummy" commit
578 # for display in commit diff
580 # for display in commit diff
579 commit = h.AttributeDict(
581 commit = h.AttributeDict(
580 {'raw_id': raw_id,
582 {'raw_id': raw_id,
581 'message': 'EMPTY or MISSING COMMIT'})
583 'message': 'EMPTY or MISSING COMMIT'})
582 c.commit_changes.append([c_type, commit])
584 c.commit_changes.append([c_type, commit])
583
585
584 # current user review statuses for each version
586 # current user review statuses for each version
585 c.review_versions = {}
587 c.review_versions = {}
586 if self._rhodecode_user.user_id in allowed_reviewers:
588 if self._rhodecode_user.user_id in allowed_reviewers:
587 for co in general_comments:
589 for co in general_comments:
588 if co.author.user_id == self._rhodecode_user.user_id:
590 if co.author.user_id == self._rhodecode_user.user_id:
589 # each comment has a status change
591 # each comment has a status change
590 status = co.status_change
592 status = co.status_change
591 if status:
593 if status:
592 _ver_pr = status[0].comment.pull_request_version_id
594 _ver_pr = status[0].comment.pull_request_version_id
593 c.review_versions[_ver_pr] = status[0]
595 c.review_versions[_ver_pr] = status[0]
594
596
595 return self._get_template_context(c)
597 return self._get_template_context(c)
596
598
597 def assure_not_empty_repo(self):
599 def assure_not_empty_repo(self):
598 _ = self.request.translate
600 _ = self.request.translate
599
601
600 try:
602 try:
601 self.db_repo.scm_instance().get_commit()
603 self.db_repo.scm_instance().get_commit()
602 except EmptyRepositoryError:
604 except EmptyRepositoryError:
603 h.flash(h.literal(_('There are no commits yet')),
605 h.flash(h.literal(_('There are no commits yet')),
604 category='warning')
606 category='warning')
605 raise HTTPFound(
607 raise HTTPFound(
606 h.route_path('repo_summary', repo_name=self.db_repo.repo_name))
608 h.route_path('repo_summary', repo_name=self.db_repo.repo_name))
607
609
608 @LoginRequired()
610 @LoginRequired()
609 @NotAnonymous()
611 @NotAnonymous()
610 @HasRepoPermissionAnyDecorator(
612 @HasRepoPermissionAnyDecorator(
611 'repository.read', 'repository.write', 'repository.admin')
613 'repository.read', 'repository.write', 'repository.admin')
612 @view_config(
614 @view_config(
613 route_name='pullrequest_new', request_method='GET',
615 route_name='pullrequest_new', request_method='GET',
614 renderer='rhodecode:templates/pullrequests/pullrequest.mako')
616 renderer='rhodecode:templates/pullrequests/pullrequest.mako')
615 def pull_request_new(self):
617 def pull_request_new(self):
616 _ = self.request.translate
618 _ = self.request.translate
617 c = self.load_default_context()
619 c = self.load_default_context()
618
620
619 self.assure_not_empty_repo()
621 self.assure_not_empty_repo()
620 source_repo = self.db_repo
622 source_repo = self.db_repo
621
623
622 commit_id = self.request.GET.get('commit')
624 commit_id = self.request.GET.get('commit')
623 branch_ref = self.request.GET.get('branch')
625 branch_ref = self.request.GET.get('branch')
624 bookmark_ref = self.request.GET.get('bookmark')
626 bookmark_ref = self.request.GET.get('bookmark')
625
627
626 try:
628 try:
627 source_repo_data = PullRequestModel().generate_repo_data(
629 source_repo_data = PullRequestModel().generate_repo_data(
628 source_repo, commit_id=commit_id,
630 source_repo, commit_id=commit_id,
629 branch=branch_ref, bookmark=bookmark_ref)
631 branch=branch_ref, bookmark=bookmark_ref)
630 except CommitDoesNotExistError as e:
632 except CommitDoesNotExistError as e:
631 log.exception(e)
633 log.exception(e)
632 h.flash(_('Commit does not exist'), 'error')
634 h.flash(_('Commit does not exist'), 'error')
633 raise HTTPFound(
635 raise HTTPFound(
634 h.route_path('pullrequest_new', repo_name=source_repo.repo_name))
636 h.route_path('pullrequest_new', repo_name=source_repo.repo_name))
635
637
636 default_target_repo = source_repo
638 default_target_repo = source_repo
637
639
638 if source_repo.parent:
640 if source_repo.parent:
639 parent_vcs_obj = source_repo.parent.scm_instance()
641 parent_vcs_obj = source_repo.parent.scm_instance()
640 if parent_vcs_obj and not parent_vcs_obj.is_empty():
642 if parent_vcs_obj and not parent_vcs_obj.is_empty():
641 # change default if we have a parent repo
643 # change default if we have a parent repo
642 default_target_repo = source_repo.parent
644 default_target_repo = source_repo.parent
643
645
644 target_repo_data = PullRequestModel().generate_repo_data(
646 target_repo_data = PullRequestModel().generate_repo_data(
645 default_target_repo)
647 default_target_repo)
646
648
647 selected_source_ref = source_repo_data['refs']['selected_ref']
649 selected_source_ref = source_repo_data['refs']['selected_ref']
648
650
649 title_source_ref = selected_source_ref.split(':', 2)[1]
651 title_source_ref = selected_source_ref.split(':', 2)[1]
650 c.default_title = PullRequestModel().generate_pullrequest_title(
652 c.default_title = PullRequestModel().generate_pullrequest_title(
651 source=source_repo.repo_name,
653 source=source_repo.repo_name,
652 source_ref=title_source_ref,
654 source_ref=title_source_ref,
653 target=default_target_repo.repo_name
655 target=default_target_repo.repo_name
654 )
656 )
655
657
656 c.default_repo_data = {
658 c.default_repo_data = {
657 'source_repo_name': source_repo.repo_name,
659 'source_repo_name': source_repo.repo_name,
658 'source_refs_json': json.dumps(source_repo_data),
660 'source_refs_json': json.dumps(source_repo_data),
659 'target_repo_name': default_target_repo.repo_name,
661 'target_repo_name': default_target_repo.repo_name,
660 'target_refs_json': json.dumps(target_repo_data),
662 'target_refs_json': json.dumps(target_repo_data),
661 }
663 }
662 c.default_source_ref = selected_source_ref
664 c.default_source_ref = selected_source_ref
663
665
664 return self._get_template_context(c)
666 return self._get_template_context(c)
665
667
666 @LoginRequired()
668 @LoginRequired()
667 @NotAnonymous()
669 @NotAnonymous()
668 @HasRepoPermissionAnyDecorator(
670 @HasRepoPermissionAnyDecorator(
669 'repository.read', 'repository.write', 'repository.admin')
671 'repository.read', 'repository.write', 'repository.admin')
670 @view_config(
672 @view_config(
671 route_name='pullrequest_repo_refs', request_method='GET',
673 route_name='pullrequest_repo_refs', request_method='GET',
672 renderer='json_ext', xhr=True)
674 renderer='json_ext', xhr=True)
673 def pull_request_repo_refs(self):
675 def pull_request_repo_refs(self):
674 target_repo_name = self.request.matchdict['target_repo_name']
676 target_repo_name = self.request.matchdict['target_repo_name']
675 repo = Repository.get_by_repo_name(target_repo_name)
677 repo = Repository.get_by_repo_name(target_repo_name)
676 if not repo:
678 if not repo:
677 raise HTTPNotFound()
679 raise HTTPNotFound()
678 return PullRequestModel().generate_repo_data(repo)
680 return PullRequestModel().generate_repo_data(repo)
679
681
680 @LoginRequired()
682 @LoginRequired()
681 @NotAnonymous()
683 @NotAnonymous()
682 @HasRepoPermissionAnyDecorator(
684 @HasRepoPermissionAnyDecorator(
683 'repository.read', 'repository.write', 'repository.admin')
685 'repository.read', 'repository.write', 'repository.admin')
684 @view_config(
686 @view_config(
685 route_name='pullrequest_repo_destinations', request_method='GET',
687 route_name='pullrequest_repo_destinations', request_method='GET',
686 renderer='json_ext', xhr=True)
688 renderer='json_ext', xhr=True)
687 def pull_request_repo_destinations(self):
689 def pull_request_repo_destinations(self):
688 _ = self.request.translate
690 _ = self.request.translate
689 filter_query = self.request.GET.get('query')
691 filter_query = self.request.GET.get('query')
690
692
691 query = Repository.query() \
693 query = Repository.query() \
692 .order_by(func.length(Repository.repo_name)) \
694 .order_by(func.length(Repository.repo_name)) \
693 .filter(
695 .filter(
694 or_(Repository.repo_name == self.db_repo.repo_name,
696 or_(Repository.repo_name == self.db_repo.repo_name,
695 Repository.fork_id == self.db_repo.repo_id))
697 Repository.fork_id == self.db_repo.repo_id))
696
698
697 if filter_query:
699 if filter_query:
698 ilike_expression = u'%{}%'.format(safe_unicode(filter_query))
700 ilike_expression = u'%{}%'.format(safe_unicode(filter_query))
699 query = query.filter(
701 query = query.filter(
700 Repository.repo_name.ilike(ilike_expression))
702 Repository.repo_name.ilike(ilike_expression))
701
703
702 add_parent = False
704 add_parent = False
703 if self.db_repo.parent:
705 if self.db_repo.parent:
704 if filter_query in self.db_repo.parent.repo_name:
706 if filter_query in self.db_repo.parent.repo_name:
705 parent_vcs_obj = self.db_repo.parent.scm_instance()
707 parent_vcs_obj = self.db_repo.parent.scm_instance()
706 if parent_vcs_obj and not parent_vcs_obj.is_empty():
708 if parent_vcs_obj and not parent_vcs_obj.is_empty():
707 add_parent = True
709 add_parent = True
708
710
709 limit = 20 - 1 if add_parent else 20
711 limit = 20 - 1 if add_parent else 20
710 all_repos = query.limit(limit).all()
712 all_repos = query.limit(limit).all()
711 if add_parent:
713 if add_parent:
712 all_repos += [self.db_repo.parent]
714 all_repos += [self.db_repo.parent]
713
715
714 repos = []
716 repos = []
715 for obj in ScmModel().get_repos(all_repos):
717 for obj in ScmModel().get_repos(all_repos):
716 repos.append({
718 repos.append({
717 'id': obj['name'],
719 'id': obj['name'],
718 'text': obj['name'],
720 'text': obj['name'],
719 'type': 'repo',
721 'type': 'repo',
720 'obj': obj['dbrepo']
722 'obj': obj['dbrepo']
721 })
723 })
722
724
723 data = {
725 data = {
724 'more': False,
726 'more': False,
725 'results': [{
727 'results': [{
726 'text': _('Repositories'),
728 'text': _('Repositories'),
727 'children': repos
729 'children': repos
728 }] if repos else []
730 }] if repos else []
729 }
731 }
730 return data
732 return data
731
733
732 @LoginRequired()
734 @LoginRequired()
733 @NotAnonymous()
735 @NotAnonymous()
734 @HasRepoPermissionAnyDecorator(
736 @HasRepoPermissionAnyDecorator(
735 'repository.read', 'repository.write', 'repository.admin')
737 'repository.read', 'repository.write', 'repository.admin')
736 @CSRFRequired()
738 @CSRFRequired()
737 @view_config(
739 @view_config(
738 route_name='pullrequest_create', request_method='POST',
740 route_name='pullrequest_create', request_method='POST',
739 renderer=None)
741 renderer=None)
740 def pull_request_create(self):
742 def pull_request_create(self):
741 _ = self.request.translate
743 _ = self.request.translate
742 self.assure_not_empty_repo()
744 self.assure_not_empty_repo()
743
745
744 controls = peppercorn.parse(self.request.POST.items())
746 controls = peppercorn.parse(self.request.POST.items())
745
747
746 try:
748 try:
747 _form = PullRequestForm(self.db_repo.repo_id)().to_python(controls)
749 _form = PullRequestForm(self.db_repo.repo_id)().to_python(controls)
748 except formencode.Invalid as errors:
750 except formencode.Invalid as errors:
749 if errors.error_dict.get('revisions'):
751 if errors.error_dict.get('revisions'):
750 msg = 'Revisions: %s' % errors.error_dict['revisions']
752 msg = 'Revisions: %s' % errors.error_dict['revisions']
751 elif errors.error_dict.get('pullrequest_title'):
753 elif errors.error_dict.get('pullrequest_title'):
752 msg = _('Pull request requires a title with min. 3 chars')
754 msg = _('Pull request requires a title with min. 3 chars')
753 else:
755 else:
754 msg = _('Error creating pull request: {}').format(errors)
756 msg = _('Error creating pull request: {}').format(errors)
755 log.exception(msg)
757 log.exception(msg)
756 h.flash(msg, 'error')
758 h.flash(msg, 'error')
757
759
758 # would rather just go back to form ...
760 # would rather just go back to form ...
759 raise HTTPFound(
761 raise HTTPFound(
760 h.route_path('pullrequest_new', repo_name=self.db_repo_name))
762 h.route_path('pullrequest_new', repo_name=self.db_repo_name))
761
763
762 source_repo = _form['source_repo']
764 source_repo = _form['source_repo']
763 source_ref = _form['source_ref']
765 source_ref = _form['source_ref']
764 target_repo = _form['target_repo']
766 target_repo = _form['target_repo']
765 target_ref = _form['target_ref']
767 target_ref = _form['target_ref']
766 commit_ids = _form['revisions'][::-1]
768 commit_ids = _form['revisions'][::-1]
767
769
768 # find the ancestor for this pr
770 # find the ancestor for this pr
769 source_db_repo = Repository.get_by_repo_name(_form['source_repo'])
771 source_db_repo = Repository.get_by_repo_name(_form['source_repo'])
770 target_db_repo = Repository.get_by_repo_name(_form['target_repo'])
772 target_db_repo = Repository.get_by_repo_name(_form['target_repo'])
771
773
772 source_scm = source_db_repo.scm_instance()
774 source_scm = source_db_repo.scm_instance()
773 target_scm = target_db_repo.scm_instance()
775 target_scm = target_db_repo.scm_instance()
774
776
775 source_commit = source_scm.get_commit(source_ref.split(':')[-1])
777 source_commit = source_scm.get_commit(source_ref.split(':')[-1])
776 target_commit = target_scm.get_commit(target_ref.split(':')[-1])
778 target_commit = target_scm.get_commit(target_ref.split(':')[-1])
777
779
778 ancestor = source_scm.get_common_ancestor(
780 ancestor = source_scm.get_common_ancestor(
779 source_commit.raw_id, target_commit.raw_id, target_scm)
781 source_commit.raw_id, target_commit.raw_id, target_scm)
780
782
781 target_ref_type, target_ref_name, __ = _form['target_ref'].split(':')
783 target_ref_type, target_ref_name, __ = _form['target_ref'].split(':')
782 target_ref = ':'.join((target_ref_type, target_ref_name, ancestor))
784 target_ref = ':'.join((target_ref_type, target_ref_name, ancestor))
783
785
784 pullrequest_title = _form['pullrequest_title']
786 pullrequest_title = _form['pullrequest_title']
785 title_source_ref = source_ref.split(':', 2)[1]
787 title_source_ref = source_ref.split(':', 2)[1]
786 if not pullrequest_title:
788 if not pullrequest_title:
787 pullrequest_title = PullRequestModel().generate_pullrequest_title(
789 pullrequest_title = PullRequestModel().generate_pullrequest_title(
788 source=source_repo,
790 source=source_repo,
789 source_ref=title_source_ref,
791 source_ref=title_source_ref,
790 target=target_repo
792 target=target_repo
791 )
793 )
792
794
793 description = _form['pullrequest_desc']
795 description = _form['pullrequest_desc']
794
796
795 get_default_reviewers_data, validate_default_reviewers = \
797 get_default_reviewers_data, validate_default_reviewers = \
796 PullRequestModel().get_reviewer_functions()
798 PullRequestModel().get_reviewer_functions()
797
799
798 # recalculate reviewers logic, to make sure we can validate this
800 # recalculate reviewers logic, to make sure we can validate this
799 reviewer_rules = get_default_reviewers_data(
801 reviewer_rules = get_default_reviewers_data(
800 self._rhodecode_db_user, source_db_repo,
802 self._rhodecode_db_user, source_db_repo,
801 source_commit, target_db_repo, target_commit)
803 source_commit, target_db_repo, target_commit)
802
804
803 given_reviewers = _form['review_members']
805 given_reviewers = _form['review_members']
804 reviewers = validate_default_reviewers(given_reviewers, reviewer_rules)
806 reviewers = validate_default_reviewers(given_reviewers, reviewer_rules)
805
807
806 try:
808 try:
807 pull_request = PullRequestModel().create(
809 pull_request = PullRequestModel().create(
808 self._rhodecode_user.user_id, source_repo, source_ref, target_repo,
810 self._rhodecode_user.user_id, source_repo, source_ref, target_repo,
809 target_ref, commit_ids, reviewers, pullrequest_title,
811 target_ref, commit_ids, reviewers, pullrequest_title,
810 description, reviewer_rules
812 description, reviewer_rules
811 )
813 )
812 Session().commit()
814 Session().commit()
813 h.flash(_('Successfully opened new pull request'),
815 h.flash(_('Successfully opened new pull request'),
814 category='success')
816 category='success')
815 except Exception:
817 except Exception:
816 msg = _('Error occurred during creation of this pull request.')
818 msg = _('Error occurred during creation of this pull request.')
817 log.exception(msg)
819 log.exception(msg)
818 h.flash(msg, category='error')
820 h.flash(msg, category='error')
819
821
820 # copy the args back to redirect
822 # copy the args back to redirect
821 org_query = self.request.GET.mixed()
823 org_query = self.request.GET.mixed()
822 raise HTTPFound(
824 raise HTTPFound(
823 h.route_path('pullrequest_new', repo_name=self.db_repo_name,
825 h.route_path('pullrequest_new', repo_name=self.db_repo_name,
824 _query=org_query))
826 _query=org_query))
825
827
826 raise HTTPFound(
828 raise HTTPFound(
827 h.route_path('pullrequest_show', repo_name=target_repo,
829 h.route_path('pullrequest_show', repo_name=target_repo,
828 pull_request_id=pull_request.pull_request_id))
830 pull_request_id=pull_request.pull_request_id))
829
831
830 @LoginRequired()
832 @LoginRequired()
831 @NotAnonymous()
833 @NotAnonymous()
832 @HasRepoPermissionAnyDecorator(
834 @HasRepoPermissionAnyDecorator(
833 'repository.read', 'repository.write', 'repository.admin')
835 'repository.read', 'repository.write', 'repository.admin')
834 @CSRFRequired()
836 @CSRFRequired()
835 @view_config(
837 @view_config(
836 route_name='pullrequest_update', request_method='POST',
838 route_name='pullrequest_update', request_method='POST',
837 renderer='json_ext')
839 renderer='json_ext')
838 def pull_request_update(self):
840 def pull_request_update(self):
839 pull_request = PullRequest.get_or_404(
841 pull_request = PullRequest.get_or_404(
840 self.request.matchdict['pull_request_id'])
842 self.request.matchdict['pull_request_id'])
841
843
842 # only owner or admin can update it
844 # only owner or admin can update it
843 allowed_to_update = PullRequestModel().check_user_update(
845 allowed_to_update = PullRequestModel().check_user_update(
844 pull_request, self._rhodecode_user)
846 pull_request, self._rhodecode_user)
845 if allowed_to_update:
847 if allowed_to_update:
846 controls = peppercorn.parse(self.request.POST.items())
848 controls = peppercorn.parse(self.request.POST.items())
847
849
848 if 'review_members' in controls:
850 if 'review_members' in controls:
849 self._update_reviewers(
851 self._update_reviewers(
850 pull_request, controls['review_members'],
852 pull_request, controls['review_members'],
851 pull_request.reviewer_data)
853 pull_request.reviewer_data)
852 elif str2bool(self.request.POST.get('update_commits', 'false')):
854 elif str2bool(self.request.POST.get('update_commits', 'false')):
853 self._update_commits(pull_request)
855 self._update_commits(pull_request)
854 elif str2bool(self.request.POST.get('edit_pull_request', 'false')):
856 elif str2bool(self.request.POST.get('edit_pull_request', 'false')):
855 self._edit_pull_request(pull_request)
857 self._edit_pull_request(pull_request)
856 else:
858 else:
857 raise HTTPBadRequest()
859 raise HTTPBadRequest()
858 return True
860 return True
859 raise HTTPForbidden()
861 raise HTTPForbidden()
860
862
861 def _edit_pull_request(self, pull_request):
863 def _edit_pull_request(self, pull_request):
862 _ = self.request.translate
864 _ = self.request.translate
863 try:
865 try:
864 PullRequestModel().edit(
866 PullRequestModel().edit(
865 pull_request, self.request.POST.get('title'),
867 pull_request, self.request.POST.get('title'),
866 self.request.POST.get('description'), self._rhodecode_user)
868 self.request.POST.get('description'), self._rhodecode_user)
867 except ValueError:
869 except ValueError:
868 msg = _(u'Cannot update closed pull requests.')
870 msg = _(u'Cannot update closed pull requests.')
869 h.flash(msg, category='error')
871 h.flash(msg, category='error')
870 return
872 return
871 else:
873 else:
872 Session().commit()
874 Session().commit()
873
875
874 msg = _(u'Pull request title & description updated.')
876 msg = _(u'Pull request title & description updated.')
875 h.flash(msg, category='success')
877 h.flash(msg, category='success')
876 return
878 return
877
879
878 def _update_commits(self, pull_request):
880 def _update_commits(self, pull_request):
879 _ = self.request.translate
881 _ = self.request.translate
880 resp = PullRequestModel().update_commits(pull_request)
882 resp = PullRequestModel().update_commits(pull_request)
881
883
882 if resp.executed:
884 if resp.executed:
883
885
884 if resp.target_changed and resp.source_changed:
886 if resp.target_changed and resp.source_changed:
885 changed = 'target and source repositories'
887 changed = 'target and source repositories'
886 elif resp.target_changed and not resp.source_changed:
888 elif resp.target_changed and not resp.source_changed:
887 changed = 'target repository'
889 changed = 'target repository'
888 elif not resp.target_changed and resp.source_changed:
890 elif not resp.target_changed and resp.source_changed:
889 changed = 'source repository'
891 changed = 'source repository'
890 else:
892 else:
891 changed = 'nothing'
893 changed = 'nothing'
892
894
893 msg = _(
895 msg = _(
894 u'Pull request updated to "{source_commit_id}" with '
896 u'Pull request updated to "{source_commit_id}" with '
895 u'{count_added} added, {count_removed} removed commits. '
897 u'{count_added} added, {count_removed} removed commits. '
896 u'Source of changes: {change_source}')
898 u'Source of changes: {change_source}')
897 msg = msg.format(
899 msg = msg.format(
898 source_commit_id=pull_request.source_ref_parts.commit_id,
900 source_commit_id=pull_request.source_ref_parts.commit_id,
899 count_added=len(resp.changes.added),
901 count_added=len(resp.changes.added),
900 count_removed=len(resp.changes.removed),
902 count_removed=len(resp.changes.removed),
901 change_source=changed)
903 change_source=changed)
902 h.flash(msg, category='success')
904 h.flash(msg, category='success')
903
905
904 channel = '/repo${}$/pr/{}'.format(
906 channel = '/repo${}$/pr/{}'.format(
905 pull_request.target_repo.repo_name,
907 pull_request.target_repo.repo_name,
906 pull_request.pull_request_id)
908 pull_request.pull_request_id)
907 message = msg + (
909 message = msg + (
908 ' - <a onclick="window.location.reload()">'
910 ' - <a onclick="window.location.reload()">'
909 '<strong>{}</strong></a>'.format(_('Reload page')))
911 '<strong>{}</strong></a>'.format(_('Reload page')))
910 channelstream.post_message(
912 channelstream.post_message(
911 channel, message, self._rhodecode_user.username,
913 channel, message, self._rhodecode_user.username,
912 registry=self.request.registry)
914 registry=self.request.registry)
913 else:
915 else:
914 msg = PullRequestModel.UPDATE_STATUS_MESSAGES[resp.reason]
916 msg = PullRequestModel.UPDATE_STATUS_MESSAGES[resp.reason]
915 warning_reasons = [
917 warning_reasons = [
916 UpdateFailureReason.NO_CHANGE,
918 UpdateFailureReason.NO_CHANGE,
917 UpdateFailureReason.WRONG_REF_TYPE,
919 UpdateFailureReason.WRONG_REF_TYPE,
918 ]
920 ]
919 category = 'warning' if resp.reason in warning_reasons else 'error'
921 category = 'warning' if resp.reason in warning_reasons else 'error'
920 h.flash(msg, category=category)
922 h.flash(msg, category=category)
921
923
922 @LoginRequired()
924 @LoginRequired()
923 @NotAnonymous()
925 @NotAnonymous()
924 @HasRepoPermissionAnyDecorator(
926 @HasRepoPermissionAnyDecorator(
925 'repository.read', 'repository.write', 'repository.admin')
927 'repository.read', 'repository.write', 'repository.admin')
926 @CSRFRequired()
928 @CSRFRequired()
927 @view_config(
929 @view_config(
928 route_name='pullrequest_merge', request_method='POST',
930 route_name='pullrequest_merge', request_method='POST',
929 renderer='json_ext')
931 renderer='json_ext')
930 def pull_request_merge(self):
932 def pull_request_merge(self):
931 """
933 """
932 Merge will perform a server-side merge of the specified
934 Merge will perform a server-side merge of the specified
933 pull request, if the pull request is approved and mergeable.
935 pull request, if the pull request is approved and mergeable.
934 After successful merging, the pull request is automatically
936 After successful merging, the pull request is automatically
935 closed, with a relevant comment.
937 closed, with a relevant comment.
936 """
938 """
937 pull_request = PullRequest.get_or_404(
939 pull_request = PullRequest.get_or_404(
938 self.request.matchdict['pull_request_id'])
940 self.request.matchdict['pull_request_id'])
939
941
940 check = MergeCheck.validate(pull_request, self._rhodecode_db_user)
942 check = MergeCheck.validate(pull_request, self._rhodecode_db_user)
941 merge_possible = not check.failed
943 merge_possible = not check.failed
942
944
943 for err_type, error_msg in check.errors:
945 for err_type, error_msg in check.errors:
944 h.flash(error_msg, category=err_type)
946 h.flash(error_msg, category=err_type)
945
947
946 if merge_possible:
948 if merge_possible:
947 log.debug("Pre-conditions checked, trying to merge.")
949 log.debug("Pre-conditions checked, trying to merge.")
948 extras = vcs_operation_context(
950 extras = vcs_operation_context(
949 self.request.environ, repo_name=pull_request.target_repo.repo_name,
951 self.request.environ, repo_name=pull_request.target_repo.repo_name,
950 username=self._rhodecode_db_user.username, action='push',
952 username=self._rhodecode_db_user.username, action='push',
951 scm=pull_request.target_repo.repo_type)
953 scm=pull_request.target_repo.repo_type)
952 self._merge_pull_request(
954 self._merge_pull_request(
953 pull_request, self._rhodecode_db_user, extras)
955 pull_request, self._rhodecode_db_user, extras)
954 else:
956 else:
955 log.debug("Pre-conditions failed, NOT merging.")
957 log.debug("Pre-conditions failed, NOT merging.")
956
958
957 raise HTTPFound(
959 raise HTTPFound(
958 h.route_path('pullrequest_show',
960 h.route_path('pullrequest_show',
959 repo_name=pull_request.target_repo.repo_name,
961 repo_name=pull_request.target_repo.repo_name,
960 pull_request_id=pull_request.pull_request_id))
962 pull_request_id=pull_request.pull_request_id))
961
963
962 def _merge_pull_request(self, pull_request, user, extras):
964 def _merge_pull_request(self, pull_request, user, extras):
963 _ = self.request.translate
965 _ = self.request.translate
964 merge_resp = PullRequestModel().merge(pull_request, user, extras=extras)
966 merge_resp = PullRequestModel().merge(pull_request, user, extras=extras)
965
967
966 if merge_resp.executed:
968 if merge_resp.executed:
967 log.debug("The merge was successful, closing the pull request.")
969 log.debug("The merge was successful, closing the pull request.")
968 PullRequestModel().close_pull_request(
970 PullRequestModel().close_pull_request(
969 pull_request.pull_request_id, user)
971 pull_request.pull_request_id, user)
970 Session().commit()
972 Session().commit()
971 msg = _('Pull request was successfully merged and closed.')
973 msg = _('Pull request was successfully merged and closed.')
972 h.flash(msg, category='success')
974 h.flash(msg, category='success')
973 else:
975 else:
974 log.debug(
976 log.debug(
975 "The merge was not successful. Merge response: %s",
977 "The merge was not successful. Merge response: %s",
976 merge_resp)
978 merge_resp)
977 msg = PullRequestModel().merge_status_message(
979 msg = PullRequestModel().merge_status_message(
978 merge_resp.failure_reason)
980 merge_resp.failure_reason)
979 h.flash(msg, category='error')
981 h.flash(msg, category='error')
980
982
981 def _update_reviewers(self, pull_request, review_members, reviewer_rules):
983 def _update_reviewers(self, pull_request, review_members, reviewer_rules):
982 _ = self.request.translate
984 _ = self.request.translate
983 get_default_reviewers_data, validate_default_reviewers = \
985 get_default_reviewers_data, validate_default_reviewers = \
984 PullRequestModel().get_reviewer_functions()
986 PullRequestModel().get_reviewer_functions()
985
987
986 try:
988 try:
987 reviewers = validate_default_reviewers(review_members, reviewer_rules)
989 reviewers = validate_default_reviewers(review_members, reviewer_rules)
988 except ValueError as e:
990 except ValueError as e:
989 log.error('Reviewers Validation: {}'.format(e))
991 log.error('Reviewers Validation: {}'.format(e))
990 h.flash(e, category='error')
992 h.flash(e, category='error')
991 return
993 return
992
994
993 PullRequestModel().update_reviewers(
995 PullRequestModel().update_reviewers(
994 pull_request, reviewers, self._rhodecode_user)
996 pull_request, reviewers, self._rhodecode_user)
995 h.flash(_('Pull request reviewers updated.'), category='success')
997 h.flash(_('Pull request reviewers updated.'), category='success')
996 Session().commit()
998 Session().commit()
997
999
998 @LoginRequired()
1000 @LoginRequired()
999 @NotAnonymous()
1001 @NotAnonymous()
1000 @HasRepoPermissionAnyDecorator(
1002 @HasRepoPermissionAnyDecorator(
1001 'repository.read', 'repository.write', 'repository.admin')
1003 'repository.read', 'repository.write', 'repository.admin')
1002 @CSRFRequired()
1004 @CSRFRequired()
1003 @view_config(
1005 @view_config(
1004 route_name='pullrequest_delete', request_method='POST',
1006 route_name='pullrequest_delete', request_method='POST',
1005 renderer='json_ext')
1007 renderer='json_ext')
1006 def pull_request_delete(self):
1008 def pull_request_delete(self):
1007 _ = self.request.translate
1009 _ = self.request.translate
1008
1010
1009 pull_request = PullRequest.get_or_404(
1011 pull_request = PullRequest.get_or_404(
1010 self.request.matchdict['pull_request_id'])
1012 self.request.matchdict['pull_request_id'])
1011
1013
1012 pr_closed = pull_request.is_closed()
1014 pr_closed = pull_request.is_closed()
1013 allowed_to_delete = PullRequestModel().check_user_delete(
1015 allowed_to_delete = PullRequestModel().check_user_delete(
1014 pull_request, self._rhodecode_user) and not pr_closed
1016 pull_request, self._rhodecode_user) and not pr_closed
1015
1017
1016 # only owner can delete it !
1018 # only owner can delete it !
1017 if allowed_to_delete:
1019 if allowed_to_delete:
1018 PullRequestModel().delete(pull_request, self._rhodecode_user)
1020 PullRequestModel().delete(pull_request, self._rhodecode_user)
1019 Session().commit()
1021 Session().commit()
1020 h.flash(_('Successfully deleted pull request'),
1022 h.flash(_('Successfully deleted pull request'),
1021 category='success')
1023 category='success')
1022 raise HTTPFound(h.route_path('pullrequest_show_all',
1024 raise HTTPFound(h.route_path('pullrequest_show_all',
1023 repo_name=self.db_repo_name))
1025 repo_name=self.db_repo_name))
1024
1026
1025 log.warning('user %s tried to delete pull request without access',
1027 log.warning('user %s tried to delete pull request without access',
1026 self._rhodecode_user)
1028 self._rhodecode_user)
1027 raise HTTPNotFound()
1029 raise HTTPNotFound()
1028
1030
1029 @LoginRequired()
1031 @LoginRequired()
1030 @NotAnonymous()
1032 @NotAnonymous()
1031 @HasRepoPermissionAnyDecorator(
1033 @HasRepoPermissionAnyDecorator(
1032 'repository.read', 'repository.write', 'repository.admin')
1034 'repository.read', 'repository.write', 'repository.admin')
1033 @CSRFRequired()
1035 @CSRFRequired()
1034 @view_config(
1036 @view_config(
1035 route_name='pullrequest_comment_create', request_method='POST',
1037 route_name='pullrequest_comment_create', request_method='POST',
1036 renderer='json_ext')
1038 renderer='json_ext')
1037 def pull_request_comment_create(self):
1039 def pull_request_comment_create(self):
1038 _ = self.request.translate
1040 _ = self.request.translate
1039
1041
1040 pull_request = PullRequest.get_or_404(
1042 pull_request = PullRequest.get_or_404(
1041 self.request.matchdict['pull_request_id'])
1043 self.request.matchdict['pull_request_id'])
1042 pull_request_id = pull_request.pull_request_id
1044 pull_request_id = pull_request.pull_request_id
1043
1045
1044 if pull_request.is_closed():
1046 if pull_request.is_closed():
1045 log.debug('comment: forbidden because pull request is closed')
1047 log.debug('comment: forbidden because pull request is closed')
1046 raise HTTPForbidden()
1048 raise HTTPForbidden()
1047
1049
1048 c = self.load_default_context()
1050 c = self.load_default_context()
1049
1051
1050 status = self.request.POST.get('changeset_status', None)
1052 status = self.request.POST.get('changeset_status', None)
1051 text = self.request.POST.get('text')
1053 text = self.request.POST.get('text')
1052 comment_type = self.request.POST.get('comment_type')
1054 comment_type = self.request.POST.get('comment_type')
1053 resolves_comment_id = self.request.POST.get('resolves_comment_id', None)
1055 resolves_comment_id = self.request.POST.get('resolves_comment_id', None)
1054 close_pull_request = self.request.POST.get('close_pull_request')
1056 close_pull_request = self.request.POST.get('close_pull_request')
1055
1057
1056 # the logic here should work like following, if we submit close
1058 # the logic here should work like following, if we submit close
1057 # pr comment, use `close_pull_request_with_comment` function
1059 # pr comment, use `close_pull_request_with_comment` function
1058 # else handle regular comment logic
1060 # else handle regular comment logic
1059
1061
1060 if close_pull_request:
1062 if close_pull_request:
1061 # only owner or admin or person with write permissions
1063 # only owner or admin or person with write permissions
1062 allowed_to_close = PullRequestModel().check_user_update(
1064 allowed_to_close = PullRequestModel().check_user_update(
1063 pull_request, self._rhodecode_user)
1065 pull_request, self._rhodecode_user)
1064 if not allowed_to_close:
1066 if not allowed_to_close:
1065 log.debug('comment: forbidden because not allowed to close '
1067 log.debug('comment: forbidden because not allowed to close '
1066 'pull request %s', pull_request_id)
1068 'pull request %s', pull_request_id)
1067 raise HTTPForbidden()
1069 raise HTTPForbidden()
1068 comment, status = PullRequestModel().close_pull_request_with_comment(
1070 comment, status = PullRequestModel().close_pull_request_with_comment(
1069 pull_request, self._rhodecode_user, self.db_repo, message=text)
1071 pull_request, self._rhodecode_user, self.db_repo, message=text)
1070 Session().flush()
1072 Session().flush()
1071 events.trigger(
1073 events.trigger(
1072 events.PullRequestCommentEvent(pull_request, comment))
1074 events.PullRequestCommentEvent(pull_request, comment))
1073
1075
1074 else:
1076 else:
1075 # regular comment case, could be inline, or one with status.
1077 # regular comment case, could be inline, or one with status.
1076 # for that one we check also permissions
1078 # for that one we check also permissions
1077
1079
1078 allowed_to_change_status = PullRequestModel().check_user_change_status(
1080 allowed_to_change_status = PullRequestModel().check_user_change_status(
1079 pull_request, self._rhodecode_user)
1081 pull_request, self._rhodecode_user)
1080
1082
1081 if status and allowed_to_change_status:
1083 if status and allowed_to_change_status:
1082 message = (_('Status change %(transition_icon)s %(status)s')
1084 message = (_('Status change %(transition_icon)s %(status)s')
1083 % {'transition_icon': '>',
1085 % {'transition_icon': '>',
1084 'status': ChangesetStatus.get_status_lbl(status)})
1086 'status': ChangesetStatus.get_status_lbl(status)})
1085 text = text or message
1087 text = text or message
1086
1088
1087 comment = CommentsModel().create(
1089 comment = CommentsModel().create(
1088 text=text,
1090 text=text,
1089 repo=self.db_repo.repo_id,
1091 repo=self.db_repo.repo_id,
1090 user=self._rhodecode_user.user_id,
1092 user=self._rhodecode_user.user_id,
1091 pull_request=pull_request,
1093 pull_request=pull_request,
1092 f_path=self.request.POST.get('f_path'),
1094 f_path=self.request.POST.get('f_path'),
1093 line_no=self.request.POST.get('line'),
1095 line_no=self.request.POST.get('line'),
1094 status_change=(ChangesetStatus.get_status_lbl(status)
1096 status_change=(ChangesetStatus.get_status_lbl(status)
1095 if status and allowed_to_change_status else None),
1097 if status and allowed_to_change_status else None),
1096 status_change_type=(status
1098 status_change_type=(status
1097 if status and allowed_to_change_status else None),
1099 if status and allowed_to_change_status else None),
1098 comment_type=comment_type,
1100 comment_type=comment_type,
1099 resolves_comment_id=resolves_comment_id
1101 resolves_comment_id=resolves_comment_id
1100 )
1102 )
1101
1103
1102 if allowed_to_change_status:
1104 if allowed_to_change_status:
1103 # calculate old status before we change it
1105 # calculate old status before we change it
1104 old_calculated_status = pull_request.calculated_review_status()
1106 old_calculated_status = pull_request.calculated_review_status()
1105
1107
1106 # get status if set !
1108 # get status if set !
1107 if status:
1109 if status:
1108 ChangesetStatusModel().set_status(
1110 ChangesetStatusModel().set_status(
1109 self.db_repo.repo_id,
1111 self.db_repo.repo_id,
1110 status,
1112 status,
1111 self._rhodecode_user.user_id,
1113 self._rhodecode_user.user_id,
1112 comment,
1114 comment,
1113 pull_request=pull_request
1115 pull_request=pull_request
1114 )
1116 )
1115
1117
1116 Session().flush()
1118 Session().flush()
1117 events.trigger(
1119 events.trigger(
1118 events.PullRequestCommentEvent(pull_request, comment))
1120 events.PullRequestCommentEvent(pull_request, comment))
1119
1121
1120 # we now calculate the status of pull request, and based on that
1122 # we now calculate the status of pull request, and based on that
1121 # calculation we set the commits status
1123 # calculation we set the commits status
1122 calculated_status = pull_request.calculated_review_status()
1124 calculated_status = pull_request.calculated_review_status()
1123 if old_calculated_status != calculated_status:
1125 if old_calculated_status != calculated_status:
1124 PullRequestModel()._trigger_pull_request_hook(
1126 PullRequestModel()._trigger_pull_request_hook(
1125 pull_request, self._rhodecode_user, 'review_status_change')
1127 pull_request, self._rhodecode_user, 'review_status_change')
1126
1128
1127 Session().commit()
1129 Session().commit()
1128
1130
1129 data = {
1131 data = {
1130 'target_id': h.safeid(h.safe_unicode(
1132 'target_id': h.safeid(h.safe_unicode(
1131 self.request.POST.get('f_path'))),
1133 self.request.POST.get('f_path'))),
1132 }
1134 }
1133 if comment:
1135 if comment:
1134 c.co = comment
1136 c.co = comment
1135 rendered_comment = render(
1137 rendered_comment = render(
1136 'rhodecode:templates/changeset/changeset_comment_block.mako',
1138 'rhodecode:templates/changeset/changeset_comment_block.mako',
1137 self._get_template_context(c), self.request)
1139 self._get_template_context(c), self.request)
1138
1140
1139 data.update(comment.get_dict())
1141 data.update(comment.get_dict())
1140 data.update({'rendered_text': rendered_comment})
1142 data.update({'rendered_text': rendered_comment})
1141
1143
1142 return data
1144 return data
1143
1145
1144 @LoginRequired()
1146 @LoginRequired()
1145 @NotAnonymous()
1147 @NotAnonymous()
1146 @HasRepoPermissionAnyDecorator(
1148 @HasRepoPermissionAnyDecorator(
1147 'repository.read', 'repository.write', 'repository.admin')
1149 'repository.read', 'repository.write', 'repository.admin')
1148 @CSRFRequired()
1150 @CSRFRequired()
1149 @view_config(
1151 @view_config(
1150 route_name='pullrequest_comment_delete', request_method='POST',
1152 route_name='pullrequest_comment_delete', request_method='POST',
1151 renderer='json_ext')
1153 renderer='json_ext')
1152 def pull_request_comment_delete(self):
1154 def pull_request_comment_delete(self):
1153 pull_request = PullRequest.get_or_404(
1155 pull_request = PullRequest.get_or_404(
1154 self.request.matchdict['pull_request_id'])
1156 self.request.matchdict['pull_request_id'])
1155
1157
1156 comment = ChangesetComment.get_or_404(
1158 comment = ChangesetComment.get_or_404(
1157 self.request.matchdict['comment_id'])
1159 self.request.matchdict['comment_id'])
1158 comment_id = comment.comment_id
1160 comment_id = comment.comment_id
1159
1161
1160 if pull_request.is_closed():
1162 if pull_request.is_closed():
1161 log.debug('comment: forbidden because pull request is closed')
1163 log.debug('comment: forbidden because pull request is closed')
1162 raise HTTPForbidden()
1164 raise HTTPForbidden()
1163
1165
1164 if not comment:
1166 if not comment:
1165 log.debug('Comment with id:%s not found, skipping', comment_id)
1167 log.debug('Comment with id:%s not found, skipping', comment_id)
1166 # comment already deleted in another call probably
1168 # comment already deleted in another call probably
1167 return True
1169 return True
1168
1170
1169 if comment.pull_request.is_closed():
1171 if comment.pull_request.is_closed():
1170 # don't allow deleting comments on closed pull request
1172 # don't allow deleting comments on closed pull request
1171 raise HTTPForbidden()
1173 raise HTTPForbidden()
1172
1174
1173 is_repo_admin = h.HasRepoPermissionAny('repository.admin')(self.db_repo_name)
1175 is_repo_admin = h.HasRepoPermissionAny('repository.admin')(self.db_repo_name)
1174 super_admin = h.HasPermissionAny('hg.admin')()
1176 super_admin = h.HasPermissionAny('hg.admin')()
1175 comment_owner = comment.author.user_id == self._rhodecode_user.user_id
1177 comment_owner = comment.author.user_id == self._rhodecode_user.user_id
1176 is_repo_comment = comment.repo.repo_name == self.db_repo_name
1178 is_repo_comment = comment.repo.repo_name == self.db_repo_name
1177 comment_repo_admin = is_repo_admin and is_repo_comment
1179 comment_repo_admin = is_repo_admin and is_repo_comment
1178
1180
1179 if super_admin or comment_owner or comment_repo_admin:
1181 if super_admin or comment_owner or comment_repo_admin:
1180 old_calculated_status = comment.pull_request.calculated_review_status()
1182 old_calculated_status = comment.pull_request.calculated_review_status()
1181 CommentsModel().delete(comment=comment, user=self._rhodecode_user)
1183 CommentsModel().delete(comment=comment, user=self._rhodecode_user)
1182 Session().commit()
1184 Session().commit()
1183 calculated_status = comment.pull_request.calculated_review_status()
1185 calculated_status = comment.pull_request.calculated_review_status()
1184 if old_calculated_status != calculated_status:
1186 if old_calculated_status != calculated_status:
1185 PullRequestModel()._trigger_pull_request_hook(
1187 PullRequestModel()._trigger_pull_request_hook(
1186 comment.pull_request, self._rhodecode_user, 'review_status_change')
1188 comment.pull_request, self._rhodecode_user, 'review_status_change')
1187 return True
1189 return True
1188 else:
1190 else:
1189 log.warning('No permissions for user %s to delete comment_id: %s',
1191 log.warning('No permissions for user %s to delete comment_id: %s',
1190 self._rhodecode_db_user, comment_id)
1192 self._rhodecode_db_user, comment_id)
1191 raise HTTPNotFound()
1193 raise HTTPNotFound()
@@ -1,1552 +1,1584 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2012-2017 RhodeCode GmbH
3 # Copyright (C) 2012-2017 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21
21
22 """
22 """
23 pull request model for RhodeCode
23 pull request model for RhodeCode
24 """
24 """
25
25
26 from collections import namedtuple
26 from collections import namedtuple
27 import json
27 import json
28 import logging
28 import logging
29 import datetime
29 import datetime
30 import urllib
30 import urllib
31
31
32 from pylons.i18n.translation import _
32 from pylons.i18n.translation import _
33 from pylons.i18n.translation import lazy_ugettext
33 from pylons.i18n.translation import lazy_ugettext
34 from pyramid.threadlocal import get_current_request
34 from pyramid.threadlocal import get_current_request
35 from sqlalchemy import or_
35 from sqlalchemy import or_
36
36
37 from rhodecode import events
37 from rhodecode import events
38 from rhodecode.lib import helpers as h, hooks_utils, diffs
38 from rhodecode.lib import helpers as h, hooks_utils, diffs
39 from rhodecode.lib import audit_logger
39 from rhodecode.lib import audit_logger
40 from rhodecode.lib.compat import OrderedDict
40 from rhodecode.lib.compat import OrderedDict
41 from rhodecode.lib.hooks_daemon import prepare_callback_daemon
41 from rhodecode.lib.hooks_daemon import prepare_callback_daemon
42 from rhodecode.lib.markup_renderer import (
42 from rhodecode.lib.markup_renderer import (
43 DEFAULT_COMMENTS_RENDERER, RstTemplateRenderer)
43 DEFAULT_COMMENTS_RENDERER, RstTemplateRenderer)
44 from rhodecode.lib.utils2 import safe_unicode, safe_str, md5_safe
44 from rhodecode.lib.utils2 import safe_unicode, safe_str, md5_safe
45 from rhodecode.lib.vcs.backends.base import (
45 from rhodecode.lib.vcs.backends.base import (
46 Reference, MergeResponse, MergeFailureReason, UpdateFailureReason)
46 Reference, MergeResponse, MergeFailureReason, UpdateFailureReason)
47 from rhodecode.lib.vcs.conf import settings as vcs_settings
47 from rhodecode.lib.vcs.conf import settings as vcs_settings
48 from rhodecode.lib.vcs.exceptions import (
48 from rhodecode.lib.vcs.exceptions import (
49 CommitDoesNotExistError, EmptyRepositoryError)
49 CommitDoesNotExistError, EmptyRepositoryError)
50 from rhodecode.model import BaseModel
50 from rhodecode.model import BaseModel
51 from rhodecode.model.changeset_status import ChangesetStatusModel
51 from rhodecode.model.changeset_status import ChangesetStatusModel
52 from rhodecode.model.comment import CommentsModel
52 from rhodecode.model.comment import CommentsModel
53 from rhodecode.model.db import (
53 from rhodecode.model.db import (
54 PullRequest, PullRequestReviewers, ChangesetStatus,
54 PullRequest, PullRequestReviewers, ChangesetStatus,
55 PullRequestVersion, ChangesetComment, Repository)
55 PullRequestVersion, ChangesetComment, Repository)
56 from rhodecode.model.meta import Session
56 from rhodecode.model.meta import Session
57 from rhodecode.model.notification import NotificationModel, \
57 from rhodecode.model.notification import NotificationModel, \
58 EmailNotificationModel
58 EmailNotificationModel
59 from rhodecode.model.scm import ScmModel
59 from rhodecode.model.scm import ScmModel
60 from rhodecode.model.settings import VcsSettingsModel
60 from rhodecode.model.settings import VcsSettingsModel
61
61
62
62
63 log = logging.getLogger(__name__)
63 log = logging.getLogger(__name__)
64
64
65
65
66 # Data structure to hold the response data when updating commits during a pull
66 # Data structure to hold the response data when updating commits during a pull
67 # request update.
67 # request update.
68 UpdateResponse = namedtuple('UpdateResponse', [
68 UpdateResponse = namedtuple('UpdateResponse', [
69 'executed', 'reason', 'new', 'old', 'changes',
69 'executed', 'reason', 'new', 'old', 'changes',
70 'source_changed', 'target_changed'])
70 'source_changed', 'target_changed'])
71
71
72
72
73 class PullRequestModel(BaseModel):
73 class PullRequestModel(BaseModel):
74
74
75 cls = PullRequest
75 cls = PullRequest
76
76
77 DIFF_CONTEXT = 3
77 DIFF_CONTEXT = 3
78
78
79 MERGE_STATUS_MESSAGES = {
79 MERGE_STATUS_MESSAGES = {
80 MergeFailureReason.NONE: lazy_ugettext(
80 MergeFailureReason.NONE: lazy_ugettext(
81 'This pull request can be automatically merged.'),
81 'This pull request can be automatically merged.'),
82 MergeFailureReason.UNKNOWN: lazy_ugettext(
82 MergeFailureReason.UNKNOWN: lazy_ugettext(
83 'This pull request cannot be merged because of an unhandled'
83 'This pull request cannot be merged because of an unhandled'
84 ' exception.'),
84 ' exception.'),
85 MergeFailureReason.MERGE_FAILED: lazy_ugettext(
85 MergeFailureReason.MERGE_FAILED: lazy_ugettext(
86 'This pull request cannot be merged because of merge conflicts.'),
86 'This pull request cannot be merged because of merge conflicts.'),
87 MergeFailureReason.PUSH_FAILED: lazy_ugettext(
87 MergeFailureReason.PUSH_FAILED: lazy_ugettext(
88 'This pull request could not be merged because push to target'
88 'This pull request could not be merged because push to target'
89 ' failed.'),
89 ' failed.'),
90 MergeFailureReason.TARGET_IS_NOT_HEAD: lazy_ugettext(
90 MergeFailureReason.TARGET_IS_NOT_HEAD: lazy_ugettext(
91 'This pull request cannot be merged because the target is not a'
91 'This pull request cannot be merged because the target is not a'
92 ' head.'),
92 ' head.'),
93 MergeFailureReason.HG_SOURCE_HAS_MORE_BRANCHES: lazy_ugettext(
93 MergeFailureReason.HG_SOURCE_HAS_MORE_BRANCHES: lazy_ugettext(
94 'This pull request cannot be merged because the source contains'
94 'This pull request cannot be merged because the source contains'
95 ' more branches than the target.'),
95 ' more branches than the target.'),
96 MergeFailureReason.HG_TARGET_HAS_MULTIPLE_HEADS: lazy_ugettext(
96 MergeFailureReason.HG_TARGET_HAS_MULTIPLE_HEADS: lazy_ugettext(
97 'This pull request cannot be merged because the target has'
97 'This pull request cannot be merged because the target has'
98 ' multiple heads.'),
98 ' multiple heads.'),
99 MergeFailureReason.TARGET_IS_LOCKED: lazy_ugettext(
99 MergeFailureReason.TARGET_IS_LOCKED: lazy_ugettext(
100 'This pull request cannot be merged because the target repository'
100 'This pull request cannot be merged because the target repository'
101 ' is locked.'),
101 ' is locked.'),
102 MergeFailureReason._DEPRECATED_MISSING_COMMIT: lazy_ugettext(
102 MergeFailureReason._DEPRECATED_MISSING_COMMIT: lazy_ugettext(
103 'This pull request cannot be merged because the target or the '
103 'This pull request cannot be merged because the target or the '
104 'source reference is missing.'),
104 'source reference is missing.'),
105 MergeFailureReason.MISSING_TARGET_REF: lazy_ugettext(
105 MergeFailureReason.MISSING_TARGET_REF: lazy_ugettext(
106 'This pull request cannot be merged because the target '
106 'This pull request cannot be merged because the target '
107 'reference is missing.'),
107 'reference is missing.'),
108 MergeFailureReason.MISSING_SOURCE_REF: lazy_ugettext(
108 MergeFailureReason.MISSING_SOURCE_REF: lazy_ugettext(
109 'This pull request cannot be merged because the source '
109 'This pull request cannot be merged because the source '
110 'reference is missing.'),
110 'reference is missing.'),
111 MergeFailureReason.SUBREPO_MERGE_FAILED: lazy_ugettext(
111 MergeFailureReason.SUBREPO_MERGE_FAILED: lazy_ugettext(
112 'This pull request cannot be merged because of conflicts related '
112 'This pull request cannot be merged because of conflicts related '
113 'to sub repositories.'),
113 'to sub repositories.'),
114 }
114 }
115
115
116 UPDATE_STATUS_MESSAGES = {
116 UPDATE_STATUS_MESSAGES = {
117 UpdateFailureReason.NONE: lazy_ugettext(
117 UpdateFailureReason.NONE: lazy_ugettext(
118 'Pull request update successful.'),
118 'Pull request update successful.'),
119 UpdateFailureReason.UNKNOWN: lazy_ugettext(
119 UpdateFailureReason.UNKNOWN: lazy_ugettext(
120 'Pull request update failed because of an unknown error.'),
120 'Pull request update failed because of an unknown error.'),
121 UpdateFailureReason.NO_CHANGE: lazy_ugettext(
121 UpdateFailureReason.NO_CHANGE: lazy_ugettext(
122 'No update needed because the source and target have not changed.'),
122 'No update needed because the source and target have not changed.'),
123 UpdateFailureReason.WRONG_REF_TYPE: lazy_ugettext(
123 UpdateFailureReason.WRONG_REF_TYPE: lazy_ugettext(
124 'Pull request cannot be updated because the reference type is '
124 'Pull request cannot be updated because the reference type is '
125 'not supported for an update. Only Branch, Tag or Bookmark is allowed.'),
125 'not supported for an update. Only Branch, Tag or Bookmark is allowed.'),
126 UpdateFailureReason.MISSING_TARGET_REF: lazy_ugettext(
126 UpdateFailureReason.MISSING_TARGET_REF: lazy_ugettext(
127 'This pull request cannot be updated because the target '
127 'This pull request cannot be updated because the target '
128 'reference is missing.'),
128 'reference is missing.'),
129 UpdateFailureReason.MISSING_SOURCE_REF: lazy_ugettext(
129 UpdateFailureReason.MISSING_SOURCE_REF: lazy_ugettext(
130 'This pull request cannot be updated because the source '
130 'This pull request cannot be updated because the source '
131 'reference is missing.'),
131 'reference is missing.'),
132 }
132 }
133
133
134 def __get_pull_request(self, pull_request):
134 def __get_pull_request(self, pull_request):
135 return self._get_instance((
135 return self._get_instance((
136 PullRequest, PullRequestVersion), pull_request)
136 PullRequest, PullRequestVersion), pull_request)
137
137
138 def _check_perms(self, perms, pull_request, user, api=False):
138 def _check_perms(self, perms, pull_request, user, api=False):
139 if not api:
139 if not api:
140 return h.HasRepoPermissionAny(*perms)(
140 return h.HasRepoPermissionAny(*perms)(
141 user=user, repo_name=pull_request.target_repo.repo_name)
141 user=user, repo_name=pull_request.target_repo.repo_name)
142 else:
142 else:
143 return h.HasRepoPermissionAnyApi(*perms)(
143 return h.HasRepoPermissionAnyApi(*perms)(
144 user=user, repo_name=pull_request.target_repo.repo_name)
144 user=user, repo_name=pull_request.target_repo.repo_name)
145
145
146 def check_user_read(self, pull_request, user, api=False):
146 def check_user_read(self, pull_request, user, api=False):
147 _perms = ('repository.admin', 'repository.write', 'repository.read',)
147 _perms = ('repository.admin', 'repository.write', 'repository.read',)
148 return self._check_perms(_perms, pull_request, user, api)
148 return self._check_perms(_perms, pull_request, user, api)
149
149
150 def check_user_merge(self, pull_request, user, api=False):
150 def check_user_merge(self, pull_request, user, api=False):
151 _perms = ('repository.admin', 'repository.write', 'hg.admin',)
151 _perms = ('repository.admin', 'repository.write', 'hg.admin',)
152 return self._check_perms(_perms, pull_request, user, api)
152 return self._check_perms(_perms, pull_request, user, api)
153
153
154 def check_user_update(self, pull_request, user, api=False):
154 def check_user_update(self, pull_request, user, api=False):
155 owner = user.user_id == pull_request.user_id
155 owner = user.user_id == pull_request.user_id
156 return self.check_user_merge(pull_request, user, api) or owner
156 return self.check_user_merge(pull_request, user, api) or owner
157
157
158 def check_user_delete(self, pull_request, user):
158 def check_user_delete(self, pull_request, user):
159 owner = user.user_id == pull_request.user_id
159 owner = user.user_id == pull_request.user_id
160 _perms = ('repository.admin',)
160 _perms = ('repository.admin',)
161 return self._check_perms(_perms, pull_request, user) or owner
161 return self._check_perms(_perms, pull_request, user) or owner
162
162
163 def check_user_change_status(self, pull_request, user, api=False):
163 def check_user_change_status(self, pull_request, user, api=False):
164 reviewer = user.user_id in [x.user_id for x in
164 reviewer = user.user_id in [x.user_id for x in
165 pull_request.reviewers]
165 pull_request.reviewers]
166 return self.check_user_update(pull_request, user, api) or reviewer
166 return self.check_user_update(pull_request, user, api) or reviewer
167
167
168 def get(self, pull_request):
168 def get(self, pull_request):
169 return self.__get_pull_request(pull_request)
169 return self.__get_pull_request(pull_request)
170
170
171 def _prepare_get_all_query(self, repo_name, source=False, statuses=None,
171 def _prepare_get_all_query(self, repo_name, source=False, statuses=None,
172 opened_by=None, order_by=None,
172 opened_by=None, order_by=None,
173 order_dir='desc'):
173 order_dir='desc'):
174 repo = None
174 repo = None
175 if repo_name:
175 if repo_name:
176 repo = self._get_repo(repo_name)
176 repo = self._get_repo(repo_name)
177
177
178 q = PullRequest.query()
178 q = PullRequest.query()
179
179
180 # source or target
180 # source or target
181 if repo and source:
181 if repo and source:
182 q = q.filter(PullRequest.source_repo == repo)
182 q = q.filter(PullRequest.source_repo == repo)
183 elif repo:
183 elif repo:
184 q = q.filter(PullRequest.target_repo == repo)
184 q = q.filter(PullRequest.target_repo == repo)
185
185
186 # closed,opened
186 # closed,opened
187 if statuses:
187 if statuses:
188 q = q.filter(PullRequest.status.in_(statuses))
188 q = q.filter(PullRequest.status.in_(statuses))
189
189
190 # opened by filter
190 # opened by filter
191 if opened_by:
191 if opened_by:
192 q = q.filter(PullRequest.user_id.in_(opened_by))
192 q = q.filter(PullRequest.user_id.in_(opened_by))
193
193
194 if order_by:
194 if order_by:
195 order_map = {
195 order_map = {
196 'name_raw': PullRequest.pull_request_id,
196 'name_raw': PullRequest.pull_request_id,
197 'title': PullRequest.title,
197 'title': PullRequest.title,
198 'updated_on_raw': PullRequest.updated_on,
198 'updated_on_raw': PullRequest.updated_on,
199 'target_repo': PullRequest.target_repo_id
199 'target_repo': PullRequest.target_repo_id
200 }
200 }
201 if order_dir == 'asc':
201 if order_dir == 'asc':
202 q = q.order_by(order_map[order_by].asc())
202 q = q.order_by(order_map[order_by].asc())
203 else:
203 else:
204 q = q.order_by(order_map[order_by].desc())
204 q = q.order_by(order_map[order_by].desc())
205
205
206 return q
206 return q
207
207
208 def count_all(self, repo_name, source=False, statuses=None,
208 def count_all(self, repo_name, source=False, statuses=None,
209 opened_by=None):
209 opened_by=None):
210 """
210 """
211 Count the number of pull requests for a specific repository.
211 Count the number of pull requests for a specific repository.
212
212
213 :param repo_name: target or source repo
213 :param repo_name: target or source repo
214 :param source: boolean flag to specify if repo_name refers to source
214 :param source: boolean flag to specify if repo_name refers to source
215 :param statuses: list of pull request statuses
215 :param statuses: list of pull request statuses
216 :param opened_by: author user of the pull request
216 :param opened_by: author user of the pull request
217 :returns: int number of pull requests
217 :returns: int number of pull requests
218 """
218 """
219 q = self._prepare_get_all_query(
219 q = self._prepare_get_all_query(
220 repo_name, source=source, statuses=statuses, opened_by=opened_by)
220 repo_name, source=source, statuses=statuses, opened_by=opened_by)
221
221
222 return q.count()
222 return q.count()
223
223
224 def get_all(self, repo_name, source=False, statuses=None, opened_by=None,
224 def get_all(self, repo_name, source=False, statuses=None, opened_by=None,
225 offset=0, length=None, order_by=None, order_dir='desc'):
225 offset=0, length=None, order_by=None, order_dir='desc'):
226 """
226 """
227 Get all pull requests for a specific repository.
227 Get all pull requests for a specific repository.
228
228
229 :param repo_name: target or source repo
229 :param repo_name: target or source repo
230 :param source: boolean flag to specify if repo_name refers to source
230 :param source: boolean flag to specify if repo_name refers to source
231 :param statuses: list of pull request statuses
231 :param statuses: list of pull request statuses
232 :param opened_by: author user of the pull request
232 :param opened_by: author user of the pull request
233 :param offset: pagination offset
233 :param offset: pagination offset
234 :param length: length of returned list
234 :param length: length of returned list
235 :param order_by: order of the returned list
235 :param order_by: order of the returned list
236 :param order_dir: 'asc' or 'desc' ordering direction
236 :param order_dir: 'asc' or 'desc' ordering direction
237 :returns: list of pull requests
237 :returns: list of pull requests
238 """
238 """
239 q = self._prepare_get_all_query(
239 q = self._prepare_get_all_query(
240 repo_name, source=source, statuses=statuses, opened_by=opened_by,
240 repo_name, source=source, statuses=statuses, opened_by=opened_by,
241 order_by=order_by, order_dir=order_dir)
241 order_by=order_by, order_dir=order_dir)
242
242
243 if length:
243 if length:
244 pull_requests = q.limit(length).offset(offset).all()
244 pull_requests = q.limit(length).offset(offset).all()
245 else:
245 else:
246 pull_requests = q.all()
246 pull_requests = q.all()
247
247
248 return pull_requests
248 return pull_requests
249
249
250 def count_awaiting_review(self, repo_name, source=False, statuses=None,
250 def count_awaiting_review(self, repo_name, source=False, statuses=None,
251 opened_by=None):
251 opened_by=None):
252 """
252 """
253 Count the number of pull requests for a specific repository that are
253 Count the number of pull requests for a specific repository that are
254 awaiting review.
254 awaiting review.
255
255
256 :param repo_name: target or source repo
256 :param repo_name: target or source repo
257 :param source: boolean flag to specify if repo_name refers to source
257 :param source: boolean flag to specify if repo_name refers to source
258 :param statuses: list of pull request statuses
258 :param statuses: list of pull request statuses
259 :param opened_by: author user of the pull request
259 :param opened_by: author user of the pull request
260 :returns: int number of pull requests
260 :returns: int number of pull requests
261 """
261 """
262 pull_requests = self.get_awaiting_review(
262 pull_requests = self.get_awaiting_review(
263 repo_name, source=source, statuses=statuses, opened_by=opened_by)
263 repo_name, source=source, statuses=statuses, opened_by=opened_by)
264
264
265 return len(pull_requests)
265 return len(pull_requests)
266
266
267 def get_awaiting_review(self, repo_name, source=False, statuses=None,
267 def get_awaiting_review(self, repo_name, source=False, statuses=None,
268 opened_by=None, offset=0, length=None,
268 opened_by=None, offset=0, length=None,
269 order_by=None, order_dir='desc'):
269 order_by=None, order_dir='desc'):
270 """
270 """
271 Get all pull requests for a specific repository that are awaiting
271 Get all pull requests for a specific repository that are awaiting
272 review.
272 review.
273
273
274 :param repo_name: target or source repo
274 :param repo_name: target or source repo
275 :param source: boolean flag to specify if repo_name refers to source
275 :param source: boolean flag to specify if repo_name refers to source
276 :param statuses: list of pull request statuses
276 :param statuses: list of pull request statuses
277 :param opened_by: author user of the pull request
277 :param opened_by: author user of the pull request
278 :param offset: pagination offset
278 :param offset: pagination offset
279 :param length: length of returned list
279 :param length: length of returned list
280 :param order_by: order of the returned list
280 :param order_by: order of the returned list
281 :param order_dir: 'asc' or 'desc' ordering direction
281 :param order_dir: 'asc' or 'desc' ordering direction
282 :returns: list of pull requests
282 :returns: list of pull requests
283 """
283 """
284 pull_requests = self.get_all(
284 pull_requests = self.get_all(
285 repo_name, source=source, statuses=statuses, opened_by=opened_by,
285 repo_name, source=source, statuses=statuses, opened_by=opened_by,
286 order_by=order_by, order_dir=order_dir)
286 order_by=order_by, order_dir=order_dir)
287
287
288 _filtered_pull_requests = []
288 _filtered_pull_requests = []
289 for pr in pull_requests:
289 for pr in pull_requests:
290 status = pr.calculated_review_status()
290 status = pr.calculated_review_status()
291 if status in [ChangesetStatus.STATUS_NOT_REVIEWED,
291 if status in [ChangesetStatus.STATUS_NOT_REVIEWED,
292 ChangesetStatus.STATUS_UNDER_REVIEW]:
292 ChangesetStatus.STATUS_UNDER_REVIEW]:
293 _filtered_pull_requests.append(pr)
293 _filtered_pull_requests.append(pr)
294 if length:
294 if length:
295 return _filtered_pull_requests[offset:offset+length]
295 return _filtered_pull_requests[offset:offset+length]
296 else:
296 else:
297 return _filtered_pull_requests
297 return _filtered_pull_requests
298
298
299 def count_awaiting_my_review(self, repo_name, source=False, statuses=None,
299 def count_awaiting_my_review(self, repo_name, source=False, statuses=None,
300 opened_by=None, user_id=None):
300 opened_by=None, user_id=None):
301 """
301 """
302 Count the number of pull requests for a specific repository that are
302 Count the number of pull requests for a specific repository that are
303 awaiting review from a specific user.
303 awaiting review from a specific user.
304
304
305 :param repo_name: target or source repo
305 :param repo_name: target or source repo
306 :param source: boolean flag to specify if repo_name refers to source
306 :param source: boolean flag to specify if repo_name refers to source
307 :param statuses: list of pull request statuses
307 :param statuses: list of pull request statuses
308 :param opened_by: author user of the pull request
308 :param opened_by: author user of the pull request
309 :param user_id: reviewer user of the pull request
309 :param user_id: reviewer user of the pull request
310 :returns: int number of pull requests
310 :returns: int number of pull requests
311 """
311 """
312 pull_requests = self.get_awaiting_my_review(
312 pull_requests = self.get_awaiting_my_review(
313 repo_name, source=source, statuses=statuses, opened_by=opened_by,
313 repo_name, source=source, statuses=statuses, opened_by=opened_by,
314 user_id=user_id)
314 user_id=user_id)
315
315
316 return len(pull_requests)
316 return len(pull_requests)
317
317
318 def get_awaiting_my_review(self, repo_name, source=False, statuses=None,
318 def get_awaiting_my_review(self, repo_name, source=False, statuses=None,
319 opened_by=None, user_id=None, offset=0,
319 opened_by=None, user_id=None, offset=0,
320 length=None, order_by=None, order_dir='desc'):
320 length=None, order_by=None, order_dir='desc'):
321 """
321 """
322 Get all pull requests for a specific repository that are awaiting
322 Get all pull requests for a specific repository that are awaiting
323 review from a specific user.
323 review from a specific user.
324
324
325 :param repo_name: target or source repo
325 :param repo_name: target or source repo
326 :param source: boolean flag to specify if repo_name refers to source
326 :param source: boolean flag to specify if repo_name refers to source
327 :param statuses: list of pull request statuses
327 :param statuses: list of pull request statuses
328 :param opened_by: author user of the pull request
328 :param opened_by: author user of the pull request
329 :param user_id: reviewer user of the pull request
329 :param user_id: reviewer user of the pull request
330 :param offset: pagination offset
330 :param offset: pagination offset
331 :param length: length of returned list
331 :param length: length of returned list
332 :param order_by: order of the returned list
332 :param order_by: order of the returned list
333 :param order_dir: 'asc' or 'desc' ordering direction
333 :param order_dir: 'asc' or 'desc' ordering direction
334 :returns: list of pull requests
334 :returns: list of pull requests
335 """
335 """
336 pull_requests = self.get_all(
336 pull_requests = self.get_all(
337 repo_name, source=source, statuses=statuses, opened_by=opened_by,
337 repo_name, source=source, statuses=statuses, opened_by=opened_by,
338 order_by=order_by, order_dir=order_dir)
338 order_by=order_by, order_dir=order_dir)
339
339
340 _my = PullRequestModel().get_not_reviewed(user_id)
340 _my = PullRequestModel().get_not_reviewed(user_id)
341 my_participation = []
341 my_participation = []
342 for pr in pull_requests:
342 for pr in pull_requests:
343 if pr in _my:
343 if pr in _my:
344 my_participation.append(pr)
344 my_participation.append(pr)
345 _filtered_pull_requests = my_participation
345 _filtered_pull_requests = my_participation
346 if length:
346 if length:
347 return _filtered_pull_requests[offset:offset+length]
347 return _filtered_pull_requests[offset:offset+length]
348 else:
348 else:
349 return _filtered_pull_requests
349 return _filtered_pull_requests
350
350
351 def get_not_reviewed(self, user_id):
351 def get_not_reviewed(self, user_id):
352 return [
352 return [
353 x.pull_request for x in PullRequestReviewers.query().filter(
353 x.pull_request for x in PullRequestReviewers.query().filter(
354 PullRequestReviewers.user_id == user_id).all()
354 PullRequestReviewers.user_id == user_id).all()
355 ]
355 ]
356
356
357 def _prepare_participating_query(self, user_id=None, statuses=None,
357 def _prepare_participating_query(self, user_id=None, statuses=None,
358 order_by=None, order_dir='desc'):
358 order_by=None, order_dir='desc'):
359 q = PullRequest.query()
359 q = PullRequest.query()
360 if user_id:
360 if user_id:
361 reviewers_subquery = Session().query(
361 reviewers_subquery = Session().query(
362 PullRequestReviewers.pull_request_id).filter(
362 PullRequestReviewers.pull_request_id).filter(
363 PullRequestReviewers.user_id == user_id).subquery()
363 PullRequestReviewers.user_id == user_id).subquery()
364 user_filter= or_(
364 user_filter= or_(
365 PullRequest.user_id == user_id,
365 PullRequest.user_id == user_id,
366 PullRequest.pull_request_id.in_(reviewers_subquery)
366 PullRequest.pull_request_id.in_(reviewers_subquery)
367 )
367 )
368 q = PullRequest.query().filter(user_filter)
368 q = PullRequest.query().filter(user_filter)
369
369
370 # closed,opened
370 # closed,opened
371 if statuses:
371 if statuses:
372 q = q.filter(PullRequest.status.in_(statuses))
372 q = q.filter(PullRequest.status.in_(statuses))
373
373
374 if order_by:
374 if order_by:
375 order_map = {
375 order_map = {
376 'name_raw': PullRequest.pull_request_id,
376 'name_raw': PullRequest.pull_request_id,
377 'title': PullRequest.title,
377 'title': PullRequest.title,
378 'updated_on_raw': PullRequest.updated_on,
378 'updated_on_raw': PullRequest.updated_on,
379 'target_repo': PullRequest.target_repo_id
379 'target_repo': PullRequest.target_repo_id
380 }
380 }
381 if order_dir == 'asc':
381 if order_dir == 'asc':
382 q = q.order_by(order_map[order_by].asc())
382 q = q.order_by(order_map[order_by].asc())
383 else:
383 else:
384 q = q.order_by(order_map[order_by].desc())
384 q = q.order_by(order_map[order_by].desc())
385
385
386 return q
386 return q
387
387
388 def count_im_participating_in(self, user_id=None, statuses=None):
388 def count_im_participating_in(self, user_id=None, statuses=None):
389 q = self._prepare_participating_query(user_id, statuses=statuses)
389 q = self._prepare_participating_query(user_id, statuses=statuses)
390 return q.count()
390 return q.count()
391
391
392 def get_im_participating_in(
392 def get_im_participating_in(
393 self, user_id=None, statuses=None, offset=0,
393 self, user_id=None, statuses=None, offset=0,
394 length=None, order_by=None, order_dir='desc'):
394 length=None, order_by=None, order_dir='desc'):
395 """
395 """
396 Get all Pull requests that i'm participating in, or i have opened
396 Get all Pull requests that i'm participating in, or i have opened
397 """
397 """
398
398
399 q = self._prepare_participating_query(
399 q = self._prepare_participating_query(
400 user_id, statuses=statuses, order_by=order_by,
400 user_id, statuses=statuses, order_by=order_by,
401 order_dir=order_dir)
401 order_dir=order_dir)
402
402
403 if length:
403 if length:
404 pull_requests = q.limit(length).offset(offset).all()
404 pull_requests = q.limit(length).offset(offset).all()
405 else:
405 else:
406 pull_requests = q.all()
406 pull_requests = q.all()
407
407
408 return pull_requests
408 return pull_requests
409
409
410 def get_versions(self, pull_request):
410 def get_versions(self, pull_request):
411 """
411 """
412 returns version of pull request sorted by ID descending
412 returns version of pull request sorted by ID descending
413 """
413 """
414 return PullRequestVersion.query()\
414 return PullRequestVersion.query()\
415 .filter(PullRequestVersion.pull_request == pull_request)\
415 .filter(PullRequestVersion.pull_request == pull_request)\
416 .order_by(PullRequestVersion.pull_request_version_id.asc())\
416 .order_by(PullRequestVersion.pull_request_version_id.asc())\
417 .all()
417 .all()
418
418
419 def create(self, created_by, source_repo, source_ref, target_repo,
419 def create(self, created_by, source_repo, source_ref, target_repo,
420 target_ref, revisions, reviewers, title, description=None,
420 target_ref, revisions, reviewers, title, description=None,
421 reviewer_data=None):
421 reviewer_data=None):
422
422
423 created_by_user = self._get_user(created_by)
423 created_by_user = self._get_user(created_by)
424 source_repo = self._get_repo(source_repo)
424 source_repo = self._get_repo(source_repo)
425 target_repo = self._get_repo(target_repo)
425 target_repo = self._get_repo(target_repo)
426
426
427 pull_request = PullRequest()
427 pull_request = PullRequest()
428 pull_request.source_repo = source_repo
428 pull_request.source_repo = source_repo
429 pull_request.source_ref = source_ref
429 pull_request.source_ref = source_ref
430 pull_request.target_repo = target_repo
430 pull_request.target_repo = target_repo
431 pull_request.target_ref = target_ref
431 pull_request.target_ref = target_ref
432 pull_request.revisions = revisions
432 pull_request.revisions = revisions
433 pull_request.title = title
433 pull_request.title = title
434 pull_request.description = description
434 pull_request.description = description
435 pull_request.author = created_by_user
435 pull_request.author = created_by_user
436 pull_request.reviewer_data = reviewer_data
436 pull_request.reviewer_data = reviewer_data
437
437
438 Session().add(pull_request)
438 Session().add(pull_request)
439 Session().flush()
439 Session().flush()
440
440
441 reviewer_ids = set()
441 reviewer_ids = set()
442 # members / reviewers
442 # members / reviewers
443 for reviewer_object in reviewers:
443 for reviewer_object in reviewers:
444 user_id, reasons, mandatory = reviewer_object
444 user_id, reasons, mandatory = reviewer_object
445 user = self._get_user(user_id)
445 user = self._get_user(user_id)
446
446
447 # skip duplicates
447 # skip duplicates
448 if user.user_id in reviewer_ids:
448 if user.user_id in reviewer_ids:
449 continue
449 continue
450
450
451 reviewer_ids.add(user.user_id)
451 reviewer_ids.add(user.user_id)
452
452
453 reviewer = PullRequestReviewers()
453 reviewer = PullRequestReviewers()
454 reviewer.user = user
454 reviewer.user = user
455 reviewer.pull_request = pull_request
455 reviewer.pull_request = pull_request
456 reviewer.reasons = reasons
456 reviewer.reasons = reasons
457 reviewer.mandatory = mandatory
457 reviewer.mandatory = mandatory
458 Session().add(reviewer)
458 Session().add(reviewer)
459
459
460 # Set approval status to "Under Review" for all commits which are
460 # Set approval status to "Under Review" for all commits which are
461 # part of this pull request.
461 # part of this pull request.
462 ChangesetStatusModel().set_status(
462 ChangesetStatusModel().set_status(
463 repo=target_repo,
463 repo=target_repo,
464 status=ChangesetStatus.STATUS_UNDER_REVIEW,
464 status=ChangesetStatus.STATUS_UNDER_REVIEW,
465 user=created_by_user,
465 user=created_by_user,
466 pull_request=pull_request
466 pull_request=pull_request
467 )
467 )
468
468
469 self.notify_reviewers(pull_request, reviewer_ids)
469 self.notify_reviewers(pull_request, reviewer_ids)
470 self._trigger_pull_request_hook(
470 self._trigger_pull_request_hook(
471 pull_request, created_by_user, 'create')
471 pull_request, created_by_user, 'create')
472
472
473 creation_data = pull_request.get_api_data(with_merge_state=False)
473 creation_data = pull_request.get_api_data(with_merge_state=False)
474 self._log_audit_action(
474 self._log_audit_action(
475 'repo.pull_request.create', {'data': creation_data},
475 'repo.pull_request.create', {'data': creation_data},
476 created_by_user, pull_request)
476 created_by_user, pull_request)
477
477
478 return pull_request
478 return pull_request
479
479
480 def _trigger_pull_request_hook(self, pull_request, user, action):
480 def _trigger_pull_request_hook(self, pull_request, user, action):
481 pull_request = self.__get_pull_request(pull_request)
481 pull_request = self.__get_pull_request(pull_request)
482 target_scm = pull_request.target_repo.scm_instance()
482 target_scm = pull_request.target_repo.scm_instance()
483 if action == 'create':
483 if action == 'create':
484 trigger_hook = hooks_utils.trigger_log_create_pull_request_hook
484 trigger_hook = hooks_utils.trigger_log_create_pull_request_hook
485 elif action == 'merge':
485 elif action == 'merge':
486 trigger_hook = hooks_utils.trigger_log_merge_pull_request_hook
486 trigger_hook = hooks_utils.trigger_log_merge_pull_request_hook
487 elif action == 'close':
487 elif action == 'close':
488 trigger_hook = hooks_utils.trigger_log_close_pull_request_hook
488 trigger_hook = hooks_utils.trigger_log_close_pull_request_hook
489 elif action == 'review_status_change':
489 elif action == 'review_status_change':
490 trigger_hook = hooks_utils.trigger_log_review_pull_request_hook
490 trigger_hook = hooks_utils.trigger_log_review_pull_request_hook
491 elif action == 'update':
491 elif action == 'update':
492 trigger_hook = hooks_utils.trigger_log_update_pull_request_hook
492 trigger_hook = hooks_utils.trigger_log_update_pull_request_hook
493 else:
493 else:
494 return
494 return
495
495
496 trigger_hook(
496 trigger_hook(
497 username=user.username,
497 username=user.username,
498 repo_name=pull_request.target_repo.repo_name,
498 repo_name=pull_request.target_repo.repo_name,
499 repo_alias=target_scm.alias,
499 repo_alias=target_scm.alias,
500 pull_request=pull_request)
500 pull_request=pull_request)
501
501
502 def _get_commit_ids(self, pull_request):
502 def _get_commit_ids(self, pull_request):
503 """
503 """
504 Return the commit ids of the merged pull request.
504 Return the commit ids of the merged pull request.
505
505
506 This method is not dealing correctly yet with the lack of autoupdates
506 This method is not dealing correctly yet with the lack of autoupdates
507 nor with the implicit target updates.
507 nor with the implicit target updates.
508 For example: if a commit in the source repo is already in the target it
508 For example: if a commit in the source repo is already in the target it
509 will be reported anyways.
509 will be reported anyways.
510 """
510 """
511 merge_rev = pull_request.merge_rev
511 merge_rev = pull_request.merge_rev
512 if merge_rev is None:
512 if merge_rev is None:
513 raise ValueError('This pull request was not merged yet')
513 raise ValueError('This pull request was not merged yet')
514
514
515 commit_ids = list(pull_request.revisions)
515 commit_ids = list(pull_request.revisions)
516 if merge_rev not in commit_ids:
516 if merge_rev not in commit_ids:
517 commit_ids.append(merge_rev)
517 commit_ids.append(merge_rev)
518
518
519 return commit_ids
519 return commit_ids
520
520
521 def merge(self, pull_request, user, extras):
521 def merge(self, pull_request, user, extras):
522 log.debug("Merging pull request %s", pull_request.pull_request_id)
522 log.debug("Merging pull request %s", pull_request.pull_request_id)
523 merge_state = self._merge_pull_request(pull_request, user, extras)
523 merge_state = self._merge_pull_request(pull_request, user, extras)
524 if merge_state.executed:
524 if merge_state.executed:
525 log.debug(
525 log.debug(
526 "Merge was successful, updating the pull request comments.")
526 "Merge was successful, updating the pull request comments.")
527 self._comment_and_close_pr(pull_request, user, merge_state)
527 self._comment_and_close_pr(pull_request, user, merge_state)
528
528
529 self._log_audit_action(
529 self._log_audit_action(
530 'repo.pull_request.merge',
530 'repo.pull_request.merge',
531 {'merge_state': merge_state.__dict__},
531 {'merge_state': merge_state.__dict__},
532 user, pull_request)
532 user, pull_request)
533
533
534 else:
534 else:
535 log.warn("Merge failed, not updating the pull request.")
535 log.warn("Merge failed, not updating the pull request.")
536 return merge_state
536 return merge_state
537
537
538 def _merge_pull_request(self, pull_request, user, extras):
538 def _merge_pull_request(self, pull_request, user, extras):
539 target_vcs = pull_request.target_repo.scm_instance()
539 target_vcs = pull_request.target_repo.scm_instance()
540 source_vcs = pull_request.source_repo.scm_instance()
540 source_vcs = pull_request.source_repo.scm_instance()
541 target_ref = self._refresh_reference(
541 target_ref = self._refresh_reference(
542 pull_request.target_ref_parts, target_vcs)
542 pull_request.target_ref_parts, target_vcs)
543
543
544 message = _(
544 message = _(
545 'Merge pull request #%(pr_id)s from '
545 'Merge pull request #%(pr_id)s from '
546 '%(source_repo)s %(source_ref_name)s\n\n %(pr_title)s') % {
546 '%(source_repo)s %(source_ref_name)s\n\n %(pr_title)s') % {
547 'pr_id': pull_request.pull_request_id,
547 'pr_id': pull_request.pull_request_id,
548 'source_repo': source_vcs.name,
548 'source_repo': source_vcs.name,
549 'source_ref_name': pull_request.source_ref_parts.name,
549 'source_ref_name': pull_request.source_ref_parts.name,
550 'pr_title': pull_request.title
550 'pr_title': pull_request.title
551 }
551 }
552
552
553 workspace_id = self._workspace_id(pull_request)
553 workspace_id = self._workspace_id(pull_request)
554 use_rebase = self._use_rebase_for_merging(pull_request)
554 use_rebase = self._use_rebase_for_merging(pull_request)
555
555
556 callback_daemon, extras = prepare_callback_daemon(
556 callback_daemon, extras = prepare_callback_daemon(
557 extras, protocol=vcs_settings.HOOKS_PROTOCOL,
557 extras, protocol=vcs_settings.HOOKS_PROTOCOL,
558 use_direct_calls=vcs_settings.HOOKS_DIRECT_CALLS)
558 use_direct_calls=vcs_settings.HOOKS_DIRECT_CALLS)
559
559
560 with callback_daemon:
560 with callback_daemon:
561 # TODO: johbo: Implement a clean way to run a config_override
561 # TODO: johbo: Implement a clean way to run a config_override
562 # for a single call.
562 # for a single call.
563 target_vcs.config.set(
563 target_vcs.config.set(
564 'rhodecode', 'RC_SCM_DATA', json.dumps(extras))
564 'rhodecode', 'RC_SCM_DATA', json.dumps(extras))
565 merge_state = target_vcs.merge(
565 merge_state = target_vcs.merge(
566 target_ref, source_vcs, pull_request.source_ref_parts,
566 target_ref, source_vcs, pull_request.source_ref_parts,
567 workspace_id, user_name=user.username,
567 workspace_id, user_name=user.username,
568 user_email=user.email, message=message, use_rebase=use_rebase)
568 user_email=user.email, message=message, use_rebase=use_rebase)
569 return merge_state
569 return merge_state
570
570
571 def _comment_and_close_pr(self, pull_request, user, merge_state):
571 def _comment_and_close_pr(self, pull_request, user, merge_state):
572 pull_request.merge_rev = merge_state.merge_ref.commit_id
572 pull_request.merge_rev = merge_state.merge_ref.commit_id
573 pull_request.updated_on = datetime.datetime.now()
573 pull_request.updated_on = datetime.datetime.now()
574
574
575 CommentsModel().create(
575 CommentsModel().create(
576 text=unicode(_('Pull request merged and closed')),
576 text=unicode(_('Pull request merged and closed')),
577 repo=pull_request.target_repo.repo_id,
577 repo=pull_request.target_repo.repo_id,
578 user=user.user_id,
578 user=user.user_id,
579 pull_request=pull_request.pull_request_id,
579 pull_request=pull_request.pull_request_id,
580 f_path=None,
580 f_path=None,
581 line_no=None,
581 line_no=None,
582 closing_pr=True
582 closing_pr=True
583 )
583 )
584
584
585 Session().add(pull_request)
585 Session().add(pull_request)
586 Session().flush()
586 Session().flush()
587 # TODO: paris: replace invalidation with less radical solution
587 # TODO: paris: replace invalidation with less radical solution
588 ScmModel().mark_for_invalidation(
588 ScmModel().mark_for_invalidation(
589 pull_request.target_repo.repo_name)
589 pull_request.target_repo.repo_name)
590 self._trigger_pull_request_hook(pull_request, user, 'merge')
590 self._trigger_pull_request_hook(pull_request, user, 'merge')
591
591
592 def has_valid_update_type(self, pull_request):
592 def has_valid_update_type(self, pull_request):
593 source_ref_type = pull_request.source_ref_parts.type
593 source_ref_type = pull_request.source_ref_parts.type
594 return source_ref_type in ['book', 'branch', 'tag']
594 return source_ref_type in ['book', 'branch', 'tag']
595
595
596 def update_commits(self, pull_request):
596 def update_commits(self, pull_request):
597 """
597 """
598 Get the updated list of commits for the pull request
598 Get the updated list of commits for the pull request
599 and return the new pull request version and the list
599 and return the new pull request version and the list
600 of commits processed by this update action
600 of commits processed by this update action
601 """
601 """
602 pull_request = self.__get_pull_request(pull_request)
602 pull_request = self.__get_pull_request(pull_request)
603 source_ref_type = pull_request.source_ref_parts.type
603 source_ref_type = pull_request.source_ref_parts.type
604 source_ref_name = pull_request.source_ref_parts.name
604 source_ref_name = pull_request.source_ref_parts.name
605 source_ref_id = pull_request.source_ref_parts.commit_id
605 source_ref_id = pull_request.source_ref_parts.commit_id
606
606
607 target_ref_type = pull_request.target_ref_parts.type
607 target_ref_type = pull_request.target_ref_parts.type
608 target_ref_name = pull_request.target_ref_parts.name
608 target_ref_name = pull_request.target_ref_parts.name
609 target_ref_id = pull_request.target_ref_parts.commit_id
609 target_ref_id = pull_request.target_ref_parts.commit_id
610
610
611 if not self.has_valid_update_type(pull_request):
611 if not self.has_valid_update_type(pull_request):
612 log.debug(
612 log.debug(
613 "Skipping update of pull request %s due to ref type: %s",
613 "Skipping update of pull request %s due to ref type: %s",
614 pull_request, source_ref_type)
614 pull_request, source_ref_type)
615 return UpdateResponse(
615 return UpdateResponse(
616 executed=False,
616 executed=False,
617 reason=UpdateFailureReason.WRONG_REF_TYPE,
617 reason=UpdateFailureReason.WRONG_REF_TYPE,
618 old=pull_request, new=None, changes=None,
618 old=pull_request, new=None, changes=None,
619 source_changed=False, target_changed=False)
619 source_changed=False, target_changed=False)
620
620
621 # source repo
621 # source repo
622 source_repo = pull_request.source_repo.scm_instance()
622 source_repo = pull_request.source_repo.scm_instance()
623 try:
623 try:
624 source_commit = source_repo.get_commit(commit_id=source_ref_name)
624 source_commit = source_repo.get_commit(commit_id=source_ref_name)
625 except CommitDoesNotExistError:
625 except CommitDoesNotExistError:
626 return UpdateResponse(
626 return UpdateResponse(
627 executed=False,
627 executed=False,
628 reason=UpdateFailureReason.MISSING_SOURCE_REF,
628 reason=UpdateFailureReason.MISSING_SOURCE_REF,
629 old=pull_request, new=None, changes=None,
629 old=pull_request, new=None, changes=None,
630 source_changed=False, target_changed=False)
630 source_changed=False, target_changed=False)
631
631
632 source_changed = source_ref_id != source_commit.raw_id
632 source_changed = source_ref_id != source_commit.raw_id
633
633
634 # target repo
634 # target repo
635 target_repo = pull_request.target_repo.scm_instance()
635 target_repo = pull_request.target_repo.scm_instance()
636 try:
636 try:
637 target_commit = target_repo.get_commit(commit_id=target_ref_name)
637 target_commit = target_repo.get_commit(commit_id=target_ref_name)
638 except CommitDoesNotExistError:
638 except CommitDoesNotExistError:
639 return UpdateResponse(
639 return UpdateResponse(
640 executed=False,
640 executed=False,
641 reason=UpdateFailureReason.MISSING_TARGET_REF,
641 reason=UpdateFailureReason.MISSING_TARGET_REF,
642 old=pull_request, new=None, changes=None,
642 old=pull_request, new=None, changes=None,
643 source_changed=False, target_changed=False)
643 source_changed=False, target_changed=False)
644 target_changed = target_ref_id != target_commit.raw_id
644 target_changed = target_ref_id != target_commit.raw_id
645
645
646 if not (source_changed or target_changed):
646 if not (source_changed or target_changed):
647 log.debug("Nothing changed in pull request %s", pull_request)
647 log.debug("Nothing changed in pull request %s", pull_request)
648 return UpdateResponse(
648 return UpdateResponse(
649 executed=False,
649 executed=False,
650 reason=UpdateFailureReason.NO_CHANGE,
650 reason=UpdateFailureReason.NO_CHANGE,
651 old=pull_request, new=None, changes=None,
651 old=pull_request, new=None, changes=None,
652 source_changed=target_changed, target_changed=source_changed)
652 source_changed=target_changed, target_changed=source_changed)
653
653
654 change_in_found = 'target repo' if target_changed else 'source repo'
654 change_in_found = 'target repo' if target_changed else 'source repo'
655 log.debug('Updating pull request because of change in %s detected',
655 log.debug('Updating pull request because of change in %s detected',
656 change_in_found)
656 change_in_found)
657
657
658 # Finally there is a need for an update, in case of source change
658 # Finally there is a need for an update, in case of source change
659 # we create a new version, else just an update
659 # we create a new version, else just an update
660 if source_changed:
660 if source_changed:
661 pull_request_version = self._create_version_from_snapshot(pull_request)
661 pull_request_version = self._create_version_from_snapshot(pull_request)
662 self._link_comments_to_version(pull_request_version)
662 self._link_comments_to_version(pull_request_version)
663 else:
663 else:
664 try:
664 try:
665 ver = pull_request.versions[-1]
665 ver = pull_request.versions[-1]
666 except IndexError:
666 except IndexError:
667 ver = None
667 ver = None
668
668
669 pull_request.pull_request_version_id = \
669 pull_request.pull_request_version_id = \
670 ver.pull_request_version_id if ver else None
670 ver.pull_request_version_id if ver else None
671 pull_request_version = pull_request
671 pull_request_version = pull_request
672
672
673 try:
673 try:
674 if target_ref_type in ('tag', 'branch', 'book'):
674 if target_ref_type in ('tag', 'branch', 'book'):
675 target_commit = target_repo.get_commit(target_ref_name)
675 target_commit = target_repo.get_commit(target_ref_name)
676 else:
676 else:
677 target_commit = target_repo.get_commit(target_ref_id)
677 target_commit = target_repo.get_commit(target_ref_id)
678 except CommitDoesNotExistError:
678 except CommitDoesNotExistError:
679 return UpdateResponse(
679 return UpdateResponse(
680 executed=False,
680 executed=False,
681 reason=UpdateFailureReason.MISSING_TARGET_REF,
681 reason=UpdateFailureReason.MISSING_TARGET_REF,
682 old=pull_request, new=None, changes=None,
682 old=pull_request, new=None, changes=None,
683 source_changed=source_changed, target_changed=target_changed)
683 source_changed=source_changed, target_changed=target_changed)
684
684
685 # re-compute commit ids
685 # re-compute commit ids
686 old_commit_ids = pull_request.revisions
686 old_commit_ids = pull_request.revisions
687 pre_load = ["author", "branch", "date", "message"]
687 pre_load = ["author", "branch", "date", "message"]
688 commit_ranges = target_repo.compare(
688 commit_ranges = target_repo.compare(
689 target_commit.raw_id, source_commit.raw_id, source_repo, merge=True,
689 target_commit.raw_id, source_commit.raw_id, source_repo, merge=True,
690 pre_load=pre_load)
690 pre_load=pre_load)
691
691
692 ancestor = target_repo.get_common_ancestor(
692 ancestor = target_repo.get_common_ancestor(
693 target_commit.raw_id, source_commit.raw_id, source_repo)
693 target_commit.raw_id, source_commit.raw_id, source_repo)
694
694
695 pull_request.source_ref = '%s:%s:%s' % (
695 pull_request.source_ref = '%s:%s:%s' % (
696 source_ref_type, source_ref_name, source_commit.raw_id)
696 source_ref_type, source_ref_name, source_commit.raw_id)
697 pull_request.target_ref = '%s:%s:%s' % (
697 pull_request.target_ref = '%s:%s:%s' % (
698 target_ref_type, target_ref_name, ancestor)
698 target_ref_type, target_ref_name, ancestor)
699
699
700 pull_request.revisions = [
700 pull_request.revisions = [
701 commit.raw_id for commit in reversed(commit_ranges)]
701 commit.raw_id for commit in reversed(commit_ranges)]
702 pull_request.updated_on = datetime.datetime.now()
702 pull_request.updated_on = datetime.datetime.now()
703 Session().add(pull_request)
703 Session().add(pull_request)
704 new_commit_ids = pull_request.revisions
704 new_commit_ids = pull_request.revisions
705
705
706 old_diff_data, new_diff_data = self._generate_update_diffs(
706 old_diff_data, new_diff_data = self._generate_update_diffs(
707 pull_request, pull_request_version)
707 pull_request, pull_request_version)
708
708
709 # calculate commit and file changes
709 # calculate commit and file changes
710 changes = self._calculate_commit_id_changes(
710 changes = self._calculate_commit_id_changes(
711 old_commit_ids, new_commit_ids)
711 old_commit_ids, new_commit_ids)
712 file_changes = self._calculate_file_changes(
712 file_changes = self._calculate_file_changes(
713 old_diff_data, new_diff_data)
713 old_diff_data, new_diff_data)
714
714
715 # set comments as outdated if DIFFS changed
715 # set comments as outdated if DIFFS changed
716 CommentsModel().outdate_comments(
716 CommentsModel().outdate_comments(
717 pull_request, old_diff_data=old_diff_data,
717 pull_request, old_diff_data=old_diff_data,
718 new_diff_data=new_diff_data)
718 new_diff_data=new_diff_data)
719
719
720 commit_changes = (changes.added or changes.removed)
720 commit_changes = (changes.added or changes.removed)
721 file_node_changes = (
721 file_node_changes = (
722 file_changes.added or file_changes.modified or file_changes.removed)
722 file_changes.added or file_changes.modified or file_changes.removed)
723 pr_has_changes = commit_changes or file_node_changes
723 pr_has_changes = commit_changes or file_node_changes
724
724
725 # Add an automatic comment to the pull request, in case
725 # Add an automatic comment to the pull request, in case
726 # anything has changed
726 # anything has changed
727 if pr_has_changes:
727 if pr_has_changes:
728 update_comment = CommentsModel().create(
728 update_comment = CommentsModel().create(
729 text=self._render_update_message(changes, file_changes),
729 text=self._render_update_message(changes, file_changes),
730 repo=pull_request.target_repo,
730 repo=pull_request.target_repo,
731 user=pull_request.author,
731 user=pull_request.author,
732 pull_request=pull_request,
732 pull_request=pull_request,
733 send_email=False, renderer=DEFAULT_COMMENTS_RENDERER)
733 send_email=False, renderer=DEFAULT_COMMENTS_RENDERER)
734
734
735 # Update status to "Under Review" for added commits
735 # Update status to "Under Review" for added commits
736 for commit_id in changes.added:
736 for commit_id in changes.added:
737 ChangesetStatusModel().set_status(
737 ChangesetStatusModel().set_status(
738 repo=pull_request.source_repo,
738 repo=pull_request.source_repo,
739 status=ChangesetStatus.STATUS_UNDER_REVIEW,
739 status=ChangesetStatus.STATUS_UNDER_REVIEW,
740 comment=update_comment,
740 comment=update_comment,
741 user=pull_request.author,
741 user=pull_request.author,
742 pull_request=pull_request,
742 pull_request=pull_request,
743 revision=commit_id)
743 revision=commit_id)
744
744
745 log.debug(
745 log.debug(
746 'Updated pull request %s, added_ids: %s, common_ids: %s, '
746 'Updated pull request %s, added_ids: %s, common_ids: %s, '
747 'removed_ids: %s', pull_request.pull_request_id,
747 'removed_ids: %s', pull_request.pull_request_id,
748 changes.added, changes.common, changes.removed)
748 changes.added, changes.common, changes.removed)
749 log.debug(
749 log.debug(
750 'Updated pull request with the following file changes: %s',
750 'Updated pull request with the following file changes: %s',
751 file_changes)
751 file_changes)
752
752
753 log.info(
753 log.info(
754 "Updated pull request %s from commit %s to commit %s, "
754 "Updated pull request %s from commit %s to commit %s, "
755 "stored new version %s of this pull request.",
755 "stored new version %s of this pull request.",
756 pull_request.pull_request_id, source_ref_id,
756 pull_request.pull_request_id, source_ref_id,
757 pull_request.source_ref_parts.commit_id,
757 pull_request.source_ref_parts.commit_id,
758 pull_request_version.pull_request_version_id)
758 pull_request_version.pull_request_version_id)
759 Session().commit()
759 Session().commit()
760 self._trigger_pull_request_hook(
760 self._trigger_pull_request_hook(
761 pull_request, pull_request.author, 'update')
761 pull_request, pull_request.author, 'update')
762
762
763 return UpdateResponse(
763 return UpdateResponse(
764 executed=True, reason=UpdateFailureReason.NONE,
764 executed=True, reason=UpdateFailureReason.NONE,
765 old=pull_request, new=pull_request_version, changes=changes,
765 old=pull_request, new=pull_request_version, changes=changes,
766 source_changed=source_changed, target_changed=target_changed)
766 source_changed=source_changed, target_changed=target_changed)
767
767
768 def _create_version_from_snapshot(self, pull_request):
768 def _create_version_from_snapshot(self, pull_request):
769 version = PullRequestVersion()
769 version = PullRequestVersion()
770 version.title = pull_request.title
770 version.title = pull_request.title
771 version.description = pull_request.description
771 version.description = pull_request.description
772 version.status = pull_request.status
772 version.status = pull_request.status
773 version.created_on = datetime.datetime.now()
773 version.created_on = datetime.datetime.now()
774 version.updated_on = pull_request.updated_on
774 version.updated_on = pull_request.updated_on
775 version.user_id = pull_request.user_id
775 version.user_id = pull_request.user_id
776 version.source_repo = pull_request.source_repo
776 version.source_repo = pull_request.source_repo
777 version.source_ref = pull_request.source_ref
777 version.source_ref = pull_request.source_ref
778 version.target_repo = pull_request.target_repo
778 version.target_repo = pull_request.target_repo
779 version.target_ref = pull_request.target_ref
779 version.target_ref = pull_request.target_ref
780
780
781 version._last_merge_source_rev = pull_request._last_merge_source_rev
781 version._last_merge_source_rev = pull_request._last_merge_source_rev
782 version._last_merge_target_rev = pull_request._last_merge_target_rev
782 version._last_merge_target_rev = pull_request._last_merge_target_rev
783 version.last_merge_status = pull_request.last_merge_status
783 version.last_merge_status = pull_request.last_merge_status
784 version.shadow_merge_ref = pull_request.shadow_merge_ref
784 version.shadow_merge_ref = pull_request.shadow_merge_ref
785 version.merge_rev = pull_request.merge_rev
785 version.merge_rev = pull_request.merge_rev
786 version.reviewer_data = pull_request.reviewer_data
786 version.reviewer_data = pull_request.reviewer_data
787
787
788 version.revisions = pull_request.revisions
788 version.revisions = pull_request.revisions
789 version.pull_request = pull_request
789 version.pull_request = pull_request
790 Session().add(version)
790 Session().add(version)
791 Session().flush()
791 Session().flush()
792
792
793 return version
793 return version
794
794
795 def _generate_update_diffs(self, pull_request, pull_request_version):
795 def _generate_update_diffs(self, pull_request, pull_request_version):
796
796
797 diff_context = (
797 diff_context = (
798 self.DIFF_CONTEXT +
798 self.DIFF_CONTEXT +
799 CommentsModel.needed_extra_diff_context())
799 CommentsModel.needed_extra_diff_context())
800
800
801 source_repo = pull_request_version.source_repo
801 source_repo = pull_request_version.source_repo
802 source_ref_id = pull_request_version.source_ref_parts.commit_id
802 source_ref_id = pull_request_version.source_ref_parts.commit_id
803 target_ref_id = pull_request_version.target_ref_parts.commit_id
803 target_ref_id = pull_request_version.target_ref_parts.commit_id
804 old_diff = self._get_diff_from_pr_or_version(
804 old_diff = self._get_diff_from_pr_or_version(
805 source_repo, source_ref_id, target_ref_id, context=diff_context)
805 source_repo, source_ref_id, target_ref_id, context=diff_context)
806
806
807 source_repo = pull_request.source_repo
807 source_repo = pull_request.source_repo
808 source_ref_id = pull_request.source_ref_parts.commit_id
808 source_ref_id = pull_request.source_ref_parts.commit_id
809 target_ref_id = pull_request.target_ref_parts.commit_id
809 target_ref_id = pull_request.target_ref_parts.commit_id
810
810
811 new_diff = self._get_diff_from_pr_or_version(
811 new_diff = self._get_diff_from_pr_or_version(
812 source_repo, source_ref_id, target_ref_id, context=diff_context)
812 source_repo, source_ref_id, target_ref_id, context=diff_context)
813
813
814 old_diff_data = diffs.DiffProcessor(old_diff)
814 old_diff_data = diffs.DiffProcessor(old_diff)
815 old_diff_data.prepare()
815 old_diff_data.prepare()
816 new_diff_data = diffs.DiffProcessor(new_diff)
816 new_diff_data = diffs.DiffProcessor(new_diff)
817 new_diff_data.prepare()
817 new_diff_data.prepare()
818
818
819 return old_diff_data, new_diff_data
819 return old_diff_data, new_diff_data
820
820
821 def _link_comments_to_version(self, pull_request_version):
821 def _link_comments_to_version(self, pull_request_version):
822 """
822 """
823 Link all unlinked comments of this pull request to the given version.
823 Link all unlinked comments of this pull request to the given version.
824
824
825 :param pull_request_version: The `PullRequestVersion` to which
825 :param pull_request_version: The `PullRequestVersion` to which
826 the comments shall be linked.
826 the comments shall be linked.
827
827
828 """
828 """
829 pull_request = pull_request_version.pull_request
829 pull_request = pull_request_version.pull_request
830 comments = ChangesetComment.query()\
830 comments = ChangesetComment.query()\
831 .filter(
831 .filter(
832 # TODO: johbo: Should we query for the repo at all here?
832 # TODO: johbo: Should we query for the repo at all here?
833 # Pending decision on how comments of PRs are to be related
833 # Pending decision on how comments of PRs are to be related
834 # to either the source repo, the target repo or no repo at all.
834 # to either the source repo, the target repo or no repo at all.
835 ChangesetComment.repo_id == pull_request.target_repo.repo_id,
835 ChangesetComment.repo_id == pull_request.target_repo.repo_id,
836 ChangesetComment.pull_request == pull_request,
836 ChangesetComment.pull_request == pull_request,
837 ChangesetComment.pull_request_version == None)\
837 ChangesetComment.pull_request_version == None)\
838 .order_by(ChangesetComment.comment_id.asc())
838 .order_by(ChangesetComment.comment_id.asc())
839
839
840 # TODO: johbo: Find out why this breaks if it is done in a bulk
840 # TODO: johbo: Find out why this breaks if it is done in a bulk
841 # operation.
841 # operation.
842 for comment in comments:
842 for comment in comments:
843 comment.pull_request_version_id = (
843 comment.pull_request_version_id = (
844 pull_request_version.pull_request_version_id)
844 pull_request_version.pull_request_version_id)
845 Session().add(comment)
845 Session().add(comment)
846
846
847 def _calculate_commit_id_changes(self, old_ids, new_ids):
847 def _calculate_commit_id_changes(self, old_ids, new_ids):
848 added = [x for x in new_ids if x not in old_ids]
848 added = [x for x in new_ids if x not in old_ids]
849 common = [x for x in new_ids if x in old_ids]
849 common = [x for x in new_ids if x in old_ids]
850 removed = [x for x in old_ids if x not in new_ids]
850 removed = [x for x in old_ids if x not in new_ids]
851 total = new_ids
851 total = new_ids
852 return ChangeTuple(added, common, removed, total)
852 return ChangeTuple(added, common, removed, total)
853
853
854 def _calculate_file_changes(self, old_diff_data, new_diff_data):
854 def _calculate_file_changes(self, old_diff_data, new_diff_data):
855
855
856 old_files = OrderedDict()
856 old_files = OrderedDict()
857 for diff_data in old_diff_data.parsed_diff:
857 for diff_data in old_diff_data.parsed_diff:
858 old_files[diff_data['filename']] = md5_safe(diff_data['raw_diff'])
858 old_files[diff_data['filename']] = md5_safe(diff_data['raw_diff'])
859
859
860 added_files = []
860 added_files = []
861 modified_files = []
861 modified_files = []
862 removed_files = []
862 removed_files = []
863 for diff_data in new_diff_data.parsed_diff:
863 for diff_data in new_diff_data.parsed_diff:
864 new_filename = diff_data['filename']
864 new_filename = diff_data['filename']
865 new_hash = md5_safe(diff_data['raw_diff'])
865 new_hash = md5_safe(diff_data['raw_diff'])
866
866
867 old_hash = old_files.get(new_filename)
867 old_hash = old_files.get(new_filename)
868 if not old_hash:
868 if not old_hash:
869 # file is not present in old diff, means it's added
869 # file is not present in old diff, means it's added
870 added_files.append(new_filename)
870 added_files.append(new_filename)
871 else:
871 else:
872 if new_hash != old_hash:
872 if new_hash != old_hash:
873 modified_files.append(new_filename)
873 modified_files.append(new_filename)
874 # now remove a file from old, since we have seen it already
874 # now remove a file from old, since we have seen it already
875 del old_files[new_filename]
875 del old_files[new_filename]
876
876
877 # removed files is when there are present in old, but not in NEW,
877 # removed files is when there are present in old, but not in NEW,
878 # since we remove old files that are present in new diff, left-overs
878 # since we remove old files that are present in new diff, left-overs
879 # if any should be the removed files
879 # if any should be the removed files
880 removed_files.extend(old_files.keys())
880 removed_files.extend(old_files.keys())
881
881
882 return FileChangeTuple(added_files, modified_files, removed_files)
882 return FileChangeTuple(added_files, modified_files, removed_files)
883
883
884 def _render_update_message(self, changes, file_changes):
884 def _render_update_message(self, changes, file_changes):
885 """
885 """
886 render the message using DEFAULT_COMMENTS_RENDERER (RST renderer),
886 render the message using DEFAULT_COMMENTS_RENDERER (RST renderer),
887 so it's always looking the same disregarding on which default
887 so it's always looking the same disregarding on which default
888 renderer system is using.
888 renderer system is using.
889
889
890 :param changes: changes named tuple
890 :param changes: changes named tuple
891 :param file_changes: file changes named tuple
891 :param file_changes: file changes named tuple
892
892
893 """
893 """
894 new_status = ChangesetStatus.get_status_lbl(
894 new_status = ChangesetStatus.get_status_lbl(
895 ChangesetStatus.STATUS_UNDER_REVIEW)
895 ChangesetStatus.STATUS_UNDER_REVIEW)
896
896
897 changed_files = (
897 changed_files = (
898 file_changes.added + file_changes.modified + file_changes.removed)
898 file_changes.added + file_changes.modified + file_changes.removed)
899
899
900 params = {
900 params = {
901 'under_review_label': new_status,
901 'under_review_label': new_status,
902 'added_commits': changes.added,
902 'added_commits': changes.added,
903 'removed_commits': changes.removed,
903 'removed_commits': changes.removed,
904 'changed_files': changed_files,
904 'changed_files': changed_files,
905 'added_files': file_changes.added,
905 'added_files': file_changes.added,
906 'modified_files': file_changes.modified,
906 'modified_files': file_changes.modified,
907 'removed_files': file_changes.removed,
907 'removed_files': file_changes.removed,
908 }
908 }
909 renderer = RstTemplateRenderer()
909 renderer = RstTemplateRenderer()
910 return renderer.render('pull_request_update.mako', **params)
910 return renderer.render('pull_request_update.mako', **params)
911
911
912 def edit(self, pull_request, title, description, user):
912 def edit(self, pull_request, title, description, user):
913 pull_request = self.__get_pull_request(pull_request)
913 pull_request = self.__get_pull_request(pull_request)
914 old_data = pull_request.get_api_data(with_merge_state=False)
914 old_data = pull_request.get_api_data(with_merge_state=False)
915 if pull_request.is_closed():
915 if pull_request.is_closed():
916 raise ValueError('This pull request is closed')
916 raise ValueError('This pull request is closed')
917 if title:
917 if title:
918 pull_request.title = title
918 pull_request.title = title
919 pull_request.description = description
919 pull_request.description = description
920 pull_request.updated_on = datetime.datetime.now()
920 pull_request.updated_on = datetime.datetime.now()
921 Session().add(pull_request)
921 Session().add(pull_request)
922 self._log_audit_action(
922 self._log_audit_action(
923 'repo.pull_request.edit', {'old_data': old_data},
923 'repo.pull_request.edit', {'old_data': old_data},
924 user, pull_request)
924 user, pull_request)
925
925
926 def update_reviewers(self, pull_request, reviewer_data, user):
926 def update_reviewers(self, pull_request, reviewer_data, user):
927 """
927 """
928 Update the reviewers in the pull request
928 Update the reviewers in the pull request
929
929
930 :param pull_request: the pr to update
930 :param pull_request: the pr to update
931 :param reviewer_data: list of tuples
931 :param reviewer_data: list of tuples
932 [(user, ['reason1', 'reason2'], mandatory_flag)]
932 [(user, ['reason1', 'reason2'], mandatory_flag)]
933 """
933 """
934
934
935 reviewers = {}
935 reviewers = {}
936 for user_id, reasons, mandatory in reviewer_data:
936 for user_id, reasons, mandatory in reviewer_data:
937 if isinstance(user_id, (int, basestring)):
937 if isinstance(user_id, (int, basestring)):
938 user_id = self._get_user(user_id).user_id
938 user_id = self._get_user(user_id).user_id
939 reviewers[user_id] = {
939 reviewers[user_id] = {
940 'reasons': reasons, 'mandatory': mandatory}
940 'reasons': reasons, 'mandatory': mandatory}
941
941
942 reviewers_ids = set(reviewers.keys())
942 reviewers_ids = set(reviewers.keys())
943 pull_request = self.__get_pull_request(pull_request)
943 pull_request = self.__get_pull_request(pull_request)
944 current_reviewers = PullRequestReviewers.query()\
944 current_reviewers = PullRequestReviewers.query()\
945 .filter(PullRequestReviewers.pull_request ==
945 .filter(PullRequestReviewers.pull_request ==
946 pull_request).all()
946 pull_request).all()
947 current_reviewers_ids = set([x.user.user_id for x in current_reviewers])
947 current_reviewers_ids = set([x.user.user_id for x in current_reviewers])
948
948
949 ids_to_add = reviewers_ids.difference(current_reviewers_ids)
949 ids_to_add = reviewers_ids.difference(current_reviewers_ids)
950 ids_to_remove = current_reviewers_ids.difference(reviewers_ids)
950 ids_to_remove = current_reviewers_ids.difference(reviewers_ids)
951
951
952 log.debug("Adding %s reviewers", ids_to_add)
952 log.debug("Adding %s reviewers", ids_to_add)
953 log.debug("Removing %s reviewers", ids_to_remove)
953 log.debug("Removing %s reviewers", ids_to_remove)
954 changed = False
954 changed = False
955 for uid in ids_to_add:
955 for uid in ids_to_add:
956 changed = True
956 changed = True
957 _usr = self._get_user(uid)
957 _usr = self._get_user(uid)
958 reviewer = PullRequestReviewers()
958 reviewer = PullRequestReviewers()
959 reviewer.user = _usr
959 reviewer.user = _usr
960 reviewer.pull_request = pull_request
960 reviewer.pull_request = pull_request
961 reviewer.reasons = reviewers[uid]['reasons']
961 reviewer.reasons = reviewers[uid]['reasons']
962 # NOTE(marcink): mandatory shouldn't be changed now
962 # NOTE(marcink): mandatory shouldn't be changed now
963 # reviewer.mandatory = reviewers[uid]['reasons']
963 # reviewer.mandatory = reviewers[uid]['reasons']
964 Session().add(reviewer)
964 Session().add(reviewer)
965 self._log_audit_action(
965 self._log_audit_action(
966 'repo.pull_request.reviewer.add', {'data': reviewer.get_dict()},
966 'repo.pull_request.reviewer.add', {'data': reviewer.get_dict()},
967 user, pull_request)
967 user, pull_request)
968
968
969 for uid in ids_to_remove:
969 for uid in ids_to_remove:
970 changed = True
970 changed = True
971 reviewers = PullRequestReviewers.query()\
971 reviewers = PullRequestReviewers.query()\
972 .filter(PullRequestReviewers.user_id == uid,
972 .filter(PullRequestReviewers.user_id == uid,
973 PullRequestReviewers.pull_request == pull_request)\
973 PullRequestReviewers.pull_request == pull_request)\
974 .all()
974 .all()
975 # use .all() in case we accidentally added the same person twice
975 # use .all() in case we accidentally added the same person twice
976 # this CAN happen due to the lack of DB checks
976 # this CAN happen due to the lack of DB checks
977 for obj in reviewers:
977 for obj in reviewers:
978 old_data = obj.get_dict()
978 old_data = obj.get_dict()
979 Session().delete(obj)
979 Session().delete(obj)
980 self._log_audit_action(
980 self._log_audit_action(
981 'repo.pull_request.reviewer.delete',
981 'repo.pull_request.reviewer.delete',
982 {'old_data': old_data}, user, pull_request)
982 {'old_data': old_data}, user, pull_request)
983
983
984 if changed:
984 if changed:
985 pull_request.updated_on = datetime.datetime.now()
985 pull_request.updated_on = datetime.datetime.now()
986 Session().add(pull_request)
986 Session().add(pull_request)
987
987
988 self.notify_reviewers(pull_request, ids_to_add)
988 self.notify_reviewers(pull_request, ids_to_add)
989 return ids_to_add, ids_to_remove
989 return ids_to_add, ids_to_remove
990
990
991 def get_url(self, pull_request, request=None, permalink=False):
991 def get_url(self, pull_request, request=None, permalink=False):
992 if not request:
992 if not request:
993 request = get_current_request()
993 request = get_current_request()
994
994
995 if permalink:
995 if permalink:
996 return request.route_url(
996 return request.route_url(
997 'pull_requests_global',
997 'pull_requests_global',
998 pull_request_id=pull_request.pull_request_id,)
998 pull_request_id=pull_request.pull_request_id,)
999 else:
999 else:
1000 return request.route_url('pullrequest_show',
1000 return request.route_url('pullrequest_show',
1001 repo_name=safe_str(pull_request.target_repo.repo_name),
1001 repo_name=safe_str(pull_request.target_repo.repo_name),
1002 pull_request_id=pull_request.pull_request_id,)
1002 pull_request_id=pull_request.pull_request_id,)
1003
1003
1004 def get_shadow_clone_url(self, pull_request):
1004 def get_shadow_clone_url(self, pull_request):
1005 """
1005 """
1006 Returns qualified url pointing to the shadow repository. If this pull
1006 Returns qualified url pointing to the shadow repository. If this pull
1007 request is closed there is no shadow repository and ``None`` will be
1007 request is closed there is no shadow repository and ``None`` will be
1008 returned.
1008 returned.
1009 """
1009 """
1010 if pull_request.is_closed():
1010 if pull_request.is_closed():
1011 return None
1011 return None
1012 else:
1012 else:
1013 pr_url = urllib.unquote(self.get_url(pull_request))
1013 pr_url = urllib.unquote(self.get_url(pull_request))
1014 return safe_unicode('{pr_url}/repository'.format(pr_url=pr_url))
1014 return safe_unicode('{pr_url}/repository'.format(pr_url=pr_url))
1015
1015
1016 def notify_reviewers(self, pull_request, reviewers_ids):
1016 def notify_reviewers(self, pull_request, reviewers_ids):
1017 # notification to reviewers
1017 # notification to reviewers
1018 if not reviewers_ids:
1018 if not reviewers_ids:
1019 return
1019 return
1020
1020
1021 pull_request_obj = pull_request
1021 pull_request_obj = pull_request
1022 # get the current participants of this pull request
1022 # get the current participants of this pull request
1023 recipients = reviewers_ids
1023 recipients = reviewers_ids
1024 notification_type = EmailNotificationModel.TYPE_PULL_REQUEST
1024 notification_type = EmailNotificationModel.TYPE_PULL_REQUEST
1025
1025
1026 pr_source_repo = pull_request_obj.source_repo
1026 pr_source_repo = pull_request_obj.source_repo
1027 pr_target_repo = pull_request_obj.target_repo
1027 pr_target_repo = pull_request_obj.target_repo
1028
1028
1029 pr_url = h.route_url('pullrequest_show',
1029 pr_url = h.route_url('pullrequest_show',
1030 repo_name=pr_target_repo.repo_name,
1030 repo_name=pr_target_repo.repo_name,
1031 pull_request_id=pull_request_obj.pull_request_id,)
1031 pull_request_id=pull_request_obj.pull_request_id,)
1032
1032
1033 # set some variables for email notification
1033 # set some variables for email notification
1034 pr_target_repo_url = h.route_url(
1034 pr_target_repo_url = h.route_url(
1035 'repo_summary', repo_name=pr_target_repo.repo_name)
1035 'repo_summary', repo_name=pr_target_repo.repo_name)
1036
1036
1037 pr_source_repo_url = h.route_url(
1037 pr_source_repo_url = h.route_url(
1038 'repo_summary', repo_name=pr_source_repo.repo_name)
1038 'repo_summary', repo_name=pr_source_repo.repo_name)
1039
1039
1040 # pull request specifics
1040 # pull request specifics
1041 pull_request_commits = [
1041 pull_request_commits = [
1042 (x.raw_id, x.message)
1042 (x.raw_id, x.message)
1043 for x in map(pr_source_repo.get_commit, pull_request.revisions)]
1043 for x in map(pr_source_repo.get_commit, pull_request.revisions)]
1044
1044
1045 kwargs = {
1045 kwargs = {
1046 'user': pull_request.author,
1046 'user': pull_request.author,
1047 'pull_request': pull_request_obj,
1047 'pull_request': pull_request_obj,
1048 'pull_request_commits': pull_request_commits,
1048 'pull_request_commits': pull_request_commits,
1049
1049
1050 'pull_request_target_repo': pr_target_repo,
1050 'pull_request_target_repo': pr_target_repo,
1051 'pull_request_target_repo_url': pr_target_repo_url,
1051 'pull_request_target_repo_url': pr_target_repo_url,
1052
1052
1053 'pull_request_source_repo': pr_source_repo,
1053 'pull_request_source_repo': pr_source_repo,
1054 'pull_request_source_repo_url': pr_source_repo_url,
1054 'pull_request_source_repo_url': pr_source_repo_url,
1055
1055
1056 'pull_request_url': pr_url,
1056 'pull_request_url': pr_url,
1057 }
1057 }
1058
1058
1059 # pre-generate the subject for notification itself
1059 # pre-generate the subject for notification itself
1060 (subject,
1060 (subject,
1061 _h, _e, # we don't care about those
1061 _h, _e, # we don't care about those
1062 body_plaintext) = EmailNotificationModel().render_email(
1062 body_plaintext) = EmailNotificationModel().render_email(
1063 notification_type, **kwargs)
1063 notification_type, **kwargs)
1064
1064
1065 # create notification objects, and emails
1065 # create notification objects, and emails
1066 NotificationModel().create(
1066 NotificationModel().create(
1067 created_by=pull_request.author,
1067 created_by=pull_request.author,
1068 notification_subject=subject,
1068 notification_subject=subject,
1069 notification_body=body_plaintext,
1069 notification_body=body_plaintext,
1070 notification_type=notification_type,
1070 notification_type=notification_type,
1071 recipients=recipients,
1071 recipients=recipients,
1072 email_kwargs=kwargs,
1072 email_kwargs=kwargs,
1073 )
1073 )
1074
1074
1075 def delete(self, pull_request, user):
1075 def delete(self, pull_request, user):
1076 pull_request = self.__get_pull_request(pull_request)
1076 pull_request = self.__get_pull_request(pull_request)
1077 old_data = pull_request.get_api_data(with_merge_state=False)
1077 old_data = pull_request.get_api_data(with_merge_state=False)
1078 self._cleanup_merge_workspace(pull_request)
1078 self._cleanup_merge_workspace(pull_request)
1079 self._log_audit_action(
1079 self._log_audit_action(
1080 'repo.pull_request.delete', {'old_data': old_data},
1080 'repo.pull_request.delete', {'old_data': old_data},
1081 user, pull_request)
1081 user, pull_request)
1082 Session().delete(pull_request)
1082 Session().delete(pull_request)
1083
1083
1084 def close_pull_request(self, pull_request, user):
1084 def close_pull_request(self, pull_request, user):
1085 pull_request = self.__get_pull_request(pull_request)
1085 pull_request = self.__get_pull_request(pull_request)
1086 self._cleanup_merge_workspace(pull_request)
1086 self._cleanup_merge_workspace(pull_request)
1087 pull_request.status = PullRequest.STATUS_CLOSED
1087 pull_request.status = PullRequest.STATUS_CLOSED
1088 pull_request.updated_on = datetime.datetime.now()
1088 pull_request.updated_on = datetime.datetime.now()
1089 Session().add(pull_request)
1089 Session().add(pull_request)
1090 self._trigger_pull_request_hook(
1090 self._trigger_pull_request_hook(
1091 pull_request, pull_request.author, 'close')
1091 pull_request, pull_request.author, 'close')
1092 self._log_audit_action(
1092 self._log_audit_action(
1093 'repo.pull_request.close', {}, user, pull_request)
1093 'repo.pull_request.close', {}, user, pull_request)
1094
1094
1095 def close_pull_request_with_comment(
1095 def close_pull_request_with_comment(
1096 self, pull_request, user, repo, message=None):
1096 self, pull_request, user, repo, message=None):
1097
1097
1098 pull_request_review_status = pull_request.calculated_review_status()
1098 pull_request_review_status = pull_request.calculated_review_status()
1099
1099
1100 if pull_request_review_status == ChangesetStatus.STATUS_APPROVED:
1100 if pull_request_review_status == ChangesetStatus.STATUS_APPROVED:
1101 # approved only if we have voting consent
1101 # approved only if we have voting consent
1102 status = ChangesetStatus.STATUS_APPROVED
1102 status = ChangesetStatus.STATUS_APPROVED
1103 else:
1103 else:
1104 status = ChangesetStatus.STATUS_REJECTED
1104 status = ChangesetStatus.STATUS_REJECTED
1105 status_lbl = ChangesetStatus.get_status_lbl(status)
1105 status_lbl = ChangesetStatus.get_status_lbl(status)
1106
1106
1107 default_message = (
1107 default_message = (
1108 _('Closing with status change {transition_icon} {status}.')
1108 _('Closing with status change {transition_icon} {status}.')
1109 ).format(transition_icon='>', status=status_lbl)
1109 ).format(transition_icon='>', status=status_lbl)
1110 text = message or default_message
1110 text = message or default_message
1111
1111
1112 # create a comment, and link it to new status
1112 # create a comment, and link it to new status
1113 comment = CommentsModel().create(
1113 comment = CommentsModel().create(
1114 text=text,
1114 text=text,
1115 repo=repo.repo_id,
1115 repo=repo.repo_id,
1116 user=user.user_id,
1116 user=user.user_id,
1117 pull_request=pull_request.pull_request_id,
1117 pull_request=pull_request.pull_request_id,
1118 status_change=status_lbl,
1118 status_change=status_lbl,
1119 status_change_type=status,
1119 status_change_type=status,
1120 closing_pr=True
1120 closing_pr=True
1121 )
1121 )
1122
1122
1123 # calculate old status before we change it
1123 # calculate old status before we change it
1124 old_calculated_status = pull_request.calculated_review_status()
1124 old_calculated_status = pull_request.calculated_review_status()
1125 ChangesetStatusModel().set_status(
1125 ChangesetStatusModel().set_status(
1126 repo.repo_id,
1126 repo.repo_id,
1127 status,
1127 status,
1128 user.user_id,
1128 user.user_id,
1129 comment=comment,
1129 comment=comment,
1130 pull_request=pull_request.pull_request_id
1130 pull_request=pull_request.pull_request_id
1131 )
1131 )
1132
1132
1133 Session().flush()
1133 Session().flush()
1134 events.trigger(events.PullRequestCommentEvent(pull_request, comment))
1134 events.trigger(events.PullRequestCommentEvent(pull_request, comment))
1135 # we now calculate the status of pull request again, and based on that
1135 # we now calculate the status of pull request again, and based on that
1136 # calculation trigger status change. This might happen in cases
1136 # calculation trigger status change. This might happen in cases
1137 # that non-reviewer admin closes a pr, which means his vote doesn't
1137 # that non-reviewer admin closes a pr, which means his vote doesn't
1138 # change the status, while if he's a reviewer this might change it.
1138 # change the status, while if he's a reviewer this might change it.
1139 calculated_status = pull_request.calculated_review_status()
1139 calculated_status = pull_request.calculated_review_status()
1140 if old_calculated_status != calculated_status:
1140 if old_calculated_status != calculated_status:
1141 self._trigger_pull_request_hook(
1141 self._trigger_pull_request_hook(
1142 pull_request, user, 'review_status_change')
1142 pull_request, user, 'review_status_change')
1143
1143
1144 # finally close the PR
1144 # finally close the PR
1145 PullRequestModel().close_pull_request(
1145 PullRequestModel().close_pull_request(
1146 pull_request.pull_request_id, user)
1146 pull_request.pull_request_id, user)
1147
1147
1148 return comment, status
1148 return comment, status
1149
1149
1150 def merge_status(self, pull_request):
1150 def merge_status(self, pull_request):
1151 if not self._is_merge_enabled(pull_request):
1151 if not self._is_merge_enabled(pull_request):
1152 return False, _('Server-side pull request merging is disabled.')
1152 return False, _('Server-side pull request merging is disabled.')
1153 if pull_request.is_closed():
1153 if pull_request.is_closed():
1154 return False, _('This pull request is closed.')
1154 return False, _('This pull request is closed.')
1155 merge_possible, msg = self._check_repo_requirements(
1155 merge_possible, msg = self._check_repo_requirements(
1156 target=pull_request.target_repo, source=pull_request.source_repo)
1156 target=pull_request.target_repo, source=pull_request.source_repo)
1157 if not merge_possible:
1157 if not merge_possible:
1158 return merge_possible, msg
1158 return merge_possible, msg
1159
1159
1160 try:
1160 try:
1161 resp = self._try_merge(pull_request)
1161 resp = self._try_merge(pull_request)
1162 log.debug("Merge response: %s", resp)
1162 log.debug("Merge response: %s", resp)
1163 status = resp.possible, self.merge_status_message(
1163 status = resp.possible, self.merge_status_message(
1164 resp.failure_reason)
1164 resp.failure_reason)
1165 except NotImplementedError:
1165 except NotImplementedError:
1166 status = False, _('Pull request merging is not supported.')
1166 status = False, _('Pull request merging is not supported.')
1167
1167
1168 return status
1168 return status
1169
1169
1170 def _check_repo_requirements(self, target, source):
1170 def _check_repo_requirements(self, target, source):
1171 """
1171 """
1172 Check if `target` and `source` have compatible requirements.
1172 Check if `target` and `source` have compatible requirements.
1173
1173
1174 Currently this is just checking for largefiles.
1174 Currently this is just checking for largefiles.
1175 """
1175 """
1176 target_has_largefiles = self._has_largefiles(target)
1176 target_has_largefiles = self._has_largefiles(target)
1177 source_has_largefiles = self._has_largefiles(source)
1177 source_has_largefiles = self._has_largefiles(source)
1178 merge_possible = True
1178 merge_possible = True
1179 message = u''
1179 message = u''
1180
1180
1181 if target_has_largefiles != source_has_largefiles:
1181 if target_has_largefiles != source_has_largefiles:
1182 merge_possible = False
1182 merge_possible = False
1183 if source_has_largefiles:
1183 if source_has_largefiles:
1184 message = _(
1184 message = _(
1185 'Target repository large files support is disabled.')
1185 'Target repository large files support is disabled.')
1186 else:
1186 else:
1187 message = _(
1187 message = _(
1188 'Source repository large files support is disabled.')
1188 'Source repository large files support is disabled.')
1189
1189
1190 return merge_possible, message
1190 return merge_possible, message
1191
1191
1192 def _has_largefiles(self, repo):
1192 def _has_largefiles(self, repo):
1193 largefiles_ui = VcsSettingsModel(repo=repo).get_ui_settings(
1193 largefiles_ui = VcsSettingsModel(repo=repo).get_ui_settings(
1194 'extensions', 'largefiles')
1194 'extensions', 'largefiles')
1195 return largefiles_ui and largefiles_ui[0].active
1195 return largefiles_ui and largefiles_ui[0].active
1196
1196
1197 def _try_merge(self, pull_request):
1197 def _try_merge(self, pull_request):
1198 """
1198 """
1199 Try to merge the pull request and return the merge status.
1199 Try to merge the pull request and return the merge status.
1200 """
1200 """
1201 log.debug(
1201 log.debug(
1202 "Trying out if the pull request %s can be merged.",
1202 "Trying out if the pull request %s can be merged.",
1203 pull_request.pull_request_id)
1203 pull_request.pull_request_id)
1204 target_vcs = pull_request.target_repo.scm_instance()
1204 target_vcs = pull_request.target_repo.scm_instance()
1205
1205
1206 # Refresh the target reference.
1206 # Refresh the target reference.
1207 try:
1207 try:
1208 target_ref = self._refresh_reference(
1208 target_ref = self._refresh_reference(
1209 pull_request.target_ref_parts, target_vcs)
1209 pull_request.target_ref_parts, target_vcs)
1210 except CommitDoesNotExistError:
1210 except CommitDoesNotExistError:
1211 merge_state = MergeResponse(
1211 merge_state = MergeResponse(
1212 False, False, None, MergeFailureReason.MISSING_TARGET_REF)
1212 False, False, None, MergeFailureReason.MISSING_TARGET_REF)
1213 return merge_state
1213 return merge_state
1214
1214
1215 target_locked = pull_request.target_repo.locked
1215 target_locked = pull_request.target_repo.locked
1216 if target_locked and target_locked[0]:
1216 if target_locked and target_locked[0]:
1217 log.debug("The target repository is locked.")
1217 log.debug("The target repository is locked.")
1218 merge_state = MergeResponse(
1218 merge_state = MergeResponse(
1219 False, False, None, MergeFailureReason.TARGET_IS_LOCKED)
1219 False, False, None, MergeFailureReason.TARGET_IS_LOCKED)
1220 elif self._needs_merge_state_refresh(pull_request, target_ref):
1220 elif self._needs_merge_state_refresh(pull_request, target_ref):
1221 log.debug("Refreshing the merge status of the repository.")
1221 log.debug("Refreshing the merge status of the repository.")
1222 merge_state = self._refresh_merge_state(
1222 merge_state = self._refresh_merge_state(
1223 pull_request, target_vcs, target_ref)
1223 pull_request, target_vcs, target_ref)
1224 else:
1224 else:
1225 possible = pull_request.\
1225 possible = pull_request.\
1226 last_merge_status == MergeFailureReason.NONE
1226 last_merge_status == MergeFailureReason.NONE
1227 merge_state = MergeResponse(
1227 merge_state = MergeResponse(
1228 possible, False, None, pull_request.last_merge_status)
1228 possible, False, None, pull_request.last_merge_status)
1229
1229
1230 return merge_state
1230 return merge_state
1231
1231
1232 def _refresh_reference(self, reference, vcs_repository):
1232 def _refresh_reference(self, reference, vcs_repository):
1233 if reference.type in ('branch', 'book'):
1233 if reference.type in ('branch', 'book'):
1234 name_or_id = reference.name
1234 name_or_id = reference.name
1235 else:
1235 else:
1236 name_or_id = reference.commit_id
1236 name_or_id = reference.commit_id
1237 refreshed_commit = vcs_repository.get_commit(name_or_id)
1237 refreshed_commit = vcs_repository.get_commit(name_or_id)
1238 refreshed_reference = Reference(
1238 refreshed_reference = Reference(
1239 reference.type, reference.name, refreshed_commit.raw_id)
1239 reference.type, reference.name, refreshed_commit.raw_id)
1240 return refreshed_reference
1240 return refreshed_reference
1241
1241
1242 def _needs_merge_state_refresh(self, pull_request, target_reference):
1242 def _needs_merge_state_refresh(self, pull_request, target_reference):
1243 return not(
1243 return not(
1244 pull_request.revisions and
1244 pull_request.revisions and
1245 pull_request.revisions[0] == pull_request._last_merge_source_rev and
1245 pull_request.revisions[0] == pull_request._last_merge_source_rev and
1246 target_reference.commit_id == pull_request._last_merge_target_rev)
1246 target_reference.commit_id == pull_request._last_merge_target_rev)
1247
1247
1248 def _refresh_merge_state(self, pull_request, target_vcs, target_reference):
1248 def _refresh_merge_state(self, pull_request, target_vcs, target_reference):
1249 workspace_id = self._workspace_id(pull_request)
1249 workspace_id = self._workspace_id(pull_request)
1250 source_vcs = pull_request.source_repo.scm_instance()
1250 source_vcs = pull_request.source_repo.scm_instance()
1251 use_rebase = self._use_rebase_for_merging(pull_request)
1251 use_rebase = self._use_rebase_for_merging(pull_request)
1252 merge_state = target_vcs.merge(
1252 merge_state = target_vcs.merge(
1253 target_reference, source_vcs, pull_request.source_ref_parts,
1253 target_reference, source_vcs, pull_request.source_ref_parts,
1254 workspace_id, dry_run=True, use_rebase=use_rebase)
1254 workspace_id, dry_run=True, use_rebase=use_rebase)
1255
1255
1256 # Do not store the response if there was an unknown error.
1256 # Do not store the response if there was an unknown error.
1257 if merge_state.failure_reason != MergeFailureReason.UNKNOWN:
1257 if merge_state.failure_reason != MergeFailureReason.UNKNOWN:
1258 pull_request._last_merge_source_rev = \
1258 pull_request._last_merge_source_rev = \
1259 pull_request.source_ref_parts.commit_id
1259 pull_request.source_ref_parts.commit_id
1260 pull_request._last_merge_target_rev = target_reference.commit_id
1260 pull_request._last_merge_target_rev = target_reference.commit_id
1261 pull_request.last_merge_status = merge_state.failure_reason
1261 pull_request.last_merge_status = merge_state.failure_reason
1262 pull_request.shadow_merge_ref = merge_state.merge_ref
1262 pull_request.shadow_merge_ref = merge_state.merge_ref
1263 Session().add(pull_request)
1263 Session().add(pull_request)
1264 Session().commit()
1264 Session().commit()
1265
1265
1266 return merge_state
1266 return merge_state
1267
1267
1268 def _workspace_id(self, pull_request):
1268 def _workspace_id(self, pull_request):
1269 workspace_id = 'pr-%s' % pull_request.pull_request_id
1269 workspace_id = 'pr-%s' % pull_request.pull_request_id
1270 return workspace_id
1270 return workspace_id
1271
1271
1272 def merge_status_message(self, status_code):
1272 def merge_status_message(self, status_code):
1273 """
1273 """
1274 Return a human friendly error message for the given merge status code.
1274 Return a human friendly error message for the given merge status code.
1275 """
1275 """
1276 return self.MERGE_STATUS_MESSAGES[status_code]
1276 return self.MERGE_STATUS_MESSAGES[status_code]
1277
1277
1278 def generate_repo_data(self, repo, commit_id=None, branch=None,
1278 def generate_repo_data(self, repo, commit_id=None, branch=None,
1279 bookmark=None):
1279 bookmark=None):
1280 all_refs, selected_ref = \
1280 all_refs, selected_ref = \
1281 self._get_repo_pullrequest_sources(
1281 self._get_repo_pullrequest_sources(
1282 repo.scm_instance(), commit_id=commit_id,
1282 repo.scm_instance(), commit_id=commit_id,
1283 branch=branch, bookmark=bookmark)
1283 branch=branch, bookmark=bookmark)
1284
1284
1285 refs_select2 = []
1285 refs_select2 = []
1286 for element in all_refs:
1286 for element in all_refs:
1287 children = [{'id': x[0], 'text': x[1]} for x in element[0]]
1287 children = [{'id': x[0], 'text': x[1]} for x in element[0]]
1288 refs_select2.append({'text': element[1], 'children': children})
1288 refs_select2.append({'text': element[1], 'children': children})
1289
1289
1290 return {
1290 return {
1291 'user': {
1291 'user': {
1292 'user_id': repo.user.user_id,
1292 'user_id': repo.user.user_id,
1293 'username': repo.user.username,
1293 'username': repo.user.username,
1294 'firstname': repo.user.first_name,
1294 'firstname': repo.user.first_name,
1295 'lastname': repo.user.last_name,
1295 'lastname': repo.user.last_name,
1296 'gravatar_link': h.gravatar_url(repo.user.email, 14),
1296 'gravatar_link': h.gravatar_url(repo.user.email, 14),
1297 },
1297 },
1298 'description': h.chop_at_smart(repo.description_safe, '\n'),
1298 'description': h.chop_at_smart(repo.description_safe, '\n'),
1299 'refs': {
1299 'refs': {
1300 'all_refs': all_refs,
1300 'all_refs': all_refs,
1301 'selected_ref': selected_ref,
1301 'selected_ref': selected_ref,
1302 'select2_refs': refs_select2
1302 'select2_refs': refs_select2
1303 }
1303 }
1304 }
1304 }
1305
1305
1306 def generate_pullrequest_title(self, source, source_ref, target):
1306 def generate_pullrequest_title(self, source, source_ref, target):
1307 return u'{source}#{at_ref} to {target}'.format(
1307 return u'{source}#{at_ref} to {target}'.format(
1308 source=source,
1308 source=source,
1309 at_ref=source_ref,
1309 at_ref=source_ref,
1310 target=target,
1310 target=target,
1311 )
1311 )
1312
1312
1313 def _cleanup_merge_workspace(self, pull_request):
1313 def _cleanup_merge_workspace(self, pull_request):
1314 # Merging related cleanup
1314 # Merging related cleanup
1315 target_scm = pull_request.target_repo.scm_instance()
1315 target_scm = pull_request.target_repo.scm_instance()
1316 workspace_id = 'pr-%s' % pull_request.pull_request_id
1316 workspace_id = 'pr-%s' % pull_request.pull_request_id
1317
1317
1318 try:
1318 try:
1319 target_scm.cleanup_merge_workspace(workspace_id)
1319 target_scm.cleanup_merge_workspace(workspace_id)
1320 except NotImplementedError:
1320 except NotImplementedError:
1321 pass
1321 pass
1322
1322
1323 def _get_repo_pullrequest_sources(
1323 def _get_repo_pullrequest_sources(
1324 self, repo, commit_id=None, branch=None, bookmark=None):
1324 self, repo, commit_id=None, branch=None, bookmark=None):
1325 """
1325 """
1326 Return a structure with repo's interesting commits, suitable for
1326 Return a structure with repo's interesting commits, suitable for
1327 the selectors in pullrequest controller
1327 the selectors in pullrequest controller
1328
1328
1329 :param commit_id: a commit that must be in the list somehow
1329 :param commit_id: a commit that must be in the list somehow
1330 and selected by default
1330 and selected by default
1331 :param branch: a branch that must be in the list and selected
1331 :param branch: a branch that must be in the list and selected
1332 by default - even if closed
1332 by default - even if closed
1333 :param bookmark: a bookmark that must be in the list and selected
1333 :param bookmark: a bookmark that must be in the list and selected
1334 """
1334 """
1335
1335
1336 commit_id = safe_str(commit_id) if commit_id else None
1336 commit_id = safe_str(commit_id) if commit_id else None
1337 branch = safe_str(branch) if branch else None
1337 branch = safe_str(branch) if branch else None
1338 bookmark = safe_str(bookmark) if bookmark else None
1338 bookmark = safe_str(bookmark) if bookmark else None
1339
1339
1340 selected = None
1340 selected = None
1341
1341
1342 # order matters: first source that has commit_id in it will be selected
1342 # order matters: first source that has commit_id in it will be selected
1343 sources = []
1343 sources = []
1344 sources.append(('book', repo.bookmarks.items(), _('Bookmarks'), bookmark))
1344 sources.append(('book', repo.bookmarks.items(), _('Bookmarks'), bookmark))
1345 sources.append(('branch', repo.branches.items(), _('Branches'), branch))
1345 sources.append(('branch', repo.branches.items(), _('Branches'), branch))
1346
1346
1347 if commit_id:
1347 if commit_id:
1348 ref_commit = (h.short_id(commit_id), commit_id)
1348 ref_commit = (h.short_id(commit_id), commit_id)
1349 sources.append(('rev', [ref_commit], _('Commit IDs'), commit_id))
1349 sources.append(('rev', [ref_commit], _('Commit IDs'), commit_id))
1350
1350
1351 sources.append(
1351 sources.append(
1352 ('branch', repo.branches_closed.items(), _('Closed Branches'), branch),
1352 ('branch', repo.branches_closed.items(), _('Closed Branches'), branch),
1353 )
1353 )
1354
1354
1355 groups = []
1355 groups = []
1356 for group_key, ref_list, group_name, match in sources:
1356 for group_key, ref_list, group_name, match in sources:
1357 group_refs = []
1357 group_refs = []
1358 for ref_name, ref_id in ref_list:
1358 for ref_name, ref_id in ref_list:
1359 ref_key = '%s:%s:%s' % (group_key, ref_name, ref_id)
1359 ref_key = '%s:%s:%s' % (group_key, ref_name, ref_id)
1360 group_refs.append((ref_key, ref_name))
1360 group_refs.append((ref_key, ref_name))
1361
1361
1362 if not selected:
1362 if not selected:
1363 if set([commit_id, match]) & set([ref_id, ref_name]):
1363 if set([commit_id, match]) & set([ref_id, ref_name]):
1364 selected = ref_key
1364 selected = ref_key
1365
1365
1366 if group_refs:
1366 if group_refs:
1367 groups.append((group_refs, group_name))
1367 groups.append((group_refs, group_name))
1368
1368
1369 if not selected:
1369 if not selected:
1370 ref = commit_id or branch or bookmark
1370 ref = commit_id or branch or bookmark
1371 if ref:
1371 if ref:
1372 raise CommitDoesNotExistError(
1372 raise CommitDoesNotExistError(
1373 'No commit refs could be found matching: %s' % ref)
1373 'No commit refs could be found matching: %s' % ref)
1374 elif repo.DEFAULT_BRANCH_NAME in repo.branches:
1374 elif repo.DEFAULT_BRANCH_NAME in repo.branches:
1375 selected = 'branch:%s:%s' % (
1375 selected = 'branch:%s:%s' % (
1376 repo.DEFAULT_BRANCH_NAME,
1376 repo.DEFAULT_BRANCH_NAME,
1377 repo.branches[repo.DEFAULT_BRANCH_NAME]
1377 repo.branches[repo.DEFAULT_BRANCH_NAME]
1378 )
1378 )
1379 elif repo.commit_ids:
1379 elif repo.commit_ids:
1380 rev = repo.commit_ids[0]
1380 rev = repo.commit_ids[0]
1381 selected = 'rev:%s:%s' % (rev, rev)
1381 selected = 'rev:%s:%s' % (rev, rev)
1382 else:
1382 else:
1383 raise EmptyRepositoryError()
1383 raise EmptyRepositoryError()
1384 return groups, selected
1384 return groups, selected
1385
1385
1386 def get_diff(self, source_repo, source_ref_id, target_ref_id, context=DIFF_CONTEXT):
1386 def get_diff(self, source_repo, source_ref_id, target_ref_id, context=DIFF_CONTEXT):
1387 return self._get_diff_from_pr_or_version(
1387 return self._get_diff_from_pr_or_version(
1388 source_repo, source_ref_id, target_ref_id, context=context)
1388 source_repo, source_ref_id, target_ref_id, context=context)
1389
1389
1390 def _get_diff_from_pr_or_version(
1390 def _get_diff_from_pr_or_version(
1391 self, source_repo, source_ref_id, target_ref_id, context):
1391 self, source_repo, source_ref_id, target_ref_id, context):
1392 target_commit = source_repo.get_commit(
1392 target_commit = source_repo.get_commit(
1393 commit_id=safe_str(target_ref_id))
1393 commit_id=safe_str(target_ref_id))
1394 source_commit = source_repo.get_commit(
1394 source_commit = source_repo.get_commit(
1395 commit_id=safe_str(source_ref_id))
1395 commit_id=safe_str(source_ref_id))
1396 if isinstance(source_repo, Repository):
1396 if isinstance(source_repo, Repository):
1397 vcs_repo = source_repo.scm_instance()
1397 vcs_repo = source_repo.scm_instance()
1398 else:
1398 else:
1399 vcs_repo = source_repo
1399 vcs_repo = source_repo
1400
1400
1401 # TODO: johbo: In the context of an update, we cannot reach
1401 # TODO: johbo: In the context of an update, we cannot reach
1402 # the old commit anymore with our normal mechanisms. It needs
1402 # the old commit anymore with our normal mechanisms. It needs
1403 # some sort of special support in the vcs layer to avoid this
1403 # some sort of special support in the vcs layer to avoid this
1404 # workaround.
1404 # workaround.
1405 if (source_commit.raw_id == vcs_repo.EMPTY_COMMIT_ID and
1405 if (source_commit.raw_id == vcs_repo.EMPTY_COMMIT_ID and
1406 vcs_repo.alias == 'git'):
1406 vcs_repo.alias == 'git'):
1407 source_commit.raw_id = safe_str(source_ref_id)
1407 source_commit.raw_id = safe_str(source_ref_id)
1408
1408
1409 log.debug('calculating diff between '
1409 log.debug('calculating diff between '
1410 'source_ref:%s and target_ref:%s for repo `%s`',
1410 'source_ref:%s and target_ref:%s for repo `%s`',
1411 target_ref_id, source_ref_id,
1411 target_ref_id, source_ref_id,
1412 safe_unicode(vcs_repo.path))
1412 safe_unicode(vcs_repo.path))
1413
1413
1414 vcs_diff = vcs_repo.get_diff(
1414 vcs_diff = vcs_repo.get_diff(
1415 commit1=target_commit, commit2=source_commit, context=context)
1415 commit1=target_commit, commit2=source_commit, context=context)
1416 return vcs_diff
1416 return vcs_diff
1417
1417
1418 def _is_merge_enabled(self, pull_request):
1418 def _is_merge_enabled(self, pull_request):
1419 settings_model = VcsSettingsModel(repo=pull_request.target_repo)
1419 settings_model = VcsSettingsModel(repo=pull_request.target_repo)
1420 settings = settings_model.get_general_settings()
1420 settings = settings_model.get_general_settings()
1421 return settings.get('rhodecode_pr_merge_enabled', False)
1421 return settings.get('rhodecode_pr_merge_enabled', False)
1422
1422
1423 def _use_rebase_for_merging(self, pull_request):
1423 def _use_rebase_for_merging(self, pull_request):
1424 settings_model = VcsSettingsModel(repo=pull_request.target_repo)
1424 settings_model = VcsSettingsModel(repo=pull_request.target_repo)
1425 settings = settings_model.get_general_settings()
1425 settings = settings_model.get_general_settings()
1426 return settings.get('rhodecode_hg_use_rebase_for_merging', False)
1426 return settings.get('rhodecode_hg_use_rebase_for_merging', False)
1427
1427
1428 def _log_audit_action(self, action, action_data, user, pull_request):
1428 def _log_audit_action(self, action, action_data, user, pull_request):
1429 audit_logger.store(
1429 audit_logger.store(
1430 action=action,
1430 action=action,
1431 action_data=action_data,
1431 action_data=action_data,
1432 user=user,
1432 user=user,
1433 repo=pull_request.target_repo)
1433 repo=pull_request.target_repo)
1434
1434
1435 def get_reviewer_functions(self):
1435 def get_reviewer_functions(self):
1436 """
1436 """
1437 Fetches functions for validation and fetching default reviewers.
1437 Fetches functions for validation and fetching default reviewers.
1438 If available we use the EE package, else we fallback to CE
1438 If available we use the EE package, else we fallback to CE
1439 package functions
1439 package functions
1440 """
1440 """
1441 try:
1441 try:
1442 from rc_reviewers.utils import get_default_reviewers_data
1442 from rc_reviewers.utils import get_default_reviewers_data
1443 from rc_reviewers.utils import validate_default_reviewers
1443 from rc_reviewers.utils import validate_default_reviewers
1444 except ImportError:
1444 except ImportError:
1445 from rhodecode.apps.repository.utils import \
1445 from rhodecode.apps.repository.utils import \
1446 get_default_reviewers_data
1446 get_default_reviewers_data
1447 from rhodecode.apps.repository.utils import \
1447 from rhodecode.apps.repository.utils import \
1448 validate_default_reviewers
1448 validate_default_reviewers
1449
1449
1450 return get_default_reviewers_data, validate_default_reviewers
1450 return get_default_reviewers_data, validate_default_reviewers
1451
1451
1452
1452
1453 class MergeCheck(object):
1453 class MergeCheck(object):
1454 """
1454 """
1455 Perform Merge Checks and returns a check object which stores information
1455 Perform Merge Checks and returns a check object which stores information
1456 about merge errors, and merge conditions
1456 about merge errors, and merge conditions
1457 """
1457 """
1458 TODO_CHECK = 'todo'
1458 TODO_CHECK = 'todo'
1459 PERM_CHECK = 'perm'
1459 PERM_CHECK = 'perm'
1460 REVIEW_CHECK = 'review'
1460 REVIEW_CHECK = 'review'
1461 MERGE_CHECK = 'merge'
1461 MERGE_CHECK = 'merge'
1462
1462
1463 def __init__(self):
1463 def __init__(self):
1464 self.review_status = None
1464 self.review_status = None
1465 self.merge_possible = None
1465 self.merge_possible = None
1466 self.merge_msg = ''
1466 self.merge_msg = ''
1467 self.failed = None
1467 self.failed = None
1468 self.errors = []
1468 self.errors = []
1469 self.error_details = OrderedDict()
1469 self.error_details = OrderedDict()
1470
1470
1471 def push_error(self, error_type, message, error_key, details):
1471 def push_error(self, error_type, message, error_key, details):
1472 self.failed = True
1472 self.failed = True
1473 self.errors.append([error_type, message])
1473 self.errors.append([error_type, message])
1474 self.error_details[error_key] = dict(
1474 self.error_details[error_key] = dict(
1475 details=details,
1475 details=details,
1476 error_type=error_type,
1476 error_type=error_type,
1477 message=message
1477 message=message
1478 )
1478 )
1479
1479
1480 @classmethod
1480 @classmethod
1481 def validate(cls, pull_request, user, fail_early=False, translator=None):
1481 def validate(cls, pull_request, user, fail_early=False, translator=None):
1482 # if migrated to pyramid...
1482 # if migrated to pyramid...
1483 # _ = lambda: translator or _ # use passed in translator if any
1483 # _ = lambda: translator or _ # use passed in translator if any
1484
1484
1485 merge_check = cls()
1485 merge_check = cls()
1486
1486
1487 # permissions to merge
1487 # permissions to merge
1488 user_allowed_to_merge = PullRequestModel().check_user_merge(
1488 user_allowed_to_merge = PullRequestModel().check_user_merge(
1489 pull_request, user)
1489 pull_request, user)
1490 if not user_allowed_to_merge:
1490 if not user_allowed_to_merge:
1491 log.debug("MergeCheck: cannot merge, approval is pending.")
1491 log.debug("MergeCheck: cannot merge, approval is pending.")
1492
1492
1493 msg = _('User `{}` not allowed to perform merge.').format(user.username)
1493 msg = _('User `{}` not allowed to perform merge.').format(user.username)
1494 merge_check.push_error('error', msg, cls.PERM_CHECK, user.username)
1494 merge_check.push_error('error', msg, cls.PERM_CHECK, user.username)
1495 if fail_early:
1495 if fail_early:
1496 return merge_check
1496 return merge_check
1497
1497
1498 # review status, must be always present
1498 # review status, must be always present
1499 review_status = pull_request.calculated_review_status()
1499 review_status = pull_request.calculated_review_status()
1500 merge_check.review_status = review_status
1500 merge_check.review_status = review_status
1501
1501
1502 status_approved = review_status == ChangesetStatus.STATUS_APPROVED
1502 status_approved = review_status == ChangesetStatus.STATUS_APPROVED
1503 if not status_approved:
1503 if not status_approved:
1504 log.debug("MergeCheck: cannot merge, approval is pending.")
1504 log.debug("MergeCheck: cannot merge, approval is pending.")
1505
1505
1506 msg = _('Pull request reviewer approval is pending.')
1506 msg = _('Pull request reviewer approval is pending.')
1507
1507
1508 merge_check.push_error(
1508 merge_check.push_error(
1509 'warning', msg, cls.REVIEW_CHECK, review_status)
1509 'warning', msg, cls.REVIEW_CHECK, review_status)
1510
1510
1511 if fail_early:
1511 if fail_early:
1512 return merge_check
1512 return merge_check
1513
1513
1514 # left over TODOs
1514 # left over TODOs
1515 todos = CommentsModel().get_unresolved_todos(pull_request)
1515 todos = CommentsModel().get_unresolved_todos(pull_request)
1516 if todos:
1516 if todos:
1517 log.debug("MergeCheck: cannot merge, {} "
1517 log.debug("MergeCheck: cannot merge, {} "
1518 "unresolved todos left.".format(len(todos)))
1518 "unresolved todos left.".format(len(todos)))
1519
1519
1520 if len(todos) == 1:
1520 if len(todos) == 1:
1521 msg = _('Cannot merge, {} TODO still not resolved.').format(
1521 msg = _('Cannot merge, {} TODO still not resolved.').format(
1522 len(todos))
1522 len(todos))
1523 else:
1523 else:
1524 msg = _('Cannot merge, {} TODOs still not resolved.').format(
1524 msg = _('Cannot merge, {} TODOs still not resolved.').format(
1525 len(todos))
1525 len(todos))
1526
1526
1527 merge_check.push_error('warning', msg, cls.TODO_CHECK, todos)
1527 merge_check.push_error('warning', msg, cls.TODO_CHECK, todos)
1528
1528
1529 if fail_early:
1529 if fail_early:
1530 return merge_check
1530 return merge_check
1531
1531
1532 # merge possible
1532 # merge possible
1533 merge_status, msg = PullRequestModel().merge_status(pull_request)
1533 merge_status, msg = PullRequestModel().merge_status(pull_request)
1534 merge_check.merge_possible = merge_status
1534 merge_check.merge_possible = merge_status
1535 merge_check.merge_msg = msg
1535 merge_check.merge_msg = msg
1536 if not merge_status:
1536 if not merge_status:
1537 log.debug(
1537 log.debug(
1538 "MergeCheck: cannot merge, pull request merge not possible.")
1538 "MergeCheck: cannot merge, pull request merge not possible.")
1539 merge_check.push_error('warning', msg, cls.MERGE_CHECK, None)
1539 merge_check.push_error('warning', msg, cls.MERGE_CHECK, None)
1540
1540
1541 if fail_early:
1541 if fail_early:
1542 return merge_check
1542 return merge_check
1543
1543
1544 log.debug('MergeCheck: is failed: %s', merge_check.failed)
1544 log.debug('MergeCheck: is failed: %s', merge_check.failed)
1545 return merge_check
1545 return merge_check
1546
1546
1547 @classmethod
1548 def get_merge_conditions(cls, pull_request):
1549 merge_details = {}
1550
1551 model = PullRequestModel()
1552 use_rebase = model._use_rebase_for_merging(pull_request)
1553
1554 if use_rebase:
1555 merge_details['merge_strategy'] = dict(
1556 details={},
1557 message=_('Merge strategy: rebase')
1558 )
1559 else:
1560 merge_details['merge_strategy'] = dict(
1561 details={},
1562 message=_('Merge strategy: explicit merge commit')
1563 )
1564
1565 close_branch = model._close_branch_before_merging(pull_request)
1566 if close_branch:
1567 repo_type = pull_request.target_repo.repo_type
1568 if repo_type == 'hg':
1569 close_msg = _('Source branch will be closed after merge.')
1570 elif repo_type == 'git':
1571 close_msg = _('Source branch will be deleted after merge.')
1572
1573 merge_details['close_branch'] = dict(
1574 details={},
1575 message=close_msg
1576 )
1577
1578 return merge_details
1547
1579
1548 ChangeTuple = namedtuple('ChangeTuple',
1580 ChangeTuple = namedtuple('ChangeTuple',
1549 ['added', 'common', 'removed', 'total'])
1581 ['added', 'common', 'removed', 'total'])
1550
1582
1551 FileChangeTuple = namedtuple('FileChangeTuple',
1583 FileChangeTuple = namedtuple('FileChangeTuple',
1552 ['added', 'modified', 'removed'])
1584 ['added', 'modified', 'removed'])
@@ -1,2396 +1,2400 b''
1 //Primary CSS
1 //Primary CSS
2
2
3 //--- IMPORTS ------------------//
3 //--- IMPORTS ------------------//
4
4
5 @import 'helpers';
5 @import 'helpers';
6 @import 'mixins';
6 @import 'mixins';
7 @import 'rcicons';
7 @import 'rcicons';
8 @import 'fonts';
8 @import 'fonts';
9 @import 'variables';
9 @import 'variables';
10 @import 'bootstrap-variables';
10 @import 'bootstrap-variables';
11 @import 'form-bootstrap';
11 @import 'form-bootstrap';
12 @import 'codemirror';
12 @import 'codemirror';
13 @import 'legacy_code_styles';
13 @import 'legacy_code_styles';
14 @import 'readme-box';
14 @import 'readme-box';
15 @import 'progress-bar';
15 @import 'progress-bar';
16
16
17 @import 'type';
17 @import 'type';
18 @import 'alerts';
18 @import 'alerts';
19 @import 'buttons';
19 @import 'buttons';
20 @import 'tags';
20 @import 'tags';
21 @import 'code-block';
21 @import 'code-block';
22 @import 'examples';
22 @import 'examples';
23 @import 'login';
23 @import 'login';
24 @import 'main-content';
24 @import 'main-content';
25 @import 'select2';
25 @import 'select2';
26 @import 'comments';
26 @import 'comments';
27 @import 'panels-bootstrap';
27 @import 'panels-bootstrap';
28 @import 'panels';
28 @import 'panels';
29 @import 'deform';
29 @import 'deform';
30
30
31 //--- BASE ------------------//
31 //--- BASE ------------------//
32 .noscript-error {
32 .noscript-error {
33 top: 0;
33 top: 0;
34 left: 0;
34 left: 0;
35 width: 100%;
35 width: 100%;
36 z-index: 101;
36 z-index: 101;
37 text-align: center;
37 text-align: center;
38 font-family: @text-semibold;
38 font-family: @text-semibold;
39 font-size: 120%;
39 font-size: 120%;
40 color: white;
40 color: white;
41 background-color: @alert2;
41 background-color: @alert2;
42 padding: 5px 0 5px 0;
42 padding: 5px 0 5px 0;
43 }
43 }
44
44
45 html {
45 html {
46 display: table;
46 display: table;
47 height: 100%;
47 height: 100%;
48 width: 100%;
48 width: 100%;
49 }
49 }
50
50
51 body {
51 body {
52 display: table-cell;
52 display: table-cell;
53 width: 100%;
53 width: 100%;
54 }
54 }
55
55
56 //--- LAYOUT ------------------//
56 //--- LAYOUT ------------------//
57
57
58 .hidden{
58 .hidden{
59 display: none !important;
59 display: none !important;
60 }
60 }
61
61
62 .box{
62 .box{
63 float: left;
63 float: left;
64 width: 100%;
64 width: 100%;
65 }
65 }
66
66
67 .browser-header {
67 .browser-header {
68 clear: both;
68 clear: both;
69 }
69 }
70 .main {
70 .main {
71 clear: both;
71 clear: both;
72 padding:0 0 @pagepadding;
72 padding:0 0 @pagepadding;
73 height: auto;
73 height: auto;
74
74
75 &:after { //clearfix
75 &:after { //clearfix
76 content:"";
76 content:"";
77 clear:both;
77 clear:both;
78 width:100%;
78 width:100%;
79 display:block;
79 display:block;
80 }
80 }
81 }
81 }
82
82
83 .action-link{
83 .action-link{
84 margin-left: @padding;
84 margin-left: @padding;
85 padding-left: @padding;
85 padding-left: @padding;
86 border-left: @border-thickness solid @border-default-color;
86 border-left: @border-thickness solid @border-default-color;
87 }
87 }
88
88
89 input + .action-link, .action-link.first{
89 input + .action-link, .action-link.first{
90 border-left: none;
90 border-left: none;
91 }
91 }
92
92
93 .action-link.last{
93 .action-link.last{
94 margin-right: @padding;
94 margin-right: @padding;
95 padding-right: @padding;
95 padding-right: @padding;
96 }
96 }
97
97
98 .action-link.active,
98 .action-link.active,
99 .action-link.active a{
99 .action-link.active a{
100 color: @grey4;
100 color: @grey4;
101 }
101 }
102
102
103 .clipboard-action {
103 .clipboard-action {
104 cursor: pointer;
104 cursor: pointer;
105 }
105 }
106
106
107 ul.simple-list{
107 ul.simple-list{
108 list-style: none;
108 list-style: none;
109 margin: 0;
109 margin: 0;
110 padding: 0;
110 padding: 0;
111 }
111 }
112
112
113 .main-content {
113 .main-content {
114 padding-bottom: @pagepadding;
114 padding-bottom: @pagepadding;
115 }
115 }
116
116
117 .wide-mode-wrapper {
117 .wide-mode-wrapper {
118 max-width:4000px !important;
118 max-width:4000px !important;
119 }
119 }
120
120
121 .wrapper {
121 .wrapper {
122 position: relative;
122 position: relative;
123 max-width: @wrapper-maxwidth;
123 max-width: @wrapper-maxwidth;
124 margin: 0 auto;
124 margin: 0 auto;
125 }
125 }
126
126
127 #content {
127 #content {
128 clear: both;
128 clear: both;
129 padding: 0 @contentpadding;
129 padding: 0 @contentpadding;
130 }
130 }
131
131
132 .advanced-settings-fields{
132 .advanced-settings-fields{
133 input{
133 input{
134 margin-left: @textmargin;
134 margin-left: @textmargin;
135 margin-right: @padding/2;
135 margin-right: @padding/2;
136 }
136 }
137 }
137 }
138
138
139 .cs_files_title {
139 .cs_files_title {
140 margin: @pagepadding 0 0;
140 margin: @pagepadding 0 0;
141 }
141 }
142
142
143 input.inline[type="file"] {
143 input.inline[type="file"] {
144 display: inline;
144 display: inline;
145 }
145 }
146
146
147 .error_page {
147 .error_page {
148 margin: 10% auto;
148 margin: 10% auto;
149
149
150 h1 {
150 h1 {
151 color: @grey2;
151 color: @grey2;
152 }
152 }
153
153
154 .alert {
154 .alert {
155 margin: @padding 0;
155 margin: @padding 0;
156 }
156 }
157
157
158 .error-branding {
158 .error-branding {
159 font-family: @text-semibold;
159 font-family: @text-semibold;
160 color: @grey4;
160 color: @grey4;
161 }
161 }
162
162
163 .error_message {
163 .error_message {
164 font-family: @text-regular;
164 font-family: @text-regular;
165 }
165 }
166
166
167 .sidebar {
167 .sidebar {
168 min-height: 275px;
168 min-height: 275px;
169 margin: 0;
169 margin: 0;
170 padding: 0 0 @sidebarpadding @sidebarpadding;
170 padding: 0 0 @sidebarpadding @sidebarpadding;
171 border: none;
171 border: none;
172 }
172 }
173
173
174 .main-content {
174 .main-content {
175 position: relative;
175 position: relative;
176 margin: 0 @sidebarpadding @sidebarpadding;
176 margin: 0 @sidebarpadding @sidebarpadding;
177 padding: 0 0 0 @sidebarpadding;
177 padding: 0 0 0 @sidebarpadding;
178 border-left: @border-thickness solid @grey5;
178 border-left: @border-thickness solid @grey5;
179
179
180 @media (max-width:767px) {
180 @media (max-width:767px) {
181 clear: both;
181 clear: both;
182 width: 100%;
182 width: 100%;
183 margin: 0;
183 margin: 0;
184 border: none;
184 border: none;
185 }
185 }
186 }
186 }
187
187
188 .inner-column {
188 .inner-column {
189 float: left;
189 float: left;
190 width: 29.75%;
190 width: 29.75%;
191 min-height: 150px;
191 min-height: 150px;
192 margin: @sidebarpadding 2% 0 0;
192 margin: @sidebarpadding 2% 0 0;
193 padding: 0 2% 0 0;
193 padding: 0 2% 0 0;
194 border-right: @border-thickness solid @grey5;
194 border-right: @border-thickness solid @grey5;
195
195
196 @media (max-width:767px) {
196 @media (max-width:767px) {
197 clear: both;
197 clear: both;
198 width: 100%;
198 width: 100%;
199 border: none;
199 border: none;
200 }
200 }
201
201
202 ul {
202 ul {
203 padding-left: 1.25em;
203 padding-left: 1.25em;
204 }
204 }
205
205
206 &:last-child {
206 &:last-child {
207 margin: @sidebarpadding 0 0;
207 margin: @sidebarpadding 0 0;
208 border: none;
208 border: none;
209 }
209 }
210
210
211 h4 {
211 h4 {
212 margin: 0 0 @padding;
212 margin: 0 0 @padding;
213 font-family: @text-semibold;
213 font-family: @text-semibold;
214 }
214 }
215 }
215 }
216 }
216 }
217 .error-page-logo {
217 .error-page-logo {
218 width: 130px;
218 width: 130px;
219 height: 160px;
219 height: 160px;
220 }
220 }
221
221
222 // HEADER
222 // HEADER
223 .header {
223 .header {
224
224
225 // TODO: johbo: Fix login pages, so that they work without a min-height
225 // TODO: johbo: Fix login pages, so that they work without a min-height
226 // for the header and then remove the min-height. I chose a smaller value
226 // for the header and then remove the min-height. I chose a smaller value
227 // intentionally here to avoid rendering issues in the main navigation.
227 // intentionally here to avoid rendering issues in the main navigation.
228 min-height: 49px;
228 min-height: 49px;
229
229
230 position: relative;
230 position: relative;
231 vertical-align: bottom;
231 vertical-align: bottom;
232 padding: 0 @header-padding;
232 padding: 0 @header-padding;
233 background-color: @grey2;
233 background-color: @grey2;
234 color: @grey5;
234 color: @grey5;
235
235
236 .title {
236 .title {
237 overflow: visible;
237 overflow: visible;
238 }
238 }
239
239
240 &:before,
240 &:before,
241 &:after {
241 &:after {
242 content: "";
242 content: "";
243 clear: both;
243 clear: both;
244 width: 100%;
244 width: 100%;
245 }
245 }
246
246
247 // TODO: johbo: Avoids breaking "Repositories" chooser
247 // TODO: johbo: Avoids breaking "Repositories" chooser
248 .select2-container .select2-choice .select2-arrow {
248 .select2-container .select2-choice .select2-arrow {
249 display: none;
249 display: none;
250 }
250 }
251 }
251 }
252
252
253 #header-inner {
253 #header-inner {
254 &.title {
254 &.title {
255 margin: 0;
255 margin: 0;
256 }
256 }
257 &:before,
257 &:before,
258 &:after {
258 &:after {
259 content: "";
259 content: "";
260 clear: both;
260 clear: both;
261 }
261 }
262 }
262 }
263
263
264 // Gists
264 // Gists
265 #files_data {
265 #files_data {
266 clear: both; //for firefox
266 clear: both; //for firefox
267 }
267 }
268 #gistid {
268 #gistid {
269 margin-right: @padding;
269 margin-right: @padding;
270 }
270 }
271
271
272 // Global Settings Editor
272 // Global Settings Editor
273 .textarea.editor {
273 .textarea.editor {
274 float: left;
274 float: left;
275 position: relative;
275 position: relative;
276 max-width: @texteditor-width;
276 max-width: @texteditor-width;
277
277
278 select {
278 select {
279 position: absolute;
279 position: absolute;
280 top:10px;
280 top:10px;
281 right:0;
281 right:0;
282 }
282 }
283
283
284 .CodeMirror {
284 .CodeMirror {
285 margin: 0;
285 margin: 0;
286 }
286 }
287
287
288 .help-block {
288 .help-block {
289 margin: 0 0 @padding;
289 margin: 0 0 @padding;
290 padding:.5em;
290 padding:.5em;
291 background-color: @grey6;
291 background-color: @grey6;
292 &.pre-formatting {
292 &.pre-formatting {
293 white-space: pre;
293 white-space: pre;
294 }
294 }
295 }
295 }
296 }
296 }
297
297
298 ul.auth_plugins {
298 ul.auth_plugins {
299 margin: @padding 0 @padding @legend-width;
299 margin: @padding 0 @padding @legend-width;
300 padding: 0;
300 padding: 0;
301
301
302 li {
302 li {
303 margin-bottom: @padding;
303 margin-bottom: @padding;
304 line-height: 1em;
304 line-height: 1em;
305 list-style-type: none;
305 list-style-type: none;
306
306
307 .auth_buttons .btn {
307 .auth_buttons .btn {
308 margin-right: @padding;
308 margin-right: @padding;
309 }
309 }
310
310
311 &:before { content: none; }
311 &:before { content: none; }
312 }
312 }
313 }
313 }
314
314
315
315
316 // My Account PR list
316 // My Account PR list
317
317
318 #show_closed {
318 #show_closed {
319 margin: 0 1em 0 0;
319 margin: 0 1em 0 0;
320 }
320 }
321
321
322 .pullrequestlist {
322 .pullrequestlist {
323 .closed {
323 .closed {
324 background-color: @grey6;
324 background-color: @grey6;
325 }
325 }
326 .td-status {
326 .td-status {
327 padding-left: .5em;
327 padding-left: .5em;
328 }
328 }
329 .log-container .truncate {
329 .log-container .truncate {
330 height: 2.75em;
330 height: 2.75em;
331 white-space: pre-line;
331 white-space: pre-line;
332 }
332 }
333 table.rctable .user {
333 table.rctable .user {
334 padding-left: 0;
334 padding-left: 0;
335 }
335 }
336 table.rctable {
336 table.rctable {
337 td.td-description,
337 td.td-description,
338 .rc-user {
338 .rc-user {
339 min-width: auto;
339 min-width: auto;
340 }
340 }
341 }
341 }
342 }
342 }
343
343
344 // Pull Requests
344 // Pull Requests
345
345
346 .pullrequests_section_head {
346 .pullrequests_section_head {
347 display: block;
347 display: block;
348 clear: both;
348 clear: both;
349 margin: @padding 0;
349 margin: @padding 0;
350 font-family: @text-bold;
350 font-family: @text-bold;
351 }
351 }
352
352
353 .pr-origininfo, .pr-targetinfo {
353 .pr-origininfo, .pr-targetinfo {
354 position: relative;
354 position: relative;
355
355
356 .tag {
356 .tag {
357 display: inline-block;
357 display: inline-block;
358 margin: 0 1em .5em 0;
358 margin: 0 1em .5em 0;
359 }
359 }
360
360
361 .clone-url {
361 .clone-url {
362 display: inline-block;
362 display: inline-block;
363 margin: 0 0 .5em 0;
363 margin: 0 0 .5em 0;
364 padding: 0;
364 padding: 0;
365 line-height: 1.2em;
365 line-height: 1.2em;
366 }
366 }
367 }
367 }
368
368
369 .pr-mergeinfo {
369 .pr-mergeinfo {
370 min-width: 95% !important;
370 min-width: 95% !important;
371 padding: 0 !important;
371 padding: 0 !important;
372 border: 0;
372 border: 0;
373 }
373 }
374 .pr-mergeinfo-copy {
374 .pr-mergeinfo-copy {
375 padding: 0 0;
375 padding: 0 0;
376 }
376 }
377
377
378 .pr-pullinfo {
378 .pr-pullinfo {
379 min-width: 95% !important;
379 min-width: 95% !important;
380 padding: 0 !important;
380 padding: 0 !important;
381 border: 0;
381 border: 0;
382 }
382 }
383 .pr-pullinfo-copy {
383 .pr-pullinfo-copy {
384 padding: 0 0;
384 padding: 0 0;
385 }
385 }
386
386
387
387
388 #pr-title-input {
388 #pr-title-input {
389 width: 72%;
389 width: 72%;
390 font-size: 1em;
390 font-size: 1em;
391 font-family: @text-bold;
391 font-family: @text-bold;
392 margin: 0;
392 margin: 0;
393 padding: 0 0 0 @padding/4;
393 padding: 0 0 0 @padding/4;
394 line-height: 1.7em;
394 line-height: 1.7em;
395 color: @text-color;
395 color: @text-color;
396 letter-spacing: .02em;
396 letter-spacing: .02em;
397 }
397 }
398
398
399 #pullrequest_title {
399 #pullrequest_title {
400 width: 100%;
400 width: 100%;
401 box-sizing: border-box;
401 box-sizing: border-box;
402 }
402 }
403
403
404 #pr_open_message {
404 #pr_open_message {
405 border: @border-thickness solid #fff;
405 border: @border-thickness solid #fff;
406 border-radius: @border-radius;
406 border-radius: @border-radius;
407 padding: @padding-large-vertical @padding-large-vertical @padding-large-vertical 0;
407 padding: @padding-large-vertical @padding-large-vertical @padding-large-vertical 0;
408 text-align: left;
408 text-align: left;
409 overflow: hidden;
409 overflow: hidden;
410 }
410 }
411
411
412 .pr-submit-button {
412 .pr-submit-button {
413 float: right;
413 float: right;
414 margin: 0 0 0 5px;
414 margin: 0 0 0 5px;
415 }
415 }
416
416
417 .pr-spacing-container {
417 .pr-spacing-container {
418 padding: 20px;
418 padding: 20px;
419 clear: both
419 clear: both
420 }
420 }
421
421
422 #pr-description-input {
422 #pr-description-input {
423 margin-bottom: 0;
423 margin-bottom: 0;
424 }
424 }
425
425
426 .pr-description-label {
426 .pr-description-label {
427 vertical-align: top;
427 vertical-align: top;
428 }
428 }
429
429
430 .perms_section_head {
430 .perms_section_head {
431 min-width: 625px;
431 min-width: 625px;
432
432
433 h2 {
433 h2 {
434 margin-bottom: 0;
434 margin-bottom: 0;
435 }
435 }
436
436
437 .label-checkbox {
437 .label-checkbox {
438 float: left;
438 float: left;
439 }
439 }
440
440
441 &.field {
441 &.field {
442 margin: @space 0 @padding;
442 margin: @space 0 @padding;
443 }
443 }
444
444
445 &:first-child.field {
445 &:first-child.field {
446 margin-top: 0;
446 margin-top: 0;
447
447
448 .label {
448 .label {
449 margin-top: 0;
449 margin-top: 0;
450 padding-top: 0;
450 padding-top: 0;
451 }
451 }
452
452
453 .radios {
453 .radios {
454 padding-top: 0;
454 padding-top: 0;
455 }
455 }
456 }
456 }
457
457
458 .radios {
458 .radios {
459 position: relative;
459 position: relative;
460 width: 405px;
460 width: 405px;
461 }
461 }
462 }
462 }
463
463
464 //--- MODULES ------------------//
464 //--- MODULES ------------------//
465
465
466
466
467 // Server Announcement
467 // Server Announcement
468 #server-announcement {
468 #server-announcement {
469 width: 95%;
469 width: 95%;
470 margin: @padding auto;
470 margin: @padding auto;
471 padding: @padding;
471 padding: @padding;
472 border-width: 2px;
472 border-width: 2px;
473 border-style: solid;
473 border-style: solid;
474 .border-radius(2px);
474 .border-radius(2px);
475 font-family: @text-bold;
475 font-family: @text-bold;
476
476
477 &.info { border-color: @alert4; background-color: @alert4-inner; }
477 &.info { border-color: @alert4; background-color: @alert4-inner; }
478 &.warning { border-color: @alert3; background-color: @alert3-inner; }
478 &.warning { border-color: @alert3; background-color: @alert3-inner; }
479 &.error { border-color: @alert2; background-color: @alert2-inner; }
479 &.error { border-color: @alert2; background-color: @alert2-inner; }
480 &.success { border-color: @alert1; background-color: @alert1-inner; }
480 &.success { border-color: @alert1; background-color: @alert1-inner; }
481 &.neutral { border-color: @grey3; background-color: @grey6; }
481 &.neutral { border-color: @grey3; background-color: @grey6; }
482 }
482 }
483
483
484 // Fixed Sidebar Column
484 // Fixed Sidebar Column
485 .sidebar-col-wrapper {
485 .sidebar-col-wrapper {
486 padding-left: @sidebar-all-width;
486 padding-left: @sidebar-all-width;
487
487
488 .sidebar {
488 .sidebar {
489 width: @sidebar-width;
489 width: @sidebar-width;
490 margin-left: -@sidebar-all-width;
490 margin-left: -@sidebar-all-width;
491 }
491 }
492 }
492 }
493
493
494 .sidebar-col-wrapper.scw-small {
494 .sidebar-col-wrapper.scw-small {
495 padding-left: @sidebar-small-all-width;
495 padding-left: @sidebar-small-all-width;
496
496
497 .sidebar {
497 .sidebar {
498 width: @sidebar-small-width;
498 width: @sidebar-small-width;
499 margin-left: -@sidebar-small-all-width;
499 margin-left: -@sidebar-small-all-width;
500 }
500 }
501 }
501 }
502
502
503
503
504 // FOOTER
504 // FOOTER
505 #footer {
505 #footer {
506 padding: 0;
506 padding: 0;
507 text-align: center;
507 text-align: center;
508 vertical-align: middle;
508 vertical-align: middle;
509 color: @grey2;
509 color: @grey2;
510 background-color: @grey6;
510 background-color: @grey6;
511
511
512 p {
512 p {
513 margin: 0;
513 margin: 0;
514 padding: 1em;
514 padding: 1em;
515 line-height: 1em;
515 line-height: 1em;
516 }
516 }
517
517
518 .server-instance { //server instance
518 .server-instance { //server instance
519 display: none;
519 display: none;
520 }
520 }
521
521
522 .title {
522 .title {
523 float: none;
523 float: none;
524 margin: 0 auto;
524 margin: 0 auto;
525 }
525 }
526 }
526 }
527
527
528 button.close {
528 button.close {
529 padding: 0;
529 padding: 0;
530 cursor: pointer;
530 cursor: pointer;
531 background: transparent;
531 background: transparent;
532 border: 0;
532 border: 0;
533 .box-shadow(none);
533 .box-shadow(none);
534 -webkit-appearance: none;
534 -webkit-appearance: none;
535 }
535 }
536
536
537 .close {
537 .close {
538 float: right;
538 float: right;
539 font-size: 21px;
539 font-size: 21px;
540 font-family: @text-bootstrap;
540 font-family: @text-bootstrap;
541 line-height: 1em;
541 line-height: 1em;
542 font-weight: bold;
542 font-weight: bold;
543 color: @grey2;
543 color: @grey2;
544
544
545 &:hover,
545 &:hover,
546 &:focus {
546 &:focus {
547 color: @grey1;
547 color: @grey1;
548 text-decoration: none;
548 text-decoration: none;
549 cursor: pointer;
549 cursor: pointer;
550 }
550 }
551 }
551 }
552
552
553 // GRID
553 // GRID
554 .sorting,
554 .sorting,
555 .sorting_desc,
555 .sorting_desc,
556 .sorting_asc {
556 .sorting_asc {
557 cursor: pointer;
557 cursor: pointer;
558 }
558 }
559 .sorting_desc:after {
559 .sorting_desc:after {
560 content: "\00A0\25B2";
560 content: "\00A0\25B2";
561 font-size: .75em;
561 font-size: .75em;
562 }
562 }
563 .sorting_asc:after {
563 .sorting_asc:after {
564 content: "\00A0\25BC";
564 content: "\00A0\25BC";
565 font-size: .68em;
565 font-size: .68em;
566 }
566 }
567
567
568
568
569 .user_auth_tokens {
569 .user_auth_tokens {
570
570
571 &.truncate {
571 &.truncate {
572 white-space: nowrap;
572 white-space: nowrap;
573 overflow: hidden;
573 overflow: hidden;
574 text-overflow: ellipsis;
574 text-overflow: ellipsis;
575 }
575 }
576
576
577 .fields .field .input {
577 .fields .field .input {
578 margin: 0;
578 margin: 0;
579 }
579 }
580
580
581 input#description {
581 input#description {
582 width: 100px;
582 width: 100px;
583 margin: 0;
583 margin: 0;
584 }
584 }
585
585
586 .drop-menu {
586 .drop-menu {
587 // TODO: johbo: Remove this, should work out of the box when
587 // TODO: johbo: Remove this, should work out of the box when
588 // having multiple inputs inline
588 // having multiple inputs inline
589 margin: 0 0 0 5px;
589 margin: 0 0 0 5px;
590 }
590 }
591 }
591 }
592 #user_list_table {
592 #user_list_table {
593 .closed {
593 .closed {
594 background-color: @grey6;
594 background-color: @grey6;
595 }
595 }
596 }
596 }
597
597
598
598
599 input {
599 input {
600 &.disabled {
600 &.disabled {
601 opacity: .5;
601 opacity: .5;
602 }
602 }
603 }
603 }
604
604
605 // remove extra padding in firefox
605 // remove extra padding in firefox
606 input::-moz-focus-inner { border:0; padding:0 }
606 input::-moz-focus-inner { border:0; padding:0 }
607
607
608 .adjacent input {
608 .adjacent input {
609 margin-bottom: @padding;
609 margin-bottom: @padding;
610 }
610 }
611
611
612 .permissions_boxes {
612 .permissions_boxes {
613 display: block;
613 display: block;
614 }
614 }
615
615
616 //TODO: lisa: this should be in tables
616 //TODO: lisa: this should be in tables
617 .show_more_col {
617 .show_more_col {
618 width: 20px;
618 width: 20px;
619 }
619 }
620
620
621 //FORMS
621 //FORMS
622
622
623 .medium-inline,
623 .medium-inline,
624 input#description.medium-inline {
624 input#description.medium-inline {
625 display: inline;
625 display: inline;
626 width: @medium-inline-input-width;
626 width: @medium-inline-input-width;
627 min-width: 100px;
627 min-width: 100px;
628 }
628 }
629
629
630 select {
630 select {
631 //reset
631 //reset
632 -webkit-appearance: none;
632 -webkit-appearance: none;
633 -moz-appearance: none;
633 -moz-appearance: none;
634
634
635 display: inline-block;
635 display: inline-block;
636 height: 28px;
636 height: 28px;
637 width: auto;
637 width: auto;
638 margin: 0 @padding @padding 0;
638 margin: 0 @padding @padding 0;
639 padding: 0 18px 0 8px;
639 padding: 0 18px 0 8px;
640 line-height:1em;
640 line-height:1em;
641 font-size: @basefontsize;
641 font-size: @basefontsize;
642 border: @border-thickness solid @rcblue;
642 border: @border-thickness solid @rcblue;
643 background:white url("../images/dt-arrow-dn.png") no-repeat 100% 50%;
643 background:white url("../images/dt-arrow-dn.png") no-repeat 100% 50%;
644 color: @rcblue;
644 color: @rcblue;
645
645
646 &:after {
646 &:after {
647 content: "\00A0\25BE";
647 content: "\00A0\25BE";
648 }
648 }
649
649
650 &:focus {
650 &:focus {
651 outline: none;
651 outline: none;
652 }
652 }
653 }
653 }
654
654
655 option {
655 option {
656 &:focus {
656 &:focus {
657 outline: none;
657 outline: none;
658 }
658 }
659 }
659 }
660
660
661 input,
661 input,
662 textarea {
662 textarea {
663 padding: @input-padding;
663 padding: @input-padding;
664 border: @input-border-thickness solid @border-highlight-color;
664 border: @input-border-thickness solid @border-highlight-color;
665 .border-radius (@border-radius);
665 .border-radius (@border-radius);
666 font-family: @text-light;
666 font-family: @text-light;
667 font-size: @basefontsize;
667 font-size: @basefontsize;
668
668
669 &.input-sm {
669 &.input-sm {
670 padding: 5px;
670 padding: 5px;
671 }
671 }
672
672
673 &#description {
673 &#description {
674 min-width: @input-description-minwidth;
674 min-width: @input-description-minwidth;
675 min-height: 1em;
675 min-height: 1em;
676 padding: 10px;
676 padding: 10px;
677 }
677 }
678 }
678 }
679
679
680 .field-sm {
680 .field-sm {
681 input,
681 input,
682 textarea {
682 textarea {
683 padding: 5px;
683 padding: 5px;
684 }
684 }
685 }
685 }
686
686
687 textarea {
687 textarea {
688 display: block;
688 display: block;
689 clear: both;
689 clear: both;
690 width: 100%;
690 width: 100%;
691 min-height: 100px;
691 min-height: 100px;
692 margin-bottom: @padding;
692 margin-bottom: @padding;
693 .box-sizing(border-box);
693 .box-sizing(border-box);
694 overflow: auto;
694 overflow: auto;
695 }
695 }
696
696
697 label {
697 label {
698 font-family: @text-light;
698 font-family: @text-light;
699 }
699 }
700
700
701 // GRAVATARS
701 // GRAVATARS
702 // centers gravatar on username to the right
702 // centers gravatar on username to the right
703
703
704 .gravatar {
704 .gravatar {
705 display: inline;
705 display: inline;
706 min-width: 16px;
706 min-width: 16px;
707 min-height: 16px;
707 min-height: 16px;
708 margin: -5px 0;
708 margin: -5px 0;
709 padding: 0;
709 padding: 0;
710 line-height: 1em;
710 line-height: 1em;
711 border: 1px solid @grey4;
711 border: 1px solid @grey4;
712 box-sizing: content-box;
712 box-sizing: content-box;
713
713
714 &.gravatar-large {
714 &.gravatar-large {
715 margin: -0.5em .25em -0.5em 0;
715 margin: -0.5em .25em -0.5em 0;
716 }
716 }
717
717
718 & + .user {
718 & + .user {
719 display: inline;
719 display: inline;
720 margin: 0;
720 margin: 0;
721 padding: 0 0 0 .17em;
721 padding: 0 0 0 .17em;
722 line-height: 1em;
722 line-height: 1em;
723 }
723 }
724 }
724 }
725
725
726 .user-inline-data {
726 .user-inline-data {
727 display: inline-block;
727 display: inline-block;
728 float: left;
728 float: left;
729 padding-left: .5em;
729 padding-left: .5em;
730 line-height: 1.3em;
730 line-height: 1.3em;
731 }
731 }
732
732
733 .rc-user { // gravatar + user wrapper
733 .rc-user { // gravatar + user wrapper
734 float: left;
734 float: left;
735 position: relative;
735 position: relative;
736 min-width: 100px;
736 min-width: 100px;
737 max-width: 200px;
737 max-width: 200px;
738 min-height: (@gravatar-size + @border-thickness * 2); // account for border
738 min-height: (@gravatar-size + @border-thickness * 2); // account for border
739 display: block;
739 display: block;
740 padding: 0 0 0 (@gravatar-size + @basefontsize/2 + @border-thickness * 2);
740 padding: 0 0 0 (@gravatar-size + @basefontsize/2 + @border-thickness * 2);
741
741
742
742
743 .gravatar {
743 .gravatar {
744 display: block;
744 display: block;
745 position: absolute;
745 position: absolute;
746 top: 0;
746 top: 0;
747 left: 0;
747 left: 0;
748 min-width: @gravatar-size;
748 min-width: @gravatar-size;
749 min-height: @gravatar-size;
749 min-height: @gravatar-size;
750 margin: 0;
750 margin: 0;
751 }
751 }
752
752
753 .user {
753 .user {
754 display: block;
754 display: block;
755 max-width: 175px;
755 max-width: 175px;
756 padding-top: 2px;
756 padding-top: 2px;
757 overflow: hidden;
757 overflow: hidden;
758 text-overflow: ellipsis;
758 text-overflow: ellipsis;
759 }
759 }
760 }
760 }
761
761
762 .gist-gravatar,
762 .gist-gravatar,
763 .journal_container {
763 .journal_container {
764 .gravatar-large {
764 .gravatar-large {
765 margin: 0 .5em -10px 0;
765 margin: 0 .5em -10px 0;
766 }
766 }
767 }
767 }
768
768
769
769
770 // ADMIN SETTINGS
770 // ADMIN SETTINGS
771
771
772 // Tag Patterns
772 // Tag Patterns
773 .tag_patterns {
773 .tag_patterns {
774 .tag_input {
774 .tag_input {
775 margin-bottom: @padding;
775 margin-bottom: @padding;
776 }
776 }
777 }
777 }
778
778
779 .locked_input {
779 .locked_input {
780 position: relative;
780 position: relative;
781
781
782 input {
782 input {
783 display: inline;
783 display: inline;
784 margin: 3px 5px 0px 0px;
784 margin: 3px 5px 0px 0px;
785 }
785 }
786
786
787 br {
787 br {
788 display: none;
788 display: none;
789 }
789 }
790
790
791 .error-message {
791 .error-message {
792 float: left;
792 float: left;
793 width: 100%;
793 width: 100%;
794 }
794 }
795
795
796 .lock_input_button {
796 .lock_input_button {
797 display: inline;
797 display: inline;
798 }
798 }
799
799
800 .help-block {
800 .help-block {
801 clear: both;
801 clear: both;
802 }
802 }
803 }
803 }
804
804
805 // Notifications
805 // Notifications
806
806
807 .notifications_buttons {
807 .notifications_buttons {
808 margin: 0 0 @space 0;
808 margin: 0 0 @space 0;
809 padding: 0;
809 padding: 0;
810
810
811 .btn {
811 .btn {
812 display: inline-block;
812 display: inline-block;
813 }
813 }
814 }
814 }
815
815
816 .notification-list {
816 .notification-list {
817
817
818 div {
818 div {
819 display: inline-block;
819 display: inline-block;
820 vertical-align: middle;
820 vertical-align: middle;
821 }
821 }
822
822
823 .container {
823 .container {
824 display: block;
824 display: block;
825 margin: 0 0 @padding 0;
825 margin: 0 0 @padding 0;
826 }
826 }
827
827
828 .delete-notifications {
828 .delete-notifications {
829 margin-left: @padding;
829 margin-left: @padding;
830 text-align: right;
830 text-align: right;
831 cursor: pointer;
831 cursor: pointer;
832 }
832 }
833
833
834 .read-notifications {
834 .read-notifications {
835 margin-left: @padding/2;
835 margin-left: @padding/2;
836 text-align: right;
836 text-align: right;
837 width: 35px;
837 width: 35px;
838 cursor: pointer;
838 cursor: pointer;
839 }
839 }
840
840
841 .icon-minus-sign {
841 .icon-minus-sign {
842 color: @alert2;
842 color: @alert2;
843 }
843 }
844
844
845 .icon-ok-sign {
845 .icon-ok-sign {
846 color: @alert1;
846 color: @alert1;
847 }
847 }
848 }
848 }
849
849
850 .user_settings {
850 .user_settings {
851 float: left;
851 float: left;
852 clear: both;
852 clear: both;
853 display: block;
853 display: block;
854 width: 100%;
854 width: 100%;
855
855
856 .gravatar_box {
856 .gravatar_box {
857 margin-bottom: @padding;
857 margin-bottom: @padding;
858
858
859 &:after {
859 &:after {
860 content: " ";
860 content: " ";
861 clear: both;
861 clear: both;
862 width: 100%;
862 width: 100%;
863 }
863 }
864 }
864 }
865
865
866 .fields .field {
866 .fields .field {
867 clear: both;
867 clear: both;
868 }
868 }
869 }
869 }
870
870
871 .advanced_settings {
871 .advanced_settings {
872 margin-bottom: @space;
872 margin-bottom: @space;
873
873
874 .help-block {
874 .help-block {
875 margin-left: 0;
875 margin-left: 0;
876 }
876 }
877
877
878 button + .help-block {
878 button + .help-block {
879 margin-top: @padding;
879 margin-top: @padding;
880 }
880 }
881 }
881 }
882
882
883 // admin settings radio buttons and labels
883 // admin settings radio buttons and labels
884 .label-2 {
884 .label-2 {
885 float: left;
885 float: left;
886 width: @label2-width;
886 width: @label2-width;
887
887
888 label {
888 label {
889 color: @grey1;
889 color: @grey1;
890 }
890 }
891 }
891 }
892 .checkboxes {
892 .checkboxes {
893 float: left;
893 float: left;
894 width: @checkboxes-width;
894 width: @checkboxes-width;
895 margin-bottom: @padding;
895 margin-bottom: @padding;
896
896
897 .checkbox {
897 .checkbox {
898 width: 100%;
898 width: 100%;
899
899
900 label {
900 label {
901 margin: 0;
901 margin: 0;
902 padding: 0;
902 padding: 0;
903 }
903 }
904 }
904 }
905
905
906 .checkbox + .checkbox {
906 .checkbox + .checkbox {
907 display: inline-block;
907 display: inline-block;
908 }
908 }
909
909
910 label {
910 label {
911 margin-right: 1em;
911 margin-right: 1em;
912 }
912 }
913 }
913 }
914
914
915 // CHANGELOG
915 // CHANGELOG
916 .container_header {
916 .container_header {
917 float: left;
917 float: left;
918 display: block;
918 display: block;
919 width: 100%;
919 width: 100%;
920 margin: @padding 0 @padding;
920 margin: @padding 0 @padding;
921
921
922 #filter_changelog {
922 #filter_changelog {
923 float: left;
923 float: left;
924 margin-right: @padding;
924 margin-right: @padding;
925 }
925 }
926
926
927 .breadcrumbs_light {
927 .breadcrumbs_light {
928 display: inline-block;
928 display: inline-block;
929 }
929 }
930 }
930 }
931
931
932 .info_box {
932 .info_box {
933 float: right;
933 float: right;
934 }
934 }
935
935
936
936
937 #graph_nodes {
937 #graph_nodes {
938 padding-top: 43px;
938 padding-top: 43px;
939 }
939 }
940
940
941 #graph_content{
941 #graph_content{
942
942
943 // adjust for table headers so that graph renders properly
943 // adjust for table headers so that graph renders properly
944 // #graph_nodes padding - table cell padding
944 // #graph_nodes padding - table cell padding
945 padding-top: (@space - (@basefontsize * 2.4));
945 padding-top: (@space - (@basefontsize * 2.4));
946
946
947 &.graph_full_width {
947 &.graph_full_width {
948 width: 100%;
948 width: 100%;
949 max-width: 100%;
949 max-width: 100%;
950 }
950 }
951 }
951 }
952
952
953 #graph {
953 #graph {
954 .flag_status {
954 .flag_status {
955 margin: 0;
955 margin: 0;
956 }
956 }
957
957
958 .pagination-left {
958 .pagination-left {
959 float: left;
959 float: left;
960 clear: both;
960 clear: both;
961 }
961 }
962
962
963 .log-container {
963 .log-container {
964 max-width: 345px;
964 max-width: 345px;
965
965
966 .message{
966 .message{
967 max-width: 340px;
967 max-width: 340px;
968 }
968 }
969 }
969 }
970
970
971 .graph-col-wrapper {
971 .graph-col-wrapper {
972 padding-left: 110px;
972 padding-left: 110px;
973
973
974 #graph_nodes {
974 #graph_nodes {
975 width: 100px;
975 width: 100px;
976 margin-left: -110px;
976 margin-left: -110px;
977 float: left;
977 float: left;
978 clear: left;
978 clear: left;
979 }
979 }
980 }
980 }
981
981
982 .load-more-commits {
982 .load-more-commits {
983 text-align: center;
983 text-align: center;
984 }
984 }
985 .load-more-commits:hover {
985 .load-more-commits:hover {
986 background-color: @grey7;
986 background-color: @grey7;
987 }
987 }
988 .load-more-commits {
988 .load-more-commits {
989 a {
989 a {
990 display: block;
990 display: block;
991 }
991 }
992 }
992 }
993 }
993 }
994
994
995 #filter_changelog {
995 #filter_changelog {
996 float: left;
996 float: left;
997 }
997 }
998
998
999
999
1000 //--- THEME ------------------//
1000 //--- THEME ------------------//
1001
1001
1002 #logo {
1002 #logo {
1003 float: left;
1003 float: left;
1004 margin: 9px 0 0 0;
1004 margin: 9px 0 0 0;
1005
1005
1006 .header {
1006 .header {
1007 background-color: transparent;
1007 background-color: transparent;
1008 }
1008 }
1009
1009
1010 a {
1010 a {
1011 display: inline-block;
1011 display: inline-block;
1012 }
1012 }
1013
1013
1014 img {
1014 img {
1015 height:30px;
1015 height:30px;
1016 }
1016 }
1017 }
1017 }
1018
1018
1019 .logo-wrapper {
1019 .logo-wrapper {
1020 float:left;
1020 float:left;
1021 }
1021 }
1022
1022
1023 .branding{
1023 .branding{
1024 float: left;
1024 float: left;
1025 padding: 9px 2px;
1025 padding: 9px 2px;
1026 line-height: 1em;
1026 line-height: 1em;
1027 font-size: @navigation-fontsize;
1027 font-size: @navigation-fontsize;
1028 }
1028 }
1029
1029
1030 img {
1030 img {
1031 border: none;
1031 border: none;
1032 outline: none;
1032 outline: none;
1033 }
1033 }
1034 user-profile-header
1034 user-profile-header
1035 label {
1035 label {
1036
1036
1037 input[type="checkbox"] {
1037 input[type="checkbox"] {
1038 margin-right: 1em;
1038 margin-right: 1em;
1039 }
1039 }
1040 input[type="radio"] {
1040 input[type="radio"] {
1041 margin-right: 1em;
1041 margin-right: 1em;
1042 }
1042 }
1043 }
1043 }
1044
1044
1045 .flag_status {
1045 .flag_status {
1046 margin: 2px 8px 6px 2px;
1046 margin: 2px 8px 6px 2px;
1047 &.under_review {
1047 &.under_review {
1048 .circle(5px, @alert3);
1048 .circle(5px, @alert3);
1049 }
1049 }
1050 &.approved {
1050 &.approved {
1051 .circle(5px, @alert1);
1051 .circle(5px, @alert1);
1052 }
1052 }
1053 &.rejected,
1053 &.rejected,
1054 &.forced_closed{
1054 &.forced_closed{
1055 .circle(5px, @alert2);
1055 .circle(5px, @alert2);
1056 }
1056 }
1057 &.not_reviewed {
1057 &.not_reviewed {
1058 .circle(5px, @grey5);
1058 .circle(5px, @grey5);
1059 }
1059 }
1060 }
1060 }
1061
1061
1062 .flag_status_comment_box {
1062 .flag_status_comment_box {
1063 margin: 5px 6px 0px 2px;
1063 margin: 5px 6px 0px 2px;
1064 }
1064 }
1065 .test_pattern_preview {
1065 .test_pattern_preview {
1066 margin: @space 0;
1066 margin: @space 0;
1067
1067
1068 p {
1068 p {
1069 margin-bottom: 0;
1069 margin-bottom: 0;
1070 border-bottom: @border-thickness solid @border-default-color;
1070 border-bottom: @border-thickness solid @border-default-color;
1071 color: @grey3;
1071 color: @grey3;
1072 }
1072 }
1073
1073
1074 .btn {
1074 .btn {
1075 margin-bottom: @padding;
1075 margin-bottom: @padding;
1076 }
1076 }
1077 }
1077 }
1078 #test_pattern_result {
1078 #test_pattern_result {
1079 display: none;
1079 display: none;
1080 &:extend(pre);
1080 &:extend(pre);
1081 padding: .9em;
1081 padding: .9em;
1082 color: @grey3;
1082 color: @grey3;
1083 background-color: @grey7;
1083 background-color: @grey7;
1084 border-right: @border-thickness solid @border-default-color;
1084 border-right: @border-thickness solid @border-default-color;
1085 border-bottom: @border-thickness solid @border-default-color;
1085 border-bottom: @border-thickness solid @border-default-color;
1086 border-left: @border-thickness solid @border-default-color;
1086 border-left: @border-thickness solid @border-default-color;
1087 }
1087 }
1088
1088
1089 #repo_vcs_settings {
1089 #repo_vcs_settings {
1090 #inherit_overlay_vcs_default {
1090 #inherit_overlay_vcs_default {
1091 display: none;
1091 display: none;
1092 }
1092 }
1093 #inherit_overlay_vcs_custom {
1093 #inherit_overlay_vcs_custom {
1094 display: custom;
1094 display: custom;
1095 }
1095 }
1096 &.inherited {
1096 &.inherited {
1097 #inherit_overlay_vcs_default {
1097 #inherit_overlay_vcs_default {
1098 display: block;
1098 display: block;
1099 }
1099 }
1100 #inherit_overlay_vcs_custom {
1100 #inherit_overlay_vcs_custom {
1101 display: none;
1101 display: none;
1102 }
1102 }
1103 }
1103 }
1104 }
1104 }
1105
1105
1106 .issue-tracker-link {
1106 .issue-tracker-link {
1107 color: @rcblue;
1107 color: @rcblue;
1108 }
1108 }
1109
1109
1110 // Issue Tracker Table Show/Hide
1110 // Issue Tracker Table Show/Hide
1111 #repo_issue_tracker {
1111 #repo_issue_tracker {
1112 #inherit_overlay {
1112 #inherit_overlay {
1113 display: none;
1113 display: none;
1114 }
1114 }
1115 #custom_overlay {
1115 #custom_overlay {
1116 display: custom;
1116 display: custom;
1117 }
1117 }
1118 &.inherited {
1118 &.inherited {
1119 #inherit_overlay {
1119 #inherit_overlay {
1120 display: block;
1120 display: block;
1121 }
1121 }
1122 #custom_overlay {
1122 #custom_overlay {
1123 display: none;
1123 display: none;
1124 }
1124 }
1125 }
1125 }
1126 }
1126 }
1127 table.issuetracker {
1127 table.issuetracker {
1128 &.readonly {
1128 &.readonly {
1129 tr, td {
1129 tr, td {
1130 color: @grey3;
1130 color: @grey3;
1131 }
1131 }
1132 }
1132 }
1133 .edit {
1133 .edit {
1134 display: none;
1134 display: none;
1135 }
1135 }
1136 .editopen {
1136 .editopen {
1137 .edit {
1137 .edit {
1138 display: inline;
1138 display: inline;
1139 }
1139 }
1140 .entry {
1140 .entry {
1141 display: none;
1141 display: none;
1142 }
1142 }
1143 }
1143 }
1144 tr td.td-action {
1144 tr td.td-action {
1145 min-width: 117px;
1145 min-width: 117px;
1146 }
1146 }
1147 td input {
1147 td input {
1148 max-width: none;
1148 max-width: none;
1149 min-width: 30px;
1149 min-width: 30px;
1150 width: 80%;
1150 width: 80%;
1151 }
1151 }
1152 .issuetracker_pref input {
1152 .issuetracker_pref input {
1153 width: 40%;
1153 width: 40%;
1154 }
1154 }
1155 input.edit_issuetracker_update {
1155 input.edit_issuetracker_update {
1156 margin-right: 0;
1156 margin-right: 0;
1157 width: auto;
1157 width: auto;
1158 }
1158 }
1159 }
1159 }
1160
1160
1161 table.integrations {
1161 table.integrations {
1162 .td-icon {
1162 .td-icon {
1163 width: 20px;
1163 width: 20px;
1164 .integration-icon {
1164 .integration-icon {
1165 height: 20px;
1165 height: 20px;
1166 width: 20px;
1166 width: 20px;
1167 }
1167 }
1168 }
1168 }
1169 }
1169 }
1170
1170
1171 .integrations {
1171 .integrations {
1172 a.integration-box {
1172 a.integration-box {
1173 color: @text-color;
1173 color: @text-color;
1174 &:hover {
1174 &:hover {
1175 .panel {
1175 .panel {
1176 background: #fbfbfb;
1176 background: #fbfbfb;
1177 }
1177 }
1178 }
1178 }
1179 .integration-icon {
1179 .integration-icon {
1180 width: 30px;
1180 width: 30px;
1181 height: 30px;
1181 height: 30px;
1182 margin-right: 20px;
1182 margin-right: 20px;
1183 float: left;
1183 float: left;
1184 }
1184 }
1185
1185
1186 .panel-body {
1186 .panel-body {
1187 padding: 10px;
1187 padding: 10px;
1188 }
1188 }
1189 .panel {
1189 .panel {
1190 margin-bottom: 10px;
1190 margin-bottom: 10px;
1191 }
1191 }
1192 h2 {
1192 h2 {
1193 display: inline-block;
1193 display: inline-block;
1194 margin: 0;
1194 margin: 0;
1195 min-width: 140px;
1195 min-width: 140px;
1196 }
1196 }
1197 }
1197 }
1198 }
1198 }
1199
1199
1200 //Permissions Settings
1200 //Permissions Settings
1201 #add_perm {
1201 #add_perm {
1202 margin: 0 0 @padding;
1202 margin: 0 0 @padding;
1203 cursor: pointer;
1203 cursor: pointer;
1204 }
1204 }
1205
1205
1206 .perm_ac {
1206 .perm_ac {
1207 input {
1207 input {
1208 width: 95%;
1208 width: 95%;
1209 }
1209 }
1210 }
1210 }
1211
1211
1212 .autocomplete-suggestions {
1212 .autocomplete-suggestions {
1213 width: auto !important; // overrides autocomplete.js
1213 width: auto !important; // overrides autocomplete.js
1214 margin: 0;
1214 margin: 0;
1215 border: @border-thickness solid @rcblue;
1215 border: @border-thickness solid @rcblue;
1216 border-radius: @border-radius;
1216 border-radius: @border-radius;
1217 color: @rcblue;
1217 color: @rcblue;
1218 background-color: white;
1218 background-color: white;
1219 }
1219 }
1220 .autocomplete-selected {
1220 .autocomplete-selected {
1221 background: #F0F0F0;
1221 background: #F0F0F0;
1222 }
1222 }
1223 .ac-container-wrap {
1223 .ac-container-wrap {
1224 margin: 0;
1224 margin: 0;
1225 padding: 8px;
1225 padding: 8px;
1226 border-bottom: @border-thickness solid @rclightblue;
1226 border-bottom: @border-thickness solid @rclightblue;
1227 list-style-type: none;
1227 list-style-type: none;
1228 cursor: pointer;
1228 cursor: pointer;
1229
1229
1230 &:hover {
1230 &:hover {
1231 background-color: @rclightblue;
1231 background-color: @rclightblue;
1232 }
1232 }
1233
1233
1234 img {
1234 img {
1235 height: @gravatar-size;
1235 height: @gravatar-size;
1236 width: @gravatar-size;
1236 width: @gravatar-size;
1237 margin-right: 1em;
1237 margin-right: 1em;
1238 }
1238 }
1239
1239
1240 strong {
1240 strong {
1241 font-weight: normal;
1241 font-weight: normal;
1242 }
1242 }
1243 }
1243 }
1244
1244
1245 // Settings Dropdown
1245 // Settings Dropdown
1246 .user-menu .container {
1246 .user-menu .container {
1247 padding: 0 4px;
1247 padding: 0 4px;
1248 margin: 0;
1248 margin: 0;
1249 }
1249 }
1250
1250
1251 .user-menu .gravatar {
1251 .user-menu .gravatar {
1252 cursor: pointer;
1252 cursor: pointer;
1253 }
1253 }
1254
1254
1255 .codeblock {
1255 .codeblock {
1256 margin-bottom: @padding;
1256 margin-bottom: @padding;
1257 clear: both;
1257 clear: both;
1258
1258
1259 .stats{
1259 .stats{
1260 overflow: hidden;
1260 overflow: hidden;
1261 }
1261 }
1262
1262
1263 .message{
1263 .message{
1264 textarea{
1264 textarea{
1265 margin: 0;
1265 margin: 0;
1266 }
1266 }
1267 }
1267 }
1268
1268
1269 .code-header {
1269 .code-header {
1270 .stats {
1270 .stats {
1271 line-height: 2em;
1271 line-height: 2em;
1272
1272
1273 .revision_id {
1273 .revision_id {
1274 margin-left: 0;
1274 margin-left: 0;
1275 }
1275 }
1276 .buttons {
1276 .buttons {
1277 padding-right: 0;
1277 padding-right: 0;
1278 }
1278 }
1279 }
1279 }
1280
1280
1281 .item{
1281 .item{
1282 margin-right: 0.5em;
1282 margin-right: 0.5em;
1283 }
1283 }
1284 }
1284 }
1285
1285
1286 #editor_container{
1286 #editor_container{
1287 position: relative;
1287 position: relative;
1288 margin: @padding;
1288 margin: @padding;
1289 }
1289 }
1290 }
1290 }
1291
1291
1292 #file_history_container {
1292 #file_history_container {
1293 display: none;
1293 display: none;
1294 }
1294 }
1295
1295
1296 .file-history-inner {
1296 .file-history-inner {
1297 margin-bottom: 10px;
1297 margin-bottom: 10px;
1298 }
1298 }
1299
1299
1300 // Pull Requests
1300 // Pull Requests
1301 .summary-details {
1301 .summary-details {
1302 width: 72%;
1302 width: 72%;
1303 }
1303 }
1304 .pr-summary {
1304 .pr-summary {
1305 border-bottom: @border-thickness solid @grey5;
1305 border-bottom: @border-thickness solid @grey5;
1306 margin-bottom: @space;
1306 margin-bottom: @space;
1307 }
1307 }
1308 .reviewers-title {
1308 .reviewers-title {
1309 width: 25%;
1309 width: 25%;
1310 min-width: 200px;
1310 min-width: 200px;
1311 }
1311 }
1312 .reviewers {
1312 .reviewers {
1313 width: 25%;
1313 width: 25%;
1314 min-width: 200px;
1314 min-width: 200px;
1315 }
1315 }
1316 .reviewers ul li {
1316 .reviewers ul li {
1317 position: relative;
1317 position: relative;
1318 width: 100%;
1318 width: 100%;
1319 margin-bottom: 8px;
1319 margin-bottom: 8px;
1320 }
1320 }
1321
1321
1322 .reviewer_entry {
1322 .reviewer_entry {
1323 min-height: 55px;
1323 min-height: 55px;
1324 }
1324 }
1325
1325
1326 .reviewers_member {
1326 .reviewers_member {
1327 width: 100%;
1327 width: 100%;
1328 overflow: auto;
1328 overflow: auto;
1329 }
1329 }
1330 .reviewer_reason {
1330 .reviewer_reason {
1331 padding-left: 20px;
1331 padding-left: 20px;
1332 }
1332 }
1333 .reviewer_status {
1333 .reviewer_status {
1334 display: inline-block;
1334 display: inline-block;
1335 vertical-align: top;
1335 vertical-align: top;
1336 width: 7%;
1336 width: 7%;
1337 min-width: 20px;
1337 min-width: 20px;
1338 height: 1.2em;
1338 height: 1.2em;
1339 margin-top: 3px;
1339 margin-top: 3px;
1340 line-height: 1em;
1340 line-height: 1em;
1341 }
1341 }
1342
1342
1343 .reviewer_name {
1343 .reviewer_name {
1344 display: inline-block;
1344 display: inline-block;
1345 max-width: 83%;
1345 max-width: 83%;
1346 padding-right: 20px;
1346 padding-right: 20px;
1347 vertical-align: middle;
1347 vertical-align: middle;
1348 line-height: 1;
1348 line-height: 1;
1349
1349
1350 .rc-user {
1350 .rc-user {
1351 min-width: 0;
1351 min-width: 0;
1352 margin: -2px 1em 0 0;
1352 margin: -2px 1em 0 0;
1353 }
1353 }
1354
1354
1355 .reviewer {
1355 .reviewer {
1356 float: left;
1356 float: left;
1357 }
1357 }
1358 }
1358 }
1359
1359
1360 .reviewer_member_mandatory,
1360 .reviewer_member_mandatory,
1361 .reviewer_member_mandatory_remove,
1361 .reviewer_member_mandatory_remove,
1362 .reviewer_member_remove {
1362 .reviewer_member_remove {
1363 position: absolute;
1363 position: absolute;
1364 right: 0;
1364 right: 0;
1365 top: 0;
1365 top: 0;
1366 width: 16px;
1366 width: 16px;
1367 margin-bottom: 10px;
1367 margin-bottom: 10px;
1368 padding: 0;
1368 padding: 0;
1369 color: black;
1369 color: black;
1370 }
1370 }
1371
1371
1372 .reviewer_member_mandatory_remove {
1372 .reviewer_member_mandatory_remove {
1373 color: @grey4;
1373 color: @grey4;
1374 }
1374 }
1375
1375
1376 .reviewer_member_mandatory {
1376 .reviewer_member_mandatory {
1377 padding-top:20px;
1377 padding-top:20px;
1378 }
1378 }
1379
1379
1380 .reviewer_member_status {
1380 .reviewer_member_status {
1381 margin-top: 5px;
1381 margin-top: 5px;
1382 }
1382 }
1383 .pr-summary #summary{
1383 .pr-summary #summary{
1384 width: 100%;
1384 width: 100%;
1385 }
1385 }
1386 .pr-summary .action_button:hover {
1386 .pr-summary .action_button:hover {
1387 border: 0;
1387 border: 0;
1388 cursor: pointer;
1388 cursor: pointer;
1389 }
1389 }
1390 .pr-details-title {
1390 .pr-details-title {
1391 padding-bottom: 8px;
1391 padding-bottom: 8px;
1392 border-bottom: @border-thickness solid @grey5;
1392 border-bottom: @border-thickness solid @grey5;
1393
1393
1394 .action_button.disabled {
1394 .action_button.disabled {
1395 color: @grey4;
1395 color: @grey4;
1396 cursor: inherit;
1396 cursor: inherit;
1397 }
1397 }
1398 .action_button {
1398 .action_button {
1399 color: @rcblue;
1399 color: @rcblue;
1400 }
1400 }
1401 }
1401 }
1402 .pr-details-content {
1402 .pr-details-content {
1403 margin-top: @textmargin;
1403 margin-top: @textmargin;
1404 margin-bottom: @textmargin;
1404 margin-bottom: @textmargin;
1405 }
1405 }
1406 .pr-description {
1406 .pr-description {
1407 white-space:pre-wrap;
1407 white-space:pre-wrap;
1408 }
1408 }
1409
1409
1410 .pr-reviewer-rules {
1410 .pr-reviewer-rules {
1411 padding: 10px 0px 20px 0px;
1411 padding: 10px 0px 20px 0px;
1412 }
1412 }
1413
1413
1414 .group_members {
1414 .group_members {
1415 margin-top: 0;
1415 margin-top: 0;
1416 padding: 0;
1416 padding: 0;
1417 list-style: outside none none;
1417 list-style: outside none none;
1418
1418
1419 img {
1419 img {
1420 height: @gravatar-size;
1420 height: @gravatar-size;
1421 width: @gravatar-size;
1421 width: @gravatar-size;
1422 margin-right: .5em;
1422 margin-right: .5em;
1423 margin-left: 3px;
1423 margin-left: 3px;
1424 }
1424 }
1425
1425
1426 .to-delete {
1426 .to-delete {
1427 .user {
1427 .user {
1428 text-decoration: line-through;
1428 text-decoration: line-through;
1429 }
1429 }
1430 }
1430 }
1431 }
1431 }
1432
1432
1433 .compare_view_commits_title {
1433 .compare_view_commits_title {
1434 .disabled {
1434 .disabled {
1435 cursor: inherit;
1435 cursor: inherit;
1436 &:hover{
1436 &:hover{
1437 background-color: inherit;
1437 background-color: inherit;
1438 color: inherit;
1438 color: inherit;
1439 }
1439 }
1440 }
1440 }
1441 }
1441 }
1442
1442
1443 .subtitle-compare {
1443 .subtitle-compare {
1444 margin: -15px 0px 0px 0px;
1444 margin: -15px 0px 0px 0px;
1445 }
1445 }
1446
1446
1447 .comments-summary-td {
1447 .comments-summary-td {
1448 border-top: 1px dashed @grey5;
1448 border-top: 1px dashed @grey5;
1449 }
1449 }
1450
1450
1451 // new entry in group_members
1451 // new entry in group_members
1452 .td-author-new-entry {
1452 .td-author-new-entry {
1453 background-color: rgba(red(@alert1), green(@alert1), blue(@alert1), 0.3);
1453 background-color: rgba(red(@alert1), green(@alert1), blue(@alert1), 0.3);
1454 }
1454 }
1455
1455
1456 .usergroup_member_remove {
1456 .usergroup_member_remove {
1457 width: 16px;
1457 width: 16px;
1458 margin-bottom: 10px;
1458 margin-bottom: 10px;
1459 padding: 0;
1459 padding: 0;
1460 color: black !important;
1460 color: black !important;
1461 cursor: pointer;
1461 cursor: pointer;
1462 }
1462 }
1463
1463
1464 .reviewer_ac .ac-input {
1464 .reviewer_ac .ac-input {
1465 width: 92%;
1465 width: 92%;
1466 margin-bottom: 1em;
1466 margin-bottom: 1em;
1467 }
1467 }
1468
1468
1469 .compare_view_commits tr{
1469 .compare_view_commits tr{
1470 height: 20px;
1470 height: 20px;
1471 }
1471 }
1472 .compare_view_commits td {
1472 .compare_view_commits td {
1473 vertical-align: top;
1473 vertical-align: top;
1474 padding-top: 10px;
1474 padding-top: 10px;
1475 }
1475 }
1476 .compare_view_commits .author {
1476 .compare_view_commits .author {
1477 margin-left: 5px;
1477 margin-left: 5px;
1478 }
1478 }
1479
1479
1480 .compare_view_commits {
1480 .compare_view_commits {
1481 .color-a {
1481 .color-a {
1482 color: @alert1;
1482 color: @alert1;
1483 }
1483 }
1484
1484
1485 .color-c {
1485 .color-c {
1486 color: @color3;
1486 color: @color3;
1487 }
1487 }
1488
1488
1489 .color-r {
1489 .color-r {
1490 color: @color5;
1490 color: @color5;
1491 }
1491 }
1492
1492
1493 .color-a-bg {
1493 .color-a-bg {
1494 background-color: @alert1;
1494 background-color: @alert1;
1495 }
1495 }
1496
1496
1497 .color-c-bg {
1497 .color-c-bg {
1498 background-color: @alert3;
1498 background-color: @alert3;
1499 }
1499 }
1500
1500
1501 .color-r-bg {
1501 .color-r-bg {
1502 background-color: @alert2;
1502 background-color: @alert2;
1503 }
1503 }
1504
1504
1505 .color-a-border {
1505 .color-a-border {
1506 border: 1px solid @alert1;
1506 border: 1px solid @alert1;
1507 }
1507 }
1508
1508
1509 .color-c-border {
1509 .color-c-border {
1510 border: 1px solid @alert3;
1510 border: 1px solid @alert3;
1511 }
1511 }
1512
1512
1513 .color-r-border {
1513 .color-r-border {
1514 border: 1px solid @alert2;
1514 border: 1px solid @alert2;
1515 }
1515 }
1516
1516
1517 .commit-change-indicator {
1517 .commit-change-indicator {
1518 width: 15px;
1518 width: 15px;
1519 height: 15px;
1519 height: 15px;
1520 position: relative;
1520 position: relative;
1521 left: 15px;
1521 left: 15px;
1522 }
1522 }
1523
1523
1524 .commit-change-content {
1524 .commit-change-content {
1525 text-align: center;
1525 text-align: center;
1526 vertical-align: middle;
1526 vertical-align: middle;
1527 line-height: 15px;
1527 line-height: 15px;
1528 }
1528 }
1529 }
1529 }
1530
1530
1531 .compare_view_files {
1531 .compare_view_files {
1532 width: 100%;
1532 width: 100%;
1533
1533
1534 td {
1534 td {
1535 vertical-align: middle;
1535 vertical-align: middle;
1536 }
1536 }
1537 }
1537 }
1538
1538
1539 .compare_view_filepath {
1539 .compare_view_filepath {
1540 color: @grey1;
1540 color: @grey1;
1541 }
1541 }
1542
1542
1543 .show_more {
1543 .show_more {
1544 display: inline-block;
1544 display: inline-block;
1545 position: relative;
1545 position: relative;
1546 vertical-align: middle;
1546 vertical-align: middle;
1547 width: 4px;
1547 width: 4px;
1548 height: @basefontsize;
1548 height: @basefontsize;
1549
1549
1550 &:after {
1550 &:after {
1551 content: "\00A0\25BE";
1551 content: "\00A0\25BE";
1552 display: inline-block;
1552 display: inline-block;
1553 width:10px;
1553 width:10px;
1554 line-height: 5px;
1554 line-height: 5px;
1555 font-size: 12px;
1555 font-size: 12px;
1556 cursor: pointer;
1556 cursor: pointer;
1557 }
1557 }
1558 }
1558 }
1559
1559
1560 .journal_more .show_more {
1560 .journal_more .show_more {
1561 display: inline;
1561 display: inline;
1562
1562
1563 &:after {
1563 &:after {
1564 content: none;
1564 content: none;
1565 }
1565 }
1566 }
1566 }
1567
1567
1568 .open .show_more:after,
1568 .open .show_more:after,
1569 .select2-dropdown-open .show_more:after {
1569 .select2-dropdown-open .show_more:after {
1570 .rotate(180deg);
1570 .rotate(180deg);
1571 margin-left: 4px;
1571 margin-left: 4px;
1572 }
1572 }
1573
1573
1574
1574
1575 .compare_view_commits .collapse_commit:after {
1575 .compare_view_commits .collapse_commit:after {
1576 cursor: pointer;
1576 cursor: pointer;
1577 content: "\00A0\25B4";
1577 content: "\00A0\25B4";
1578 margin-left: -3px;
1578 margin-left: -3px;
1579 font-size: 17px;
1579 font-size: 17px;
1580 color: @grey4;
1580 color: @grey4;
1581 }
1581 }
1582
1582
1583 .diff_links {
1583 .diff_links {
1584 margin-left: 8px;
1584 margin-left: 8px;
1585 }
1585 }
1586
1586
1587 div.ancestor {
1587 div.ancestor {
1588 margin: -30px 0px;
1588 margin: -30px 0px;
1589 }
1589 }
1590
1590
1591 .cs_icon_td input[type="checkbox"] {
1591 .cs_icon_td input[type="checkbox"] {
1592 display: none;
1592 display: none;
1593 }
1593 }
1594
1594
1595 .cs_icon_td .expand_file_icon:after {
1595 .cs_icon_td .expand_file_icon:after {
1596 cursor: pointer;
1596 cursor: pointer;
1597 content: "\00A0\25B6";
1597 content: "\00A0\25B6";
1598 font-size: 12px;
1598 font-size: 12px;
1599 color: @grey4;
1599 color: @grey4;
1600 }
1600 }
1601
1601
1602 .cs_icon_td .collapse_file_icon:after {
1602 .cs_icon_td .collapse_file_icon:after {
1603 cursor: pointer;
1603 cursor: pointer;
1604 content: "\00A0\25BC";
1604 content: "\00A0\25BC";
1605 font-size: 12px;
1605 font-size: 12px;
1606 color: @grey4;
1606 color: @grey4;
1607 }
1607 }
1608
1608
1609 /*new binary
1609 /*new binary
1610 NEW_FILENODE = 1
1610 NEW_FILENODE = 1
1611 DEL_FILENODE = 2
1611 DEL_FILENODE = 2
1612 MOD_FILENODE = 3
1612 MOD_FILENODE = 3
1613 RENAMED_FILENODE = 4
1613 RENAMED_FILENODE = 4
1614 COPIED_FILENODE = 5
1614 COPIED_FILENODE = 5
1615 CHMOD_FILENODE = 6
1615 CHMOD_FILENODE = 6
1616 BIN_FILENODE = 7
1616 BIN_FILENODE = 7
1617 */
1617 */
1618 .cs_files_expand {
1618 .cs_files_expand {
1619 font-size: @basefontsize + 5px;
1619 font-size: @basefontsize + 5px;
1620 line-height: 1.8em;
1620 line-height: 1.8em;
1621 float: right;
1621 float: right;
1622 }
1622 }
1623
1623
1624 .cs_files_expand span{
1624 .cs_files_expand span{
1625 color: @rcblue;
1625 color: @rcblue;
1626 cursor: pointer;
1626 cursor: pointer;
1627 }
1627 }
1628 .cs_files {
1628 .cs_files {
1629 clear: both;
1629 clear: both;
1630 padding-bottom: @padding;
1630 padding-bottom: @padding;
1631
1631
1632 .cur_cs {
1632 .cur_cs {
1633 margin: 10px 2px;
1633 margin: 10px 2px;
1634 font-weight: bold;
1634 font-weight: bold;
1635 }
1635 }
1636
1636
1637 .node {
1637 .node {
1638 float: left;
1638 float: left;
1639 }
1639 }
1640
1640
1641 .changes {
1641 .changes {
1642 float: right;
1642 float: right;
1643 color: white;
1643 color: white;
1644 font-size: @basefontsize - 4px;
1644 font-size: @basefontsize - 4px;
1645 margin-top: 4px;
1645 margin-top: 4px;
1646 opacity: 0.6;
1646 opacity: 0.6;
1647 filter: Alpha(opacity=60); /* IE8 and earlier */
1647 filter: Alpha(opacity=60); /* IE8 and earlier */
1648
1648
1649 .added {
1649 .added {
1650 background-color: @alert1;
1650 background-color: @alert1;
1651 float: left;
1651 float: left;
1652 text-align: center;
1652 text-align: center;
1653 }
1653 }
1654
1654
1655 .deleted {
1655 .deleted {
1656 background-color: @alert2;
1656 background-color: @alert2;
1657 float: left;
1657 float: left;
1658 text-align: center;
1658 text-align: center;
1659 }
1659 }
1660
1660
1661 .bin {
1661 .bin {
1662 background-color: @alert1;
1662 background-color: @alert1;
1663 text-align: center;
1663 text-align: center;
1664 }
1664 }
1665
1665
1666 /*new binary*/
1666 /*new binary*/
1667 .bin.bin1 {
1667 .bin.bin1 {
1668 background-color: @alert1;
1668 background-color: @alert1;
1669 text-align: center;
1669 text-align: center;
1670 }
1670 }
1671
1671
1672 /*deleted binary*/
1672 /*deleted binary*/
1673 .bin.bin2 {
1673 .bin.bin2 {
1674 background-color: @alert2;
1674 background-color: @alert2;
1675 text-align: center;
1675 text-align: center;
1676 }
1676 }
1677
1677
1678 /*mod binary*/
1678 /*mod binary*/
1679 .bin.bin3 {
1679 .bin.bin3 {
1680 background-color: @grey2;
1680 background-color: @grey2;
1681 text-align: center;
1681 text-align: center;
1682 }
1682 }
1683
1683
1684 /*rename file*/
1684 /*rename file*/
1685 .bin.bin4 {
1685 .bin.bin4 {
1686 background-color: @alert4;
1686 background-color: @alert4;
1687 text-align: center;
1687 text-align: center;
1688 }
1688 }
1689
1689
1690 /*copied file*/
1690 /*copied file*/
1691 .bin.bin5 {
1691 .bin.bin5 {
1692 background-color: @alert4;
1692 background-color: @alert4;
1693 text-align: center;
1693 text-align: center;
1694 }
1694 }
1695
1695
1696 /*chmod file*/
1696 /*chmod file*/
1697 .bin.bin6 {
1697 .bin.bin6 {
1698 background-color: @grey2;
1698 background-color: @grey2;
1699 text-align: center;
1699 text-align: center;
1700 }
1700 }
1701 }
1701 }
1702 }
1702 }
1703
1703
1704 .cs_files .cs_added, .cs_files .cs_A,
1704 .cs_files .cs_added, .cs_files .cs_A,
1705 .cs_files .cs_added, .cs_files .cs_M,
1705 .cs_files .cs_added, .cs_files .cs_M,
1706 .cs_files .cs_added, .cs_files .cs_D {
1706 .cs_files .cs_added, .cs_files .cs_D {
1707 height: 16px;
1707 height: 16px;
1708 padding-right: 10px;
1708 padding-right: 10px;
1709 margin-top: 7px;
1709 margin-top: 7px;
1710 text-align: left;
1710 text-align: left;
1711 }
1711 }
1712
1712
1713 .cs_icon_td {
1713 .cs_icon_td {
1714 min-width: 16px;
1714 min-width: 16px;
1715 width: 16px;
1715 width: 16px;
1716 }
1716 }
1717
1717
1718 .pull-request-merge {
1718 .pull-request-merge {
1719 border: 1px solid @grey5;
1719 border: 1px solid @grey5;
1720 padding: 10px 0px 20px;
1720 padding: 10px 0px 20px;
1721 margin-top: 10px;
1721 margin-top: 10px;
1722 margin-bottom: 20px;
1722 margin-bottom: 20px;
1723 }
1723 }
1724
1724
1725 .pull-request-merge ul {
1725 .pull-request-merge ul {
1726 padding: 0px 0px;
1726 padding: 0px 0px;
1727 }
1727 }
1728
1728
1729 .pull-request-merge li:before{
1729 .pull-request-merge li:before{
1730 content:none;
1730 content:none;
1731 }
1731 }
1732
1732
1733 .pull-request-merge .pull-request-wrap {
1733 .pull-request-merge .pull-request-wrap {
1734 height: auto;
1734 height: auto;
1735 padding: 0px 0px;
1735 padding: 0px 0px;
1736 text-align: right;
1736 text-align: right;
1737 }
1737 }
1738
1738
1739 .pull-request-merge span {
1739 .pull-request-merge span {
1740 margin-right: 5px;
1740 margin-right: 5px;
1741 }
1741 }
1742
1742
1743 .pull-request-merge-actions {
1743 .pull-request-merge-actions {
1744 height: 30px;
1744 min-height: 30px;
1745 padding: 0px 0px;
1745 padding: 0px 0px;
1746 }
1746 }
1747
1747
1748 .pull-request-merge-info {
1749 padding: 0px 5px 5px 0px;
1750 }
1751
1748 .merge-status {
1752 .merge-status {
1749 margin-right: 5px;
1753 margin-right: 5px;
1750 }
1754 }
1751
1755
1752 .merge-message {
1756 .merge-message {
1753 font-size: 1.2em
1757 font-size: 1.2em
1754 }
1758 }
1755
1759
1756 .merge-message.success i,
1760 .merge-message.success i,
1757 .merge-icon.success i {
1761 .merge-icon.success i {
1758 color:@alert1;
1762 color:@alert1;
1759 }
1763 }
1760
1764
1761 .merge-message.warning i,
1765 .merge-message.warning i,
1762 .merge-icon.warning i {
1766 .merge-icon.warning i {
1763 color: @alert3;
1767 color: @alert3;
1764 }
1768 }
1765
1769
1766 .merge-message.error i,
1770 .merge-message.error i,
1767 .merge-icon.error i {
1771 .merge-icon.error i {
1768 color:@alert2;
1772 color:@alert2;
1769 }
1773 }
1770
1774
1771 .pr-versions {
1775 .pr-versions {
1772 font-size: 1.1em;
1776 font-size: 1.1em;
1773
1777
1774 table {
1778 table {
1775 padding: 0px 5px;
1779 padding: 0px 5px;
1776 }
1780 }
1777
1781
1778 td {
1782 td {
1779 line-height: 15px;
1783 line-height: 15px;
1780 }
1784 }
1781
1785
1782 .flag_status {
1786 .flag_status {
1783 margin: 0;
1787 margin: 0;
1784 }
1788 }
1785
1789
1786 .compare-radio-button {
1790 .compare-radio-button {
1787 position: relative;
1791 position: relative;
1788 top: -3px;
1792 top: -3px;
1789 }
1793 }
1790 }
1794 }
1791
1795
1792
1796
1793 #close_pull_request {
1797 #close_pull_request {
1794 margin-right: 0px;
1798 margin-right: 0px;
1795 }
1799 }
1796
1800
1797 .empty_data {
1801 .empty_data {
1798 color: @grey4;
1802 color: @grey4;
1799 }
1803 }
1800
1804
1801 #changeset_compare_view_content {
1805 #changeset_compare_view_content {
1802 margin-bottom: @space;
1806 margin-bottom: @space;
1803 clear: both;
1807 clear: both;
1804 width: 100%;
1808 width: 100%;
1805 box-sizing: border-box;
1809 box-sizing: border-box;
1806 .border-radius(@border-radius);
1810 .border-radius(@border-radius);
1807
1811
1808 .help-block {
1812 .help-block {
1809 margin: @padding 0;
1813 margin: @padding 0;
1810 color: @text-color;
1814 color: @text-color;
1811 &.pre-formatting {
1815 &.pre-formatting {
1812 white-space: pre;
1816 white-space: pre;
1813 }
1817 }
1814 }
1818 }
1815
1819
1816 .empty_data {
1820 .empty_data {
1817 margin: @padding 0;
1821 margin: @padding 0;
1818 }
1822 }
1819
1823
1820 .alert {
1824 .alert {
1821 margin-bottom: @space;
1825 margin-bottom: @space;
1822 }
1826 }
1823 }
1827 }
1824
1828
1825 .table_disp {
1829 .table_disp {
1826 .status {
1830 .status {
1827 width: auto;
1831 width: auto;
1828
1832
1829 .flag_status {
1833 .flag_status {
1830 float: left;
1834 float: left;
1831 }
1835 }
1832 }
1836 }
1833 }
1837 }
1834
1838
1835
1839
1836 .creation_in_progress {
1840 .creation_in_progress {
1837 color: @grey4
1841 color: @grey4
1838 }
1842 }
1839
1843
1840 .status_box_menu {
1844 .status_box_menu {
1841 margin: 0;
1845 margin: 0;
1842 }
1846 }
1843
1847
1844 .notification-table{
1848 .notification-table{
1845 margin-bottom: @space;
1849 margin-bottom: @space;
1846 display: table;
1850 display: table;
1847 width: 100%;
1851 width: 100%;
1848
1852
1849 .container{
1853 .container{
1850 display: table-row;
1854 display: table-row;
1851
1855
1852 .notification-header{
1856 .notification-header{
1853 border-bottom: @border-thickness solid @border-default-color;
1857 border-bottom: @border-thickness solid @border-default-color;
1854 }
1858 }
1855
1859
1856 .notification-subject{
1860 .notification-subject{
1857 display: table-cell;
1861 display: table-cell;
1858 }
1862 }
1859 }
1863 }
1860 }
1864 }
1861
1865
1862 // Notifications
1866 // Notifications
1863 .notification-header{
1867 .notification-header{
1864 display: table;
1868 display: table;
1865 width: 100%;
1869 width: 100%;
1866 padding: floor(@basefontsize/2) 0;
1870 padding: floor(@basefontsize/2) 0;
1867 line-height: 1em;
1871 line-height: 1em;
1868
1872
1869 .desc, .delete-notifications, .read-notifications{
1873 .desc, .delete-notifications, .read-notifications{
1870 display: table-cell;
1874 display: table-cell;
1871 text-align: left;
1875 text-align: left;
1872 }
1876 }
1873
1877
1874 .desc{
1878 .desc{
1875 width: 1163px;
1879 width: 1163px;
1876 }
1880 }
1877
1881
1878 .delete-notifications, .read-notifications{
1882 .delete-notifications, .read-notifications{
1879 width: 35px;
1883 width: 35px;
1880 min-width: 35px; //fixes when only one button is displayed
1884 min-width: 35px; //fixes when only one button is displayed
1881 }
1885 }
1882 }
1886 }
1883
1887
1884 .notification-body {
1888 .notification-body {
1885 .markdown-block,
1889 .markdown-block,
1886 .rst-block {
1890 .rst-block {
1887 padding: @padding 0;
1891 padding: @padding 0;
1888 }
1892 }
1889
1893
1890 .notification-subject {
1894 .notification-subject {
1891 padding: @textmargin 0;
1895 padding: @textmargin 0;
1892 border-bottom: @border-thickness solid @border-default-color;
1896 border-bottom: @border-thickness solid @border-default-color;
1893 }
1897 }
1894 }
1898 }
1895
1899
1896
1900
1897 .notifications_buttons{
1901 .notifications_buttons{
1898 float: right;
1902 float: right;
1899 }
1903 }
1900
1904
1901 #notification-status{
1905 #notification-status{
1902 display: inline;
1906 display: inline;
1903 }
1907 }
1904
1908
1905 // Repositories
1909 // Repositories
1906
1910
1907 #summary.fields{
1911 #summary.fields{
1908 display: table;
1912 display: table;
1909
1913
1910 .field{
1914 .field{
1911 display: table-row;
1915 display: table-row;
1912
1916
1913 .label-summary{
1917 .label-summary{
1914 display: table-cell;
1918 display: table-cell;
1915 min-width: @label-summary-minwidth;
1919 min-width: @label-summary-minwidth;
1916 padding-top: @padding/2;
1920 padding-top: @padding/2;
1917 padding-bottom: @padding/2;
1921 padding-bottom: @padding/2;
1918 padding-right: @padding/2;
1922 padding-right: @padding/2;
1919 }
1923 }
1920
1924
1921 .input{
1925 .input{
1922 display: table-cell;
1926 display: table-cell;
1923 padding: @padding/2;
1927 padding: @padding/2;
1924
1928
1925 input{
1929 input{
1926 min-width: 29em;
1930 min-width: 29em;
1927 padding: @padding/4;
1931 padding: @padding/4;
1928 }
1932 }
1929 }
1933 }
1930 .statistics, .downloads{
1934 .statistics, .downloads{
1931 .disabled{
1935 .disabled{
1932 color: @grey4;
1936 color: @grey4;
1933 }
1937 }
1934 }
1938 }
1935 }
1939 }
1936 }
1940 }
1937
1941
1938 #summary{
1942 #summary{
1939 width: 70%;
1943 width: 70%;
1940 }
1944 }
1941
1945
1942
1946
1943 // Journal
1947 // Journal
1944 .journal.title {
1948 .journal.title {
1945 h5 {
1949 h5 {
1946 float: left;
1950 float: left;
1947 margin: 0;
1951 margin: 0;
1948 width: 70%;
1952 width: 70%;
1949 }
1953 }
1950
1954
1951 ul {
1955 ul {
1952 float: right;
1956 float: right;
1953 display: inline-block;
1957 display: inline-block;
1954 margin: 0;
1958 margin: 0;
1955 width: 30%;
1959 width: 30%;
1956 text-align: right;
1960 text-align: right;
1957
1961
1958 li {
1962 li {
1959 display: inline;
1963 display: inline;
1960 font-size: @journal-fontsize;
1964 font-size: @journal-fontsize;
1961 line-height: 1em;
1965 line-height: 1em;
1962
1966
1963 &:before { content: none; }
1967 &:before { content: none; }
1964 }
1968 }
1965 }
1969 }
1966 }
1970 }
1967
1971
1968 .filterexample {
1972 .filterexample {
1969 position: absolute;
1973 position: absolute;
1970 top: 95px;
1974 top: 95px;
1971 left: @contentpadding;
1975 left: @contentpadding;
1972 color: @rcblue;
1976 color: @rcblue;
1973 font-size: 11px;
1977 font-size: 11px;
1974 font-family: @text-regular;
1978 font-family: @text-regular;
1975 cursor: help;
1979 cursor: help;
1976
1980
1977 &:hover {
1981 &:hover {
1978 color: @rcdarkblue;
1982 color: @rcdarkblue;
1979 }
1983 }
1980
1984
1981 @media (max-width:768px) {
1985 @media (max-width:768px) {
1982 position: relative;
1986 position: relative;
1983 top: auto;
1987 top: auto;
1984 left: auto;
1988 left: auto;
1985 display: block;
1989 display: block;
1986 }
1990 }
1987 }
1991 }
1988
1992
1989
1993
1990 #journal{
1994 #journal{
1991 margin-bottom: @space;
1995 margin-bottom: @space;
1992
1996
1993 .journal_day{
1997 .journal_day{
1994 margin-bottom: @textmargin/2;
1998 margin-bottom: @textmargin/2;
1995 padding-bottom: @textmargin/2;
1999 padding-bottom: @textmargin/2;
1996 font-size: @journal-fontsize;
2000 font-size: @journal-fontsize;
1997 border-bottom: @border-thickness solid @border-default-color;
2001 border-bottom: @border-thickness solid @border-default-color;
1998 }
2002 }
1999
2003
2000 .journal_container{
2004 .journal_container{
2001 margin-bottom: @space;
2005 margin-bottom: @space;
2002
2006
2003 .journal_user{
2007 .journal_user{
2004 display: inline-block;
2008 display: inline-block;
2005 }
2009 }
2006 .journal_action_container{
2010 .journal_action_container{
2007 display: block;
2011 display: block;
2008 margin-top: @textmargin;
2012 margin-top: @textmargin;
2009
2013
2010 div{
2014 div{
2011 display: inline;
2015 display: inline;
2012 }
2016 }
2013
2017
2014 div.journal_action_params{
2018 div.journal_action_params{
2015 display: block;
2019 display: block;
2016 }
2020 }
2017
2021
2018 div.journal_repo:after{
2022 div.journal_repo:after{
2019 content: "\A";
2023 content: "\A";
2020 white-space: pre;
2024 white-space: pre;
2021 }
2025 }
2022
2026
2023 div.date{
2027 div.date{
2024 display: block;
2028 display: block;
2025 margin-bottom: @textmargin;
2029 margin-bottom: @textmargin;
2026 }
2030 }
2027 }
2031 }
2028 }
2032 }
2029 }
2033 }
2030
2034
2031 // Files
2035 // Files
2032 .edit-file-title {
2036 .edit-file-title {
2033 border-bottom: @border-thickness solid @border-default-color;
2037 border-bottom: @border-thickness solid @border-default-color;
2034
2038
2035 .breadcrumbs {
2039 .breadcrumbs {
2036 margin-bottom: 0;
2040 margin-bottom: 0;
2037 }
2041 }
2038 }
2042 }
2039
2043
2040 .edit-file-fieldset {
2044 .edit-file-fieldset {
2041 margin-top: @sidebarpadding;
2045 margin-top: @sidebarpadding;
2042
2046
2043 .fieldset {
2047 .fieldset {
2044 .left-label {
2048 .left-label {
2045 width: 13%;
2049 width: 13%;
2046 }
2050 }
2047 .right-content {
2051 .right-content {
2048 width: 87%;
2052 width: 87%;
2049 max-width: 100%;
2053 max-width: 100%;
2050 }
2054 }
2051 .filename-label {
2055 .filename-label {
2052 margin-top: 13px;
2056 margin-top: 13px;
2053 }
2057 }
2054 .commit-message-label {
2058 .commit-message-label {
2055 margin-top: 4px;
2059 margin-top: 4px;
2056 }
2060 }
2057 .file-upload-input {
2061 .file-upload-input {
2058 input {
2062 input {
2059 display: none;
2063 display: none;
2060 }
2064 }
2061 margin-top: 10px;
2065 margin-top: 10px;
2062 }
2066 }
2063 .file-upload-label {
2067 .file-upload-label {
2064 margin-top: 10px;
2068 margin-top: 10px;
2065 }
2069 }
2066 p {
2070 p {
2067 margin-top: 5px;
2071 margin-top: 5px;
2068 }
2072 }
2069
2073
2070 }
2074 }
2071 .custom-path-link {
2075 .custom-path-link {
2072 margin-left: 5px;
2076 margin-left: 5px;
2073 }
2077 }
2074 #commit {
2078 #commit {
2075 resize: vertical;
2079 resize: vertical;
2076 }
2080 }
2077 }
2081 }
2078
2082
2079 .delete-file-preview {
2083 .delete-file-preview {
2080 max-height: 250px;
2084 max-height: 250px;
2081 }
2085 }
2082
2086
2083 .new-file,
2087 .new-file,
2084 #filter_activate,
2088 #filter_activate,
2085 #filter_deactivate {
2089 #filter_deactivate {
2086 float: left;
2090 float: left;
2087 margin: 0 0 0 15px;
2091 margin: 0 0 0 15px;
2088 }
2092 }
2089
2093
2090 h3.files_location{
2094 h3.files_location{
2091 line-height: 2.4em;
2095 line-height: 2.4em;
2092 }
2096 }
2093
2097
2094 .browser-nav {
2098 .browser-nav {
2095 display: table;
2099 display: table;
2096 margin-bottom: @space;
2100 margin-bottom: @space;
2097
2101
2098
2102
2099 .info_box {
2103 .info_box {
2100 display: inline-table;
2104 display: inline-table;
2101 height: 2.5em;
2105 height: 2.5em;
2102
2106
2103 .browser-cur-rev, .info_box_elem {
2107 .browser-cur-rev, .info_box_elem {
2104 display: table-cell;
2108 display: table-cell;
2105 vertical-align: middle;
2109 vertical-align: middle;
2106 }
2110 }
2107
2111
2108 .info_box_elem {
2112 .info_box_elem {
2109 border-top: @border-thickness solid @rcblue;
2113 border-top: @border-thickness solid @rcblue;
2110 border-bottom: @border-thickness solid @rcblue;
2114 border-bottom: @border-thickness solid @rcblue;
2111
2115
2112 #at_rev, a {
2116 #at_rev, a {
2113 padding: 0.6em 0.9em;
2117 padding: 0.6em 0.9em;
2114 margin: 0;
2118 margin: 0;
2115 .box-shadow(none);
2119 .box-shadow(none);
2116 border: 0;
2120 border: 0;
2117 height: 12px;
2121 height: 12px;
2118 }
2122 }
2119
2123
2120 input#at_rev {
2124 input#at_rev {
2121 max-width: 50px;
2125 max-width: 50px;
2122 text-align: right;
2126 text-align: right;
2123 }
2127 }
2124
2128
2125 &.previous {
2129 &.previous {
2126 border: @border-thickness solid @rcblue;
2130 border: @border-thickness solid @rcblue;
2127 .disabled {
2131 .disabled {
2128 color: @grey4;
2132 color: @grey4;
2129 cursor: not-allowed;
2133 cursor: not-allowed;
2130 }
2134 }
2131 }
2135 }
2132
2136
2133 &.next {
2137 &.next {
2134 border: @border-thickness solid @rcblue;
2138 border: @border-thickness solid @rcblue;
2135 .disabled {
2139 .disabled {
2136 color: @grey4;
2140 color: @grey4;
2137 cursor: not-allowed;
2141 cursor: not-allowed;
2138 }
2142 }
2139 }
2143 }
2140 }
2144 }
2141
2145
2142 .browser-cur-rev {
2146 .browser-cur-rev {
2143
2147
2144 span{
2148 span{
2145 margin: 0;
2149 margin: 0;
2146 color: @rcblue;
2150 color: @rcblue;
2147 height: 12px;
2151 height: 12px;
2148 display: inline-block;
2152 display: inline-block;
2149 padding: 0.7em 1em ;
2153 padding: 0.7em 1em ;
2150 border: @border-thickness solid @rcblue;
2154 border: @border-thickness solid @rcblue;
2151 margin-right: @padding;
2155 margin-right: @padding;
2152 }
2156 }
2153 }
2157 }
2154 }
2158 }
2155
2159
2156 .search_activate {
2160 .search_activate {
2157 display: table-cell;
2161 display: table-cell;
2158 vertical-align: middle;
2162 vertical-align: middle;
2159
2163
2160 input, label{
2164 input, label{
2161 margin: 0;
2165 margin: 0;
2162 padding: 0;
2166 padding: 0;
2163 }
2167 }
2164
2168
2165 input{
2169 input{
2166 margin-left: @textmargin;
2170 margin-left: @textmargin;
2167 }
2171 }
2168
2172
2169 }
2173 }
2170 }
2174 }
2171
2175
2172 .browser-cur-rev{
2176 .browser-cur-rev{
2173 margin-bottom: @textmargin;
2177 margin-bottom: @textmargin;
2174 }
2178 }
2175
2179
2176 #node_filter_box_loading{
2180 #node_filter_box_loading{
2177 .info_text;
2181 .info_text;
2178 }
2182 }
2179
2183
2180 .browser-search {
2184 .browser-search {
2181 margin: -25px 0px 5px 0px;
2185 margin: -25px 0px 5px 0px;
2182 }
2186 }
2183
2187
2184 .node-filter {
2188 .node-filter {
2185 font-size: @repo-title-fontsize;
2189 font-size: @repo-title-fontsize;
2186 padding: 4px 0px 0px 0px;
2190 padding: 4px 0px 0px 0px;
2187
2191
2188 .node-filter-path {
2192 .node-filter-path {
2189 float: left;
2193 float: left;
2190 color: @grey4;
2194 color: @grey4;
2191 }
2195 }
2192 .node-filter-input {
2196 .node-filter-input {
2193 float: left;
2197 float: left;
2194 margin: -2px 0px 0px 2px;
2198 margin: -2px 0px 0px 2px;
2195 input {
2199 input {
2196 padding: 2px;
2200 padding: 2px;
2197 border: none;
2201 border: none;
2198 font-size: @repo-title-fontsize;
2202 font-size: @repo-title-fontsize;
2199 }
2203 }
2200 }
2204 }
2201 }
2205 }
2202
2206
2203
2207
2204 .browser-result{
2208 .browser-result{
2205 td a{
2209 td a{
2206 margin-left: 0.5em;
2210 margin-left: 0.5em;
2207 display: inline-block;
2211 display: inline-block;
2208
2212
2209 em{
2213 em{
2210 font-family: @text-bold;
2214 font-family: @text-bold;
2211 }
2215 }
2212 }
2216 }
2213 }
2217 }
2214
2218
2215 .browser-highlight{
2219 .browser-highlight{
2216 background-color: @grey5-alpha;
2220 background-color: @grey5-alpha;
2217 }
2221 }
2218
2222
2219
2223
2220 // Search
2224 // Search
2221
2225
2222 .search-form{
2226 .search-form{
2223 #q {
2227 #q {
2224 width: @search-form-width;
2228 width: @search-form-width;
2225 }
2229 }
2226 .fields{
2230 .fields{
2227 margin: 0 0 @space;
2231 margin: 0 0 @space;
2228 }
2232 }
2229
2233
2230 label{
2234 label{
2231 display: inline-block;
2235 display: inline-block;
2232 margin-right: @textmargin;
2236 margin-right: @textmargin;
2233 padding-top: 0.25em;
2237 padding-top: 0.25em;
2234 }
2238 }
2235
2239
2236
2240
2237 .results{
2241 .results{
2238 clear: both;
2242 clear: both;
2239 margin: 0 0 @padding;
2243 margin: 0 0 @padding;
2240 }
2244 }
2241 }
2245 }
2242
2246
2243 div.search-feedback-items {
2247 div.search-feedback-items {
2244 display: inline-block;
2248 display: inline-block;
2245 padding:0px 0px 0px 96px;
2249 padding:0px 0px 0px 96px;
2246 }
2250 }
2247
2251
2248 div.search-code-body {
2252 div.search-code-body {
2249 background-color: #ffffff; padding: 5px 0 5px 10px;
2253 background-color: #ffffff; padding: 5px 0 5px 10px;
2250 pre {
2254 pre {
2251 .match { background-color: #faffa6;}
2255 .match { background-color: #faffa6;}
2252 .break { display: block; width: 100%; background-color: #DDE7EF; color: #747474; }
2256 .break { display: block; width: 100%; background-color: #DDE7EF; color: #747474; }
2253 }
2257 }
2254 }
2258 }
2255
2259
2256 .expand_commit.search {
2260 .expand_commit.search {
2257 .show_more.open {
2261 .show_more.open {
2258 height: auto;
2262 height: auto;
2259 max-height: none;
2263 max-height: none;
2260 }
2264 }
2261 }
2265 }
2262
2266
2263 .search-results {
2267 .search-results {
2264
2268
2265 h2 {
2269 h2 {
2266 margin-bottom: 0;
2270 margin-bottom: 0;
2267 }
2271 }
2268 .codeblock {
2272 .codeblock {
2269 border: none;
2273 border: none;
2270 background: transparent;
2274 background: transparent;
2271 }
2275 }
2272
2276
2273 .codeblock-header {
2277 .codeblock-header {
2274 border: none;
2278 border: none;
2275 background: transparent;
2279 background: transparent;
2276 }
2280 }
2277
2281
2278 .code-body {
2282 .code-body {
2279 border: @border-thickness solid @border-default-color;
2283 border: @border-thickness solid @border-default-color;
2280 .border-radius(@border-radius);
2284 .border-radius(@border-radius);
2281 }
2285 }
2282
2286
2283 .td-commit {
2287 .td-commit {
2284 &:extend(pre);
2288 &:extend(pre);
2285 border-bottom: @border-thickness solid @border-default-color;
2289 border-bottom: @border-thickness solid @border-default-color;
2286 }
2290 }
2287
2291
2288 .message {
2292 .message {
2289 height: auto;
2293 height: auto;
2290 max-width: 350px;
2294 max-width: 350px;
2291 white-space: normal;
2295 white-space: normal;
2292 text-overflow: initial;
2296 text-overflow: initial;
2293 overflow: visible;
2297 overflow: visible;
2294
2298
2295 .match { background-color: #faffa6;}
2299 .match { background-color: #faffa6;}
2296 .break { background-color: #DDE7EF; width: 100%; color: #747474; display: block; }
2300 .break { background-color: #DDE7EF; width: 100%; color: #747474; display: block; }
2297 }
2301 }
2298
2302
2299 }
2303 }
2300
2304
2301 table.rctable td.td-search-results div {
2305 table.rctable td.td-search-results div {
2302 max-width: 100%;
2306 max-width: 100%;
2303 }
2307 }
2304
2308
2305 #tip-box, .tip-box{
2309 #tip-box, .tip-box{
2306 padding: @menupadding/2;
2310 padding: @menupadding/2;
2307 display: block;
2311 display: block;
2308 border: @border-thickness solid @border-highlight-color;
2312 border: @border-thickness solid @border-highlight-color;
2309 .border-radius(@border-radius);
2313 .border-radius(@border-radius);
2310 background-color: white;
2314 background-color: white;
2311 z-index: 99;
2315 z-index: 99;
2312 white-space: pre-wrap;
2316 white-space: pre-wrap;
2313 }
2317 }
2314
2318
2315 #linktt {
2319 #linktt {
2316 width: 79px;
2320 width: 79px;
2317 }
2321 }
2318
2322
2319 #help_kb .modal-content{
2323 #help_kb .modal-content{
2320 max-width: 750px;
2324 max-width: 750px;
2321 margin: 10% auto;
2325 margin: 10% auto;
2322
2326
2323 table{
2327 table{
2324 td,th{
2328 td,th{
2325 border-bottom: none;
2329 border-bottom: none;
2326 line-height: 2.5em;
2330 line-height: 2.5em;
2327 }
2331 }
2328 th{
2332 th{
2329 padding-bottom: @textmargin/2;
2333 padding-bottom: @textmargin/2;
2330 }
2334 }
2331 td.keys{
2335 td.keys{
2332 text-align: center;
2336 text-align: center;
2333 }
2337 }
2334 }
2338 }
2335
2339
2336 .block-left{
2340 .block-left{
2337 width: 45%;
2341 width: 45%;
2338 margin-right: 5%;
2342 margin-right: 5%;
2339 }
2343 }
2340 .modal-footer{
2344 .modal-footer{
2341 clear: both;
2345 clear: both;
2342 }
2346 }
2343 .key.tag{
2347 .key.tag{
2344 padding: 0.5em;
2348 padding: 0.5em;
2345 background-color: @rcblue;
2349 background-color: @rcblue;
2346 color: white;
2350 color: white;
2347 border-color: @rcblue;
2351 border-color: @rcblue;
2348 .box-shadow(none);
2352 .box-shadow(none);
2349 }
2353 }
2350 }
2354 }
2351
2355
2352
2356
2353
2357
2354 //--- IMPORTS FOR REFACTORED STYLES ------------------//
2358 //--- IMPORTS FOR REFACTORED STYLES ------------------//
2355
2359
2356 @import 'statistics-graph';
2360 @import 'statistics-graph';
2357 @import 'tables';
2361 @import 'tables';
2358 @import 'forms';
2362 @import 'forms';
2359 @import 'diff';
2363 @import 'diff';
2360 @import 'summary';
2364 @import 'summary';
2361 @import 'navigation';
2365 @import 'navigation';
2362
2366
2363 //--- SHOW/HIDE SECTIONS --//
2367 //--- SHOW/HIDE SECTIONS --//
2364
2368
2365 .btn-collapse {
2369 .btn-collapse {
2366 float: right;
2370 float: right;
2367 text-align: right;
2371 text-align: right;
2368 font-family: @text-light;
2372 font-family: @text-light;
2369 font-size: @basefontsize;
2373 font-size: @basefontsize;
2370 cursor: pointer;
2374 cursor: pointer;
2371 border: none;
2375 border: none;
2372 color: @rcblue;
2376 color: @rcblue;
2373 }
2377 }
2374
2378
2375 table.rctable,
2379 table.rctable,
2376 table.dataTable {
2380 table.dataTable {
2377 .btn-collapse {
2381 .btn-collapse {
2378 float: right;
2382 float: right;
2379 text-align: right;
2383 text-align: right;
2380 }
2384 }
2381 }
2385 }
2382
2386
2383
2387
2384 // TODO: johbo: Fix for IE10, this avoids that we see a border
2388 // TODO: johbo: Fix for IE10, this avoids that we see a border
2385 // and padding around checkboxes and radio boxes. Move to the right place,
2389 // and padding around checkboxes and radio boxes. Move to the right place,
2386 // or better: Remove this once we did the form refactoring.
2390 // or better: Remove this once we did the form refactoring.
2387 input[type=checkbox],
2391 input[type=checkbox],
2388 input[type=radio] {
2392 input[type=radio] {
2389 padding: 0;
2393 padding: 0;
2390 border: none;
2394 border: none;
2391 }
2395 }
2392
2396
2393 .toggle-ajax-spinner{
2397 .toggle-ajax-spinner{
2394 height: 16px;
2398 height: 16px;
2395 width: 16px;
2399 width: 16px;
2396 }
2400 }
@@ -1,156 +1,157 b''
1 @font-face {
1 @font-face {
2 font-family: 'rcicons';
2 font-family: 'rcicons';
3 src: url('../fonts/RCIcons/rcicons.eot?74666722');
3 src: url('../fonts/RCIcons/rcicons.eot?74666722');
4 src: url('../fonts/RCIcons/rcicons.eot?74666722#iefix') format('embedded-opentype'),
4 src: url('../fonts/RCIcons/rcicons.eot?74666722#iefix') format('embedded-opentype'),
5 url('../fonts/RCIcons/rcicons.woff2?74666722') format('woff2'),
5 url('../fonts/RCIcons/rcicons.woff2?74666722') format('woff2'),
6 url('../fonts/RCIcons/rcicons.woff?74666722') format('woff'),
6 url('../fonts/RCIcons/rcicons.woff?74666722') format('woff'),
7 url('../fonts/RCIcons/rcicons.ttf?74666722') format('truetype'),
7 url('../fonts/RCIcons/rcicons.ttf?74666722') format('truetype'),
8 url('../fonts/RCIcons/rcicons.svg?74666722#rcicons') format('svg');
8 url('../fonts/RCIcons/rcicons.svg?74666722#rcicons') format('svg');
9 font-weight: normal;
9 font-weight: normal;
10 font-style: normal;
10 font-style: normal;
11 }
11 }
12 /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
12 /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
13 /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
13 /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
14 /*
14 /*
15 @media screen and (-webkit-min-device-pixel-ratio:0) {
15 @media screen and (-webkit-min-device-pixel-ratio:0) {
16 @font-face {
16 @font-face {
17 font-family: 'rcicons';
17 font-family: 'rcicons';
18 src: url('../fonts/RCIcons/rcicons.svg?74666722#rcicons') format('svg');
18 src: url('../fonts/RCIcons/rcicons.svg?74666722#rcicons') format('svg');
19 }
19 }
20 }
20 }
21 */
21 */
22
22
23 [class^="icon-"]:before, [class*=" icon-"]:before {
23 [class^="icon-"]:before, [class*=" icon-"]:before {
24 font-family: "rcicons";
24 font-family: "rcicons";
25 font-style: normal;
25 font-style: normal;
26 font-weight: normal;
26 font-weight: normal;
27 speak: none;
27 speak: none;
28
28
29 display: inline-block;
29 display: inline-block;
30 text-decoration: inherit;
30 text-decoration: inherit;
31 width: 1em;
31 width: 1em;
32 margin-right: .2em;
32 margin-right: .2em;
33 text-align: center;
33 text-align: center;
34 /* opacity: .8; */
34 /* opacity: .8; */
35
35
36 /* For safety - reset parent styles, that can break glyph codes*/
36 /* For safety - reset parent styles, that can break glyph codes*/
37 font-variant: normal;
37 font-variant: normal;
38 text-transform: none;
38 text-transform: none;
39
39
40 /* fix buttons height, for twitter bootstrap */
40 /* fix buttons height, for twitter bootstrap */
41 line-height: 1em;
41 line-height: 1em;
42
42
43 /* Animation center compensation - margins should be symmetric */
43 /* Animation center compensation - margins should be symmetric */
44 /* remove if not needed */
44 /* remove if not needed */
45 margin-left: .2em;
45 margin-left: .2em;
46
46
47 /* you can be more comfortable with increased icons size */
47 /* you can be more comfortable with increased icons size */
48 /* font-size: 120%; */
48 /* font-size: 120%; */
49
49
50 /* Font smoothing. That was taken from TWBS */
50 /* Font smoothing. That was taken from TWBS */
51 -webkit-font-smoothing: antialiased;
51 -webkit-font-smoothing: antialiased;
52 -moz-osx-font-smoothing: grayscale;
52 -moz-osx-font-smoothing: grayscale;
53
53
54 /* Uncomment for 3D effect */
54 /* Uncomment for 3D effect */
55 /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
55 /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
56 }
56 }
57
57
58 // -- ICON CLASSES -- //
58 // -- ICON CLASSES -- //
59
59
60 .icon-bookmark:before { content: '\e803'; } /* 'ξ ƒ' */
60 .icon-bookmark:before { content: '\e803'; } /* 'ξ ƒ' */
61 .icon-branch:before { content: '\e804'; } /* 'ξ „' */
61 .icon-branch:before { content: '\e804'; } /* 'ξ „' */
62 .icon-lock:before { content: '\e806'; } /* 'ξ †' */
62 .icon-lock:before { content: '\e806'; } /* 'ξ †' */
63 .icon-unlock:before { content: '\e807'; } /* 'ξ ‡' */
63 .icon-unlock:before { content: '\e807'; } /* 'ξ ‡' */
64 .icon-delete:before { content: '\e808'; } /* '' */
64 .icon-delete:before { content: '\e808'; } /* '' */
65 .icon-false:before { content: '\e808'; } /* '' */
65
66
66 .icon-ok:before { content: '\e809'; } /* 'ξ ‰' */
67 .icon-ok:before { content: '\e809'; } /* 'ξ ‰' */
67 .icon-true:before { content: '\e809'; } /* 'ξ ‰' */
68 .icon-true:before { content: '\e809'; } /* 'ξ ‰' */
68
69
69 .icon-comment:before { content: '\e80a'; } /* '' */
70 .icon-comment:before { content: '\e80a'; } /* '' */
70 .icon-comment-add:before { content: '\e816'; } /* 'ξ –' */
71 .icon-comment-add:before { content: '\e816'; } /* 'ξ –' */
71 .icon-comment_toggle:before { content: '\e818'; } /* '' */
72 .icon-comment_toggle:before { content: '\e818'; } /* '' */
72
73
73 .icon-feed:before { content: '\e80b'; } /* 'ξ ‹' */
74 .icon-feed:before { content: '\e80b'; } /* 'ξ ‹' */
74
75
75 .icon-right:before { content: '\e80c'; } /* '' */
76 .icon-right:before { content: '\e80c'; } /* '' */
76 .icon-left:before { content: '\e80d'; } /* '' */
77 .icon-left:before { content: '\e80d'; } /* '' */
77
78
78 .icon-arrow_down:before { content: '\e80e'; } /* '' */
79 .icon-arrow_down:before { content: '\e80e'; } /* '' */
79 .icon-arrow_up:before { content: '\e80e'; } /* '' */
80 .icon-arrow_up:before { content: '\e80e'; } /* '' */
80
81
81 .icon-group:before { content: '\e812'; } /* 'ξ ’' */
82 .icon-group:before { content: '\e812'; } /* 'ξ ’' */
82
83
83 .icon-fork:before { content: '\e814'; } /* 'ξ ”' */
84 .icon-fork:before { content: '\e814'; } /* 'ξ ”' */
84 .icon-merge:before { content: '\e814'; } /* 'ξ ”' */
85 .icon-merge:before { content: '\e814'; } /* 'ξ ”' */
85
86
86 .icon-more:before { content: '\e815'; } /* 'ξ •' */
87 .icon-more:before { content: '\e815'; } /* 'ξ •' */
87
88
88 .icon-git-inv:before { content: '\e80f'; } /* '' */
89 .icon-git-inv:before { content: '\e80f'; } /* '' */
89 .icon-hg-inv:before { content: '\e810'; } /* '' */
90 .icon-hg-inv:before { content: '\e810'; } /* '' */
90 .icon-svn-inv:before { content: '\e811'; } /* 'ξ ‘' */
91 .icon-svn-inv:before { content: '\e811'; } /* 'ξ ‘' */
91
92
92 .icon-git:before { content: '\e81a'; } /* '' */
93 .icon-git:before { content: '\e81a'; } /* '' */
93 .icon-hg:before { content: '\e81b'; } /* 'ξ ›' */
94 .icon-hg:before { content: '\e81b'; } /* 'ξ ›' */
94 .icon-svn:before { content: '\e820'; } /* 'ξ  ' */
95 .icon-svn:before { content: '\e820'; } /* 'ξ  ' */
95
96
96 .icon-minus:before { content: '\e81c'; } /* '' */
97 .icon-minus:before { content: '\e81c'; } /* '' */
97 .icon-plus:before { content: '\e81d'; } /* '' */
98 .icon-plus:before { content: '\e81d'; } /* '' */
98 .icon-remove:before { content: '\e81e'; } /* '' */
99 .icon-remove:before { content: '\e81e'; } /* '' */
99 .icon-remove-sign:before { content: '\e81e'; } /* '' */
100 .icon-remove-sign:before { content: '\e81e'; } /* '' */
100
101
101 .icon-rhodecode:before { content: '\e81f'; } /* '' */
102 .icon-rhodecode:before { content: '\e81f'; } /* '' */
102
103
103 .icon-tag:before { content: '\e821'; } /* 'ξ ‘' */
104 .icon-tag:before { content: '\e821'; } /* 'ξ ‘' */
104 .icon-copy:before { content: '\f0c5'; } /* 'οƒ…' */
105 .icon-copy:before { content: '\f0c5'; } /* 'οƒ…' */
105 .icon-clipboard:before { content: '\f0c5'; } /* 'οƒ…' */
106 .icon-clipboard:before { content: '\f0c5'; } /* 'οƒ…' */
106
107
107
108
108 .icon-folder:before { content: '\e813'; } /* 'ξ “' */
109 .icon-folder:before { content: '\e813'; } /* 'ξ “' */
109 .icon-folder-close:before { content: '\e813'; } /* 'ξ “' */
110 .icon-folder-close:before { content: '\e813'; } /* 'ξ “' */
110
111
111 .icon-directory:before { content: '\e800'; } /* 'ξ €' */
112 .icon-directory:before { content: '\e800'; } /* 'ξ €' */
112 .icon-directory-empty:before { content: '\f114'; } /* 'ο„”' */
113 .icon-directory-empty:before { content: '\f114'; } /* 'ο„”' */
113 .icon-file-text:before { content: '\f0f6'; } /* 'οƒΆ' */
114 .icon-file-text:before { content: '\f0f6'; } /* 'οƒΆ' */
114 .icon-file-text-inv:before { content: '\f15c'; } /* 'ο…œ' */
115 .icon-file-text-inv:before { content: '\f15c'; } /* 'ο…œ' */
115 .icon-file-code:before { content: '\f1c9'; } /* '' */
116 .icon-file-code:before { content: '\f1c9'; } /* '' */
116
117
117 // MERGED ICONS
118 // MERGED ICONS
118
119
119 .icon-repo-private:before { &:extend(.icon-lock:before); }
120 .icon-repo-private:before { &:extend(.icon-lock:before); }
120 .icon-repo-lock:before { &:extend(.icon-lock:before); }
121 .icon-repo-lock:before { &:extend(.icon-lock:before); }
121 .icon-unlock-alt:before { &:extend(.icon-unlock:before); }
122 .icon-unlock-alt:before { &:extend(.icon-unlock:before); }
122 .icon-repo-unlock:before { &:extend(.icon-unlock:before); }
123 .icon-repo-unlock:before { &:extend(.icon-unlock:before); }
123 .icon-repo-public:before { &:extend(.icon-unlock:before); }
124 .icon-repo-public:before { &:extend(.icon-unlock:before); }
124 .icon-rss-sign:before { &:extend(.icon-feed:before); }
125 .icon-rss-sign:before { &:extend(.icon-feed:before); }
125 .icon-code-fork:before { &:extend(.icon-fork:before); }
126 .icon-code-fork:before { &:extend(.icon-fork:before); }
126
127
127 // TRANSFORM
128 // TRANSFORM
128 .icon-arrow_up:before {transform: rotate(180deg);}
129 .icon-arrow_up:before {transform: rotate(180deg);}
129 .icon-merge:before {transform: rotate(180deg);}
130 .icon-merge:before {transform: rotate(180deg);}
130
131
131 // -- END ICON CLASSES -- //
132 // -- END ICON CLASSES -- //
132
133
133
134
134 //--- ICONS STYLING ------------------//
135 //--- ICONS STYLING ------------------//
135
136
136 .icon-git { color: @color4 !important; }
137 .icon-git { color: @color4 !important; }
137 .icon-hg { color: @color8 !important; }
138 .icon-hg { color: @color8 !important; }
138 .icon-svn { color: @color1 !important; }
139 .icon-svn { color: @color1 !important; }
139 .icon-git-inv { color: @color4 !important; }
140 .icon-git-inv { color: @color4 !important; }
140 .icon-hg-inv { color: @color8 !important; }
141 .icon-hg-inv { color: @color8 !important; }
141 .icon-svn-inv { color: @color1 !important; }
142 .icon-svn-inv { color: @color1 !important; }
142 .icon-repo-lock { color: #FF0000; }
143 .icon-repo-lock { color: #FF0000; }
143 .icon-repo-unlock { color: #FF0000; }
144 .icon-repo-unlock { color: #FF0000; }
144
145
145 .repo-switcher-dropdown .select2-result-label {
146 .repo-switcher-dropdown .select2-result-label {
146 .icon-git:before {
147 .icon-git:before {
147 &:extend(.icon-git-transparent:before);
148 &:extend(.icon-git-transparent:before);
148 }
149 }
149 .icon-hg:before {
150 .icon-hg:before {
150 &:extend(.icon-hg-transparent:before);
151 &:extend(.icon-hg-transparent:before);
151 color: @alert4;
152 color: @alert4;
152 }
153 }
153 .icon-svn:before {
154 .icon-svn:before {
154 &:extend(.icon-svn-transparent:before);
155 &:extend(.icon-svn-transparent:before);
155 }
156 }
156 }
157 }
@@ -1,63 +1,78 b''
1
1
2 <div class="pull-request-wrap">
2 <div class="pull-request-wrap">
3
3
4 % if c.pr_merge_possible:
4 % if c.pr_merge_possible:
5 <h2 class="merge-status">
5 <h2 class="merge-status">
6 <span class="merge-icon success"><i class="icon-ok"></i></span>
6 <span class="merge-icon success"><i class="icon-ok"></i></span>
7 ${_('This pull request can be merged automatically.')}
7 ${_('This pull request can be merged automatically.')}
8 </h2>
8 </h2>
9 % else:
9 % else:
10 <h2 class="merge-status">
10 <h2 class="merge-status">
11 <span class="merge-icon warning"><i class="icon-false"></i></span>
11 <span class="merge-icon warning"><i class="icon-false"></i></span>
12 ${_('Merge is not currently possible because of below failed checks.')}
12 ${_('Merge is not currently possible because of below failed checks.')}
13 </h2>
13 </h2>
14 % endif
14 % endif
15
15
16 % if c.pr_merge_errors.items():
16 <ul>
17 <ul>
17 % for pr_check_key, pr_check_details in c.pr_merge_errors.items():
18 % for pr_check_key, pr_check_details in c.pr_merge_errors.items():
18 <% pr_check_type = pr_check_details['error_type'] %>
19 <% pr_check_type = pr_check_details['error_type'] %>
19 <li>
20 <li>
20 <span class="merge-message ${pr_check_type}" data-role="merge-message">
21 <span class="merge-message ${pr_check_type}" data-role="merge-message">
21 - ${pr_check_details['message']}
22 - ${pr_check_details['message']}
22 % if pr_check_key == 'todo':
23 % if pr_check_key == 'todo':
23 % for co in pr_check_details['details']:
24 % for co in pr_check_details['details']:
24 <a class="permalink" href="#comment-${co.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${co.comment_id}'), 0, ${h.json.dumps(co.outdated)})"> #${co.comment_id}</a>${'' if loop.last else ','}
25 <a class="permalink" href="#comment-${co.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${co.comment_id}'), 0, ${h.json.dumps(co.outdated)})"> #${co.comment_id}</a>${'' if loop.last else ','}
25 % endfor
26 % endfor
26 % endif
27 % endif
27 </span>
28 </span>
28 </li>
29 </li>
29 % endfor
30 % endfor
30 </ul>
31 </ul>
32 % endif
31
33
32 <div class="pull-request-merge-actions">
34 <div class="pull-request-merge-actions">
33 % if c.allowed_to_merge:
35 % if c.allowed_to_merge:
34 <div class="pull-right">
36 ## Merge info, show only if all errors are taken care of
37 % if not c.pr_merge_errors and c.pr_merge_info:
38 <div class="pull-request-merge-info">
39 <ul>
40 % for pr_merge_key, pr_merge_details in c.pr_merge_info.items():
41 <li>
42 - ${pr_merge_details['message']}
43 </li>
44 % endfor
45 </ul>
46 </div>
47 % endif
48
49 <div>
35 ${h.secure_form(h.route_path('pullrequest_merge', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id), id='merge_pull_request_form', method='POST', request=request)}
50 ${h.secure_form(h.route_path('pullrequest_merge', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id), id='merge_pull_request_form', method='POST', request=request)}
36 <% merge_disabled = ' disabled' if c.pr_merge_possible is False else '' %>
51 <% merge_disabled = ' disabled' if c.pr_merge_possible is False else '' %>
37 <a class="btn" href="#" onclick="refreshMergeChecks(); return false;">${_('refresh checks')}</a>
52 <a class="btn" href="#" onclick="refreshMergeChecks(); return false;">${_('refresh checks')}</a>
38 <input type="submit" id="merge_pull_request" value="${_('Merge Pull Request')}" class="btn${merge_disabled}"${merge_disabled}>
53 <input type="submit" id="merge_pull_request" value="${_('Merge Pull Request')}" class="btn${merge_disabled}"${merge_disabled}>
39 ${h.end_form()}
54 ${h.end_form()}
40 </div>
55 </div>
41 % elif c.rhodecode_user.username != h.DEFAULT_USER:
56 % elif c.rhodecode_user.username != h.DEFAULT_USER:
42 <a class="btn" href="#" onclick="refreshMergeChecks(); return false;">${_('refresh checks')}</a>
57 <a class="btn" href="#" onclick="refreshMergeChecks(); return false;">${_('refresh checks')}</a>
43 <input type="submit" value="${_('Merge Pull Request')}" class="btn disabled" disabled="disabled" title="${_('You are not allowed to merge this pull request.')}">
58 <input type="submit" value="${_('Merge Pull Request')}" class="btn disabled" disabled="disabled" title="${_('You are not allowed to merge this pull request.')}">
44 % else:
59 % else:
45 <input type="submit" value="${_('Login to Merge this Pull Request')}" class="btn disabled" disabled="disabled">
60 <input type="submit" value="${_('Login to Merge this Pull Request')}" class="btn disabled" disabled="disabled">
46 % endif
61 % endif
47 </div>
62 </div>
48
63
49 % if c.allowed_to_close:
64 % if c.allowed_to_close:
50 ## close PR action, injected later next to COMMENT button
65 ## close PR action, injected later next to COMMENT button
51 <div id="close-pull-request-action" style="display: none">
66 <div id="close-pull-request-action" style="display: none">
52 % if c.pull_request_review_status == c.REVIEW_STATUS_APPROVED:
67 % if c.pull_request_review_status == c.REVIEW_STATUS_APPROVED:
53 <a class="btn btn-approved-status" href="#close-as-approved" onclick="closePullRequest('${c.REVIEW_STATUS_APPROVED}'); return false;">
68 <a class="btn btn-approved-status" href="#close-as-approved" onclick="closePullRequest('${c.REVIEW_STATUS_APPROVED}'); return false;">
54 ${_('Close with status {}').format(h.commit_status_lbl(c.REVIEW_STATUS_APPROVED))}
69 ${_('Close with status {}').format(h.commit_status_lbl(c.REVIEW_STATUS_APPROVED))}
55 </a>
70 </a>
56 % else:
71 % else:
57 <a class="btn btn-rejected-status" href="#close-as-rejected" onclick="closePullRequest('${c.REVIEW_STATUS_REJECTED}'); return false;">
72 <a class="btn btn-rejected-status" href="#close-as-rejected" onclick="closePullRequest('${c.REVIEW_STATUS_REJECTED}'); return false;">
58 ${_('Close with status {}').format(h.commit_status_lbl(c.REVIEW_STATUS_REJECTED))}
73 ${_('Close with status {}').format(h.commit_status_lbl(c.REVIEW_STATUS_REJECTED))}
59 </a>
74 </a>
60 % endif
75 % endif
61 </div>
76 </div>
62 % endif
77 % endif
63 </div>
78 </div>
General Comments 0
You need to be logged in to leave comments. Login now