Example #1
0
def handle_code_freeze_next_branch(merge_item):
    """In case of code freeze do not merge, however send an 
    email notification that a commit was taking place into a code freeze branch.
        
        Args:
            merge_item: Details of commit to be merged.
    """
    in_freeze = False
    if is_code_freeze(merge_item[KEY_CURRENT_BRANCH],
                      mergeconf.BRANCHES_IN_CODE_FREEZE):
        mergeconf.LOGGER.debug(merge_item[KEY_NEXT_BRANCH] +
                               " is in code freeze")
        audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR],
                    merge_item[KEY_NEXT_BRANCH], merge_item[KEY_NEXT_BRANCH],
                    merge_item[KEY_REV_START], merge_item[KEY_REV_START], NA,
                    NA, AUDIT_EXPL_CODE_FREEZE)
        mailutils.mail(
            mergeconf.get_dl(merge_item[KEY_AUTHOR],
                             mergeconf.ENUM_CODE_FREEZE),
            get_nextbranch_codefreeze_subject(merge_item[KEY_NEXT_BRANCH]),
            get_nextbranch_codefreeze_text(merge_item[KEY_REV_START],
                                           merge_item[KEY_CURRENT_BRANCH],
                                           merge_item[KEY_LOOK_RESULT],
                                           merge_item[KEY_NEXT_BRANCH],
                                           merge_item[KEY_MESSAGE],
                                           merge_item[KEY_AUTHOR]))
        in_freeze = True
    return in_freeze
Example #2
0
def handle_code_freeze_cur_branch(merge_item):
    """If branch is in code freeze send an email if commit was made to it, otherwise
        do not merge into it.
        
        Args:
            merge_item: Details of commit to be merged.
    """
    if is_code_freeze(merge_item[KEY_CURRENT_BRANCH],
                      mergeconf.BRANCHES_IN_CODE_FREEZE):
        mergeconf.LOGGER.debug(merge_item[KEY_CURRENT_BRANCH] +
                               " is in code freeze")
        audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR],
                    merge_item[KEY_CURRENT_BRANCH],
                    merge_item[KEY_NEXT_BRANCH], merge_item[KEY_REV_START],
                    merge_item[KEY_REV_START], NA, NA, AUDIT_EXPL_CODE_FREEZE)
        mailutils.mail(
            mergeconf.get_dl(merge_item[KEY_AUTHOR],
                             mergeconf.ENUM_CODE_FREEZE),
            'Commit made to branch ' + merge_item[KEY_CURRENT_BRANCH] +
            ' which is below code freeze branch',
            'Commit made to branch ' + merge_item[KEY_CURRENT_BRANCH] +
            ' which is below code freeze branch\r\n' + 'By: ' +
            merge_item[KEY_AUTHOR] + '\r\n' + 'Revision: ' +
            merge_item[KEY_REV_START] + '\r\n' + 'Message: ' +
            merge_item[KEY_MESSAGE] + '\r\n' + merge_item[KEY_LOOK_RESULT])
Example #3
0
def is_automatic_allowed(merge_item):
    is_allowed = True
    if not mergeconf.IS_AUTOMATIC and not merge_item[KEY_IS_MANUAL]:
        mergeconf.LOGGER.debug("Automatic merge is not allowed")
        audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR], merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_NEXT_BRANCH], merge_item[KEY_REV_START], merge_item[KEY_REV_START], NA, NA,
                    AUDIT_EXPL_AUTO_NOT_ALLOWED)
        mailutils.mail(mergeconf.get_dl(merge_item[KEY_AUTHOR], mergeconf.ENUM_EXCLUDED), get_auto_not_allowed_subject(merge_item[KEY_NEXT_BRANCH]),
                       get_auto_not_allowed_text(merge_item[KEY_REV_START], merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_LOOK_RESULT], merge_item[KEY_MESSAGE], merge_item[KEY_AUTHOR]))
        is_allowed = False
    return is_allowed
Example #4
0
def handle_excluded_next_branch(merge_item):
    f_excluded = False
    if is_excluded(merge_item[KEY_CURRENT_BRANCH]):
        mergeconf.LOGGER.debug(merge_item[KEY_CURRENT_BRANCH] + " is in exclusion")
        audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR], merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_NEXT_BRANCH], merge_item[KEY_REV_START], merge_item[KEY_REV_START], NA, NA,
                    AUDIT_EXPL_EXCLUDED)
        mailutils.mail(mergeconf.get_dl(merge_item[KEY_AUTHOR], mergeconf.ENUM_EXCLUDED), get_next_excluded_subject(merge_item[KEY_NEXT_BRANCH]),
                       get_next_excluded_text(merge_item[KEY_REV_START], merge_item[KEY_LOOK_RESULT], merge_item[KEY_NEXT_BRANCH], merge_item[KEY_MESSAGE], merge_item[KEY_AUTHOR]))
        f_excluded = True
    return f_excluded
Example #5
0
def are_commit_files_to_ignore(merge_item):
    """Check if to ignore this commit for auto merging based on the files which were committed.
        
        Args:
            files_to_ignore: If any of the files committed is in this list in conjunction with authors, do not merge.
            with_authors_to_ignore: If the files in conjunction with these authors were committed then do not auto merge.
            revstart: Revision for original commit.
            current_branch_name: The branch on which a commit has been performed.
            next_branch_name: The branch we are supposed to perform auto merging into.
            lookresult: The result fro svn look on this commit.
            author: The one who performed this commit
        Retruns:
            True means to ignore this commit for merging.
    """
    status = False
    if merge_item[KEY_FILES_TO_IGNORE] is not None:
        for file_in_commit in merge_item[KEY_FILES_TO_IGNORE]:
            loggerutils.log(
                LOGGER, "are_commit_files_to_ignore: author: " +
                merge_item[KEY_AUTHOR])
            loggerutils.log(
                LOGGER,
                "are_commit_files_to_ignore: with_authors_to_ignore: " +
                str(merge_item[KEY_AUTHORS_TO_IGNORE]))
            loggerutils.log(
                LOGGER, "lookresult: " + merge_item[KEY_LOOK_RESULT] +
                " checking if file_in_commit " + file_in_commit +
                " is in filestoignore: " +
                str(merge_item[KEY_FILES_TO_IGNORE]) + " : " +
                str(merge_item[KEY_LOOK_RESULT].find(file_in_commit)) +
                " and if author: " + merge_item[KEY_AUTHOR] +
                " is in authors to ignore: " +
                str(merge_item[KEY_AUTHORS_TO_IGNORE]) + " : " +
                str(merge_item[KEY_AUTHOR] in
                    merge_item[KEY_AUTHORS_TO_IGNORE]))
            if merge_item[KEY_LOOK_RESULT].find(
                    file_in_commit) != -1 and merge_item[
                        KEY_AUTHOR] in merge_item[KEY_AUTHORS_TO_IGNORE]:
                audit_write(AUDIT_OP_MERGE, NA, merge_item[KEY_CURRENT_BRANCH],
                            merge_item[KEY_NEXT_BRANCH],
                            merge_item[KEY_REV_START],
                            merge_item[KEY_REV_START], NA, NA,
                            file_in_commit + ' ' + merge_item[KEY_AUTHOR])
                mergeconf.LOGGER.debug(
                    'its a ' + file_in_commit + ' commit and author is ' +
                    merge_item[KEY_AUTHOR] +
                    ' therefore not merging please verify no other commits with this '
                    + merge_item[KEY_CURRENT_BRANCH] + ' to: ' +
                    merge_item[KEY_NEXT_BRANCH] + ' revision: ' +
                    str(merge_item[KEY_REV_START]))
                status = True
                break
    return status
Example #6
0
def handle_excluded_cur_branch(merge_item):
    f_excluded = False
    if is_excluded(merge_item[KEY_CURRENT_BRANCH]):
        mergeconf.LOGGER.debug(merge_item[KEY_CURRENT_BRANCH] +
                               " is in exclusion")
        audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR],
                    merge_item[KEY_CURRENT_BRANCH],
                    merge_item[KEY_NEXT_BRANCH], merge_item[KEY_REV_START],
                    merge_item[KEY_REV_START], NA, NA, AUDIT_EXPL_EXCLUDED)
        mailutils.mail(
            mergeconf.get_dl(merge_item[KEY_AUTHOR], mergeconf.ENUM_EXCLUDED),
            get_subject_excluded(merge_item[KEY_CURRENT_BRANCH]),
            get_text_excluded(merge_item[KEY_REV_START],
                              merge_item[KEY_CURRENT_BRANCH],
                              merge_item[KEY_LOOK_RESULT],
                              merge_item[KEY_MESSAGE], merge_item[KEY_AUTHOR]))
        f_excluded = True
    return f_excluded
Example #7
0
def is_automatic_allowed(merge_item):
    is_allowed = True
    if not mergeconf.IS_AUTOMATIC and not merge_item[KEY_IS_MANUAL]:
        mergeconf.LOGGER.debug("Automatic merge is not allowed")
        audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR],
                    merge_item[KEY_CURRENT_BRANCH],
                    merge_item[KEY_NEXT_BRANCH], merge_item[KEY_REV_START],
                    merge_item[KEY_REV_START], NA, NA,
                    AUDIT_EXPL_AUTO_NOT_ALLOWED)
        mailutils.mail(
            mergeconf.get_dl(merge_item[KEY_AUTHOR], mergeconf.ENUM_EXCLUDED),
            get_auto_not_allowed_subject(merge_item[KEY_NEXT_BRANCH]),
            get_auto_not_allowed_text(merge_item[KEY_REV_START],
                                      merge_item[KEY_CURRENT_BRANCH],
                                      merge_item[KEY_LOOK_RESULT],
                                      merge_item[KEY_MESSAGE],
                                      merge_item[KEY_AUTHOR]))
        is_allowed = False
    return is_allowed
Example #8
0
def handle_code_freeze_cur_branch(merge_item):
    """If branch is in code freeze send an email if commit was made to it, otherwise
        do not merge into it.
        
        Args:
            merge_item: Details of commit to be merged.
    """
    if is_code_freeze(merge_item[KEY_CURRENT_BRANCH], mergeconf.BRANCHES_IN_CODE_FREEZE):
        mergeconf.LOGGER.debug(merge_item[KEY_CURRENT_BRANCH] + " is in code freeze")
        audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR], merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_NEXT_BRANCH], 
                    merge_item[KEY_REV_START], merge_item[KEY_REV_START], NA, NA,
                    AUDIT_EXPL_CODE_FREEZE)
        mailutils.mail(mergeconf.get_dl(merge_item[KEY_AUTHOR], mergeconf.ENUM_CODE_FREEZE),
                       'Commit made to branch ' + merge_item[KEY_CURRENT_BRANCH] + 
                       ' which is below code freeze branch',
                       'Commit made to branch ' + merge_item[KEY_CURRENT_BRANCH] + 
                       ' which is below code freeze branch\r\n' + 'By: ' + merge_item[KEY_AUTHOR] + '\r\n' + 
                       'Revision: ' + merge_item[KEY_REV_START] + '\r\n' + 'Message: ' + merge_item[KEY_MESSAGE] + '\r\n' + 
                       merge_item[KEY_LOOK_RESULT]
        )
Example #9
0
def is_nomerge_key(revstart, current_branch, next_branch, message):
    """Check if commit message has no merge keyword in it.
        In that case we would not be interested in doing auto merging.
        
        Args:
            revstart: Revision for original commit.
            current_branch: The branch on which a commit has been performed.
            next_branch: The branch we are supposed to perform auto merging into.
            message: The message the user has committed with.
        Retruns:
            True if no merge key was found otherwise false.
    """
    is_nomerge = False
    if message.find(NOMERGE_KEY) != -1:
        audit_write(AUDIT_OP_MERGE, NA, current_branch, next_branch, revstart, revstart, NA, NA, NOMERGE_KEY)
        mergeconf.LOGGER.debug(
                NOMERGE_KEY + ' keyword found in commit, not merging from ' + current_branch + ' to: ' + next_branch + ' revision: ' + revstart
        )
        is_nomerge = True
    return is_nomerge
Example #10
0
def handle_code_freeze_next_branch(merge_item):
    """In case of code freeze do not merge, however send an 
    email notification that a commit was taking place into a code freeze branch.
        
        Args:
            merge_item: Details of commit to be merged.
    """
    in_freeze = False
    if is_code_freeze(merge_item[KEY_CURRENT_BRANCH], mergeconf.BRANCHES_IN_CODE_FREEZE):
        mergeconf.LOGGER.debug(merge_item[KEY_NEXT_BRANCH] + " is in code freeze")
        audit_write(AUDIT_OP_MERGE, merge_item[KEY_AUTHOR], merge_item[KEY_NEXT_BRANCH], 
                    merge_item[KEY_NEXT_BRANCH], merge_item[KEY_REV_START], merge_item[KEY_REV_START], NA, NA,
                    AUDIT_EXPL_CODE_FREEZE)
        mailutils.mail(mergeconf.get_dl(merge_item[KEY_AUTHOR], mergeconf.ENUM_CODE_FREEZE),
                       get_nextbranch_codefreeze_subject(merge_item[KEY_NEXT_BRANCH]),
                       get_nextbranch_codefreeze_text(merge_item[KEY_REV_START], 
                                                      merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_LOOK_RESULT], 
                                                      merge_item[KEY_NEXT_BRANCH], merge_item[KEY_MESSAGE],
                                                      merge_item[KEY_AUTHOR]))
        in_freeze = True
    return in_freeze
Example #11
0
def is_nomerge_key(revstart, current_branch, next_branch, message):
    """Check if commit message has no merge keyword in it.
        In that case we would not be interested in doing auto merging.
        
        Args:
            revstart: Revision for original commit.
            current_branch: The branch on which a commit has been performed.
            next_branch: The branch we are supposed to perform auto merging into.
            message: The message the user has committed with.
        Retruns:
            True if no merge key was found otherwise false.
    """
    is_nomerge = False
    if message.find(NOMERGE_KEY) != -1:
        audit_write(AUDIT_OP_MERGE, NA, current_branch, next_branch, revstart,
                    revstart, NA, NA, NOMERGE_KEY)
        mergeconf.LOGGER.debug(NOMERGE_KEY +
                               ' keyword found in commit, not merging from ' +
                               current_branch + ' to: ' + next_branch +
                               ' revision: ' + revstart)
        is_nomerge = True
    return is_nomerge
Example #12
0
def are_commit_files_to_ignore(merge_item):
    """Check if to ignore this commit for auto merging based on the files which were committed.
        
        Args:
            files_to_ignore: If any of the files committed is in this list in conjunction with authors, do not merge.
            with_authors_to_ignore: If the files in conjunction with these authors were committed then do not auto merge.
            revstart: Revision for original commit.
            current_branch_name: The branch on which a commit has been performed.
            next_branch_name: The branch we are supposed to perform auto merging into.
            lookresult: The result fro svn look on this commit.
            author: The one who performed this commit
        Retruns:
            True means to ignore this commit for merging.
    """
    status = False
    if merge_item[KEY_FILES_TO_IGNORE] is not None:
        for file_in_commit in merge_item[KEY_FILES_TO_IGNORE]:
            loggerutils.log(LOGGER,"are_commit_files_to_ignore: author: " + merge_item[KEY_AUTHOR])
            loggerutils.log(LOGGER,"are_commit_files_to_ignore: with_authors_to_ignore: " + str(merge_item[KEY_AUTHORS_TO_IGNORE]))
            loggerutils.log(LOGGER,"lookresult: " + merge_item[KEY_LOOK_RESULT]
            + " checking if file_in_commit " + file_in_commit +
            " is in filestoignore: " + str(merge_item[KEY_FILES_TO_IGNORE]) + " : " +
            str(merge_item[KEY_LOOK_RESULT].find(file_in_commit)) +
            " and if author: " + merge_item[KEY_AUTHOR] +
            " is in authors to ignore: " + str(merge_item[KEY_AUTHORS_TO_IGNORE]) +
            " : " + str(merge_item[KEY_AUTHOR] in merge_item[KEY_AUTHORS_TO_IGNORE]))
            if merge_item[KEY_LOOK_RESULT].find(file_in_commit) != -1 and merge_item[KEY_AUTHOR] in merge_item[KEY_AUTHORS_TO_IGNORE]:
                audit_write(AUDIT_OP_MERGE, NA, merge_item[KEY_CURRENT_BRANCH], merge_item[KEY_NEXT_BRANCH], 
                            merge_item[KEY_REV_START], merge_item[KEY_REV_START], NA, NA,
                            file_in_commit + ' ' + merge_item[KEY_AUTHOR])
                mergeconf.LOGGER.debug('its a ' + file_in_commit + ' commit and author is ' + merge_item[KEY_AUTHOR] + 
                        ' therefore not merging please verify no other commits with this ' + 
                        merge_item[KEY_CURRENT_BRANCH] + ' to: ' + merge_item[KEY_NEXT_BRANCH] + ' revision: ' + str(merge_item[KEY_REV_START]))
                status = True
                break
    return status