diff --git a/rhodecode/__init__.py b/rhodecode/__init__.py --- a/rhodecode/__init__.py +++ b/rhodecode/__init__.py @@ -51,7 +51,7 @@ PYRAMID_SETTINGS = {} EXTENSIONS = {} __version__ = ('.'.join((str(each) for each in VERSION[:3]))) -__dbversion__ = 82 # defines current db version for migrations +__dbversion__ = 83 # defines current db version for migrations __platform__ = platform.system() __license__ = 'AGPLv3, and Commercial License' __author__ = 'RhodeCode GmbH' diff --git a/rhodecode/lib/dbmigrate/versions/083_version_4_11_0.py b/rhodecode/lib/dbmigrate/versions/083_version_4_11_0.py new file mode 100644 --- /dev/null +++ b/rhodecode/lib/dbmigrate/versions/083_version_4_11_0.py @@ -0,0 +1,41 @@ +import logging + +from sqlalchemy import * + +from rhodecode.model import meta +from rhodecode.lib.dbmigrate.versions import _reset_base, notify + +log = logging.getLogger(__name__) + + +def upgrade(migrate_engine): + """ + Upgrade operations go here. + Don't create your own engine; bind migrate_engine to your metadata + """ + _reset_base(migrate_engine) + from rhodecode.lib.dbmigrate.schema import db_4_11_0_0 as db + + review_rule_table = db.RepoReviewRule.__table__ + + target_branch_pattern = Column( + "target_branch_pattern", + UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') + target_branch_pattern.create(table=review_rule_table) + + review_rule_name = Column('review_rule_name', String(255)) + review_rule_name.create(table=review_rule_table) + + # issue fixups + fixups(db, meta.Session) + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + +def fixups(models, _SESSION): + pass + + diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -4127,7 +4127,9 @@ class RepoReviewRule(Base, BaseModel): "repo_id", Integer(), ForeignKey('repositories.repo_id')) repo = relationship('Repository', backref='review_rules') + review_rule_name = Column('review_rule_name', String(255)) _branch_pattern = Column("branch_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob + _target_branch_pattern = Column("target_branch_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob _file_pattern = Column("file_pattern", UnicodeText().with_variant(UnicodeText(255), 'mysql'), default=u'*') # glob use_authors_for_review = Column("use_authors_for_review", Boolean(), nullable=False, default=False) @@ -4138,19 +4140,28 @@ class RepoReviewRule(Base, BaseModel): rule_users = relationship('RepoReviewRuleUser') rule_user_groups = relationship('RepoReviewRuleUserGroup') - @hybrid_property - def branch_pattern(self): - return self._branch_pattern or '*' - def _validate_glob(self, value): re.compile('^' + glob2re(value) + '$') - @branch_pattern.setter - def branch_pattern(self, value): + @hybrid_property + def source_branch_pattern(self): + return self._branch_pattern or '*' + + @source_branch_pattern.setter + def source_branch_pattern(self, value): self._validate_glob(value) self._branch_pattern = value or '*' @hybrid_property + def target_branch_pattern(self): + return self._target_branch_pattern or '*' + + @target_branch_pattern.setter + def target_branch_pattern(self, value): + self._validate_glob(value) + self._target_branch_pattern = value or '*' + + @hybrid_property def file_pattern(self): return self._file_pattern or '*' @@ -4159,7 +4170,7 @@ class RepoReviewRule(Base, BaseModel): self._validate_glob(value) self._file_pattern = value or '*' - def matches(self, branch, files_changed): + def matches(self, source_branch, target_branch, files_changed): """ Check if this review rule matches a branch/files in a pull request @@ -4167,13 +4178,21 @@ class RepoReviewRule(Base, BaseModel): :param files_changed: list of file paths changed in the pull request """ - branch = branch or '' + source_branch = source_branch or '' + target_branch = target_branch or '' files_changed = files_changed or [] branch_matches = True - if branch: - branch_regex = re.compile('^' + glob2re(self.branch_pattern) + '$') - branch_matches = bool(branch_regex.search(branch)) + if source_branch or target_branch: + source_branch_regex = re.compile( + '^' + glob2re(self.source_branch_pattern) + '$') + target_branch_regex = re.compile( + '^' + glob2re(self.target_branch_pattern) + '$') + + branch_matches = ( + bool(source_branch_regex.search(source_branch)) and + bool(target_branch_regex.search(target_branch)) + ) files_matches = True if self.file_pattern != '*': diff --git a/rhodecode/public/css/main.less b/rhodecode/public/css/main.less --- a/rhodecode/public/css/main.less +++ b/rhodecode/public/css/main.less @@ -1335,9 +1335,14 @@ table.integrations { width: 100%; overflow: auto; } + +.reviewer_reason_container { + padding-left: 20px; +} + .reviewer_reason { - padding-left: 20px; } + .reviewer_status { display: inline-block; vertical-align: top; diff --git a/rhodecode/templates/pullrequests/pullrequest_show.mako b/rhodecode/templates/pullrequests/pullrequest_show.mako --- a/rhodecode/templates/pullrequests/pullrequest_show.mako +++ b/rhodecode/templates/pullrequests/pullrequest_show.mako @@ -340,7 +340,7 @@ ## REVIEWERS