Show More
@@ -0,0 +1,41 b'' | |||||
|
1 | import logging | |||
|
2 | ||||
|
3 | from sqlalchemy import * | |||
|
4 | ||||
|
5 | from rhodecode.model import meta | |||
|
6 | from rhodecode.lib.dbmigrate.versions import _reset_base, notify | |||
|
7 | ||||
|
8 | log = logging.getLogger(__name__) | |||
|
9 | ||||
|
10 | ||||
|
11 | def upgrade(migrate_engine): | |||
|
12 | """ | |||
|
13 | Upgrade operations go here. | |||
|
14 | Don't create your own engine; bind migrate_engine to your metadata | |||
|
15 | """ | |||
|
16 | _reset_base(migrate_engine) | |||
|
17 | from rhodecode.lib.dbmigrate.schema import db_4_11_0_0 as db | |||
|
18 | ||||
|
19 | review_rule_table = db.RepoReviewRule.__table__ | |||
|
20 | ||||
|
21 | target_branch_pattern = Column( | |||
|
22 | "target_branch_pattern", | |||
|
23 | UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') | |||
|
24 | target_branch_pattern.create(table=review_rule_table) | |||
|
25 | ||||
|
26 | review_rule_name = Column('review_rule_name', String(255)) | |||
|
27 | review_rule_name.create(table=review_rule_table) | |||
|
28 | ||||
|
29 | # issue fixups | |||
|
30 | fixups(db, meta.Session) | |||
|
31 | ||||
|
32 | ||||
|
33 | def downgrade(migrate_engine): | |||
|
34 | meta = MetaData() | |||
|
35 | meta.bind = migrate_engine | |||
|
36 | ||||
|
37 | ||||
|
38 | def fixups(models, _SESSION): | |||
|
39 | pass | |||
|
40 | ||||
|
41 |
@@ -51,7 +51,7 b' PYRAMID_SETTINGS = {}' | |||||
51 | EXTENSIONS = {} |
|
51 | EXTENSIONS = {} | |
52 |
|
52 | |||
53 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) |
|
53 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) | |
54 |
__dbversion__ = 8 |
|
54 | __dbversion__ = 83 # defines current db version for migrations | |
55 | __platform__ = platform.system() |
|
55 | __platform__ = platform.system() | |
56 | __license__ = 'AGPLv3, and Commercial License' |
|
56 | __license__ = 'AGPLv3, and Commercial License' | |
57 | __author__ = 'RhodeCode GmbH' |
|
57 | __author__ = 'RhodeCode GmbH' |
@@ -4127,7 +4127,9 b' class RepoReviewRule(Base, BaseModel):' | |||||
4127 | "repo_id", Integer(), ForeignKey('repositories.repo_id')) |
|
4127 | "repo_id", Integer(), ForeignKey('repositories.repo_id')) | |
4128 | repo = relationship('Repository', backref='review_rules') |
|
4128 | repo = relationship('Repository', backref='review_rules') | |
4129 |
|
4129 | |||
|
4130 | review_rule_name = Column('review_rule_name', String(255)) | |||
4130 | _branch_pattern = Column("branch_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob |
|
4131 | _branch_pattern = Column("branch_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob | |
|
4132 | _target_branch_pattern = Column("target_branch_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob | |||
4131 | _file_pattern = Column("file_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob |
|
4133 | _file_pattern = Column("file_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob | |
4132 |
|
4134 | |||
4133 | use_authors_for_review = Column("use_authors_for_review", Boolean(), nullable=False, default=False) |
|
4135 | use_authors_for_review = Column("use_authors_for_review", Boolean(), nullable=False, default=False) | |
@@ -4138,19 +4140,28 b' class RepoReviewRule(Base, BaseModel):' | |||||
4138 | rule_users = relationship('RepoReviewRuleUser') |
|
4140 | rule_users = relationship('RepoReviewRuleUser') | |
4139 | rule_user_groups = relationship('RepoReviewRuleUserGroup') |
|
4141 | rule_user_groups = relationship('RepoReviewRuleUserGroup') | |
4140 |
|
4142 | |||
4141 | @hybrid_property |
|
|||
4142 | def branch_pattern(self): |
|
|||
4143 | return self._branch_pattern or '*' |
|
|||
4144 |
|
||||
4145 | def _validate_glob(self, value): |
|
4143 | def _validate_glob(self, value): | |
4146 | re.compile('^' + glob2re(value) + '$') |
|
4144 | re.compile('^' + glob2re(value) + '$') | |
4147 |
|
4145 | |||
4148 | @branch_pattern.setter |
|
4146 | @hybrid_property | |
4149 |
def branch_pattern(self |
|
4147 | def source_branch_pattern(self): | |
|
4148 | return self._branch_pattern or '*' | |||
|
4149 | ||||
|
4150 | @source_branch_pattern.setter | |||
|
4151 | def source_branch_pattern(self, value): | |||
4150 | self._validate_glob(value) |
|
4152 | self._validate_glob(value) | |
4151 | self._branch_pattern = value or '*' |
|
4153 | self._branch_pattern = value or '*' | |
4152 |
|
4154 | |||
4153 | @hybrid_property |
|
4155 | @hybrid_property | |
|
4156 | def target_branch_pattern(self): | |||
|
4157 | return self._target_branch_pattern or '*' | |||
|
4158 | ||||
|
4159 | @target_branch_pattern.setter | |||
|
4160 | def target_branch_pattern(self, value): | |||
|
4161 | self._validate_glob(value) | |||
|
4162 | self._target_branch_pattern = value or '*' | |||
|
4163 | ||||
|
4164 | @hybrid_property | |||
4154 | def file_pattern(self): |
|
4165 | def file_pattern(self): | |
4155 | return self._file_pattern or '*' |
|
4166 | return self._file_pattern or '*' | |
4156 |
|
4167 | |||
@@ -4159,7 +4170,7 b' class RepoReviewRule(Base, BaseModel):' | |||||
4159 | self._validate_glob(value) |
|
4170 | self._validate_glob(value) | |
4160 | self._file_pattern = value or '*' |
|
4171 | self._file_pattern = value or '*' | |
4161 |
|
4172 | |||
4162 | def matches(self, branch, files_changed): |
|
4173 | def matches(self, source_branch, target_branch, files_changed): | |
4163 | """ |
|
4174 | """ | |
4164 | Check if this review rule matches a branch/files in a pull request |
|
4175 | Check if this review rule matches a branch/files in a pull request | |
4165 |
|
4176 | |||
@@ -4167,13 +4178,21 b' class RepoReviewRule(Base, BaseModel):' | |||||
4167 | :param files_changed: list of file paths changed in the pull request |
|
4178 | :param files_changed: list of file paths changed in the pull request | |
4168 | """ |
|
4179 | """ | |
4169 |
|
4180 | |||
4170 | branch = branch or '' |
|
4181 | source_branch = source_branch or '' | |
|
4182 | target_branch = target_branch or '' | |||
4171 | files_changed = files_changed or [] |
|
4183 | files_changed = files_changed or [] | |
4172 |
|
4184 | |||
4173 | branch_matches = True |
|
4185 | branch_matches = True | |
4174 | if branch: |
|
4186 | if source_branch or target_branch: | |
4175 |
branch_regex = re.compile( |
|
4187 | source_branch_regex = re.compile( | |
4176 | branch_matches = bool(branch_regex.search(branch)) |
|
4188 | '^' + glob2re(self.source_branch_pattern) + '$') | |
|
4189 | target_branch_regex = re.compile( | |||
|
4190 | '^' + glob2re(self.target_branch_pattern) + '$') | |||
|
4191 | ||||
|
4192 | branch_matches = ( | |||
|
4193 | bool(source_branch_regex.search(source_branch)) and | |||
|
4194 | bool(target_branch_regex.search(target_branch)) | |||
|
4195 | ) | |||
4177 |
|
4196 | |||
4178 | files_matches = True |
|
4197 | files_matches = True | |
4179 | if self.file_pattern != '*': |
|
4198 | if self.file_pattern != '*': |
@@ -1335,9 +1335,14 b' table.integrations {' | |||||
1335 | width: 100%; |
|
1335 | width: 100%; | |
1336 | overflow: auto; |
|
1336 | overflow: auto; | |
1337 | } |
|
1337 | } | |
1338 | .reviewer_reason { |
|
1338 | ||
|
1339 | .reviewer_reason_container { | |||
1339 |
|
|
1340 | padding-left: 20px; | |
1340 | } |
|
1341 | } | |
|
1342 | ||||
|
1343 | .reviewer_reason { | |||
|
1344 | } | |||
|
1345 | ||||
1341 | .reviewer_status { |
|
1346 | .reviewer_status { | |
1342 | display: inline-block; |
|
1347 | display: inline-block; | |
1343 | vertical-align: top; |
|
1348 | vertical-align: top; |
@@ -340,7 +340,7 b'' | |||||
340 | ## REVIEWERS |
|
340 | ## REVIEWERS | |
341 | <div class="reviewers-title block-right"> |
|
341 | <div class="reviewers-title block-right"> | |
342 | <div class="pr-details-title"> |
|
342 | <div class="pr-details-title"> | |
343 | ${_('Pull request reviewers')} |
|
343 | ${_('Pull request reviewers')} / <a href="#toggleReasons" onclick="$('.reviewer_reason').toggle(); return false">${_('show reasons')}</a> | |
344 | %if c.allowed_to_update: |
|
344 | %if c.allowed_to_update: | |
345 | <span id="open_edit_reviewers" class="block-right action_button last-item">${_('Edit')}</span> |
|
345 | <span id="open_edit_reviewers" class="block-right action_button last-item">${_('Edit')}</span> | |
346 | %endif |
|
346 | %endif | |
@@ -351,7 +351,7 b'' | |||||
351 | <input type="hidden" name="__start__" value="review_members:sequence"> |
|
351 | <input type="hidden" name="__start__" value="review_members:sequence"> | |
352 | <ul id="review_members" class="group_members"> |
|
352 | <ul id="review_members" class="group_members"> | |
353 | %for member,reasons,mandatory,status in c.pull_request_reviewers: |
|
353 | %for member,reasons,mandatory,status in c.pull_request_reviewers: | |
354 |
<li id="reviewer_${member.user_id}" |
|
354 | <li id="reviewer_${member.user_id}"> | |
355 | <div class="reviewers_member"> |
|
355 | <div class="reviewers_member"> | |
356 | <div class="reviewer_status tooltip" title="${h.tooltip(h.commit_status_lbl(status[0][1].status if status else 'not_reviewed'))}"> |
|
356 | <div class="reviewer_status tooltip" title="${h.tooltip(h.commit_status_lbl(status[0][1].status if status else 'not_reviewed'))}"> | |
357 | <div class="${'flag_status %s' % (status[0][1].status if status else 'not_reviewed')} pull-left reviewer_member_status"></div> |
|
357 | <div class="${'flag_status %s' % (status[0][1].status if status else 'not_reviewed')} pull-left reviewer_member_status"></div> | |
@@ -361,11 +361,14 b'' | |||||
361 | </div> |
|
361 | </div> | |
362 | <input type="hidden" name="__start__" value="reviewer:mapping"> |
|
362 | <input type="hidden" name="__start__" value="reviewer:mapping"> | |
363 | <input type="hidden" name="__start__" value="reasons:sequence"> |
|
363 | <input type="hidden" name="__start__" value="reasons:sequence"> | |
|
364 | % if reasons: | |||
|
365 | <div class="reviewer_reason_container"> | |||
364 | %for reason in reasons: |
|
366 | %for reason in reasons: | |
365 | <div class="reviewer_reason">- ${reason}</div> |
|
367 | <div class="reviewer_reason" style="display: none">- ${reason}</div> | |
366 | <input type="hidden" name="reason" value="${reason}"> |
|
368 | <input type="hidden" name="reason" value="${reason}"> | |
367 |
|
||||
368 | %endfor |
|
369 | %endfor | |
|
370 | </div> | |||
|
371 | % endif | |||
369 | <input type="hidden" name="__end__" value="reasons:sequence"> |
|
372 | <input type="hidden" name="__end__" value="reasons:sequence"> | |
370 | <input id="reviewer_${member.user_id}_input" type="hidden" value="${member.user_id}" name="user_id" /> |
|
373 | <input id="reviewer_${member.user_id}_input" type="hidden" value="${member.user_id}" name="user_id" /> | |
371 | <input type="hidden" name="mandatory" value="${mandatory}"/> |
|
374 | <input type="hidden" name="mandatory" value="${mandatory}"/> |
General Comments 0
You need to be logged in to leave comments.
Login now