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
def handle_success_merge(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_message, commit_merge_result): audit_write(AUDIT_OP_MERGE, author, current_branch_name, next_branch_name, revstart, revend, NA, NA, CSV_STATUS_MERGE_SUCCESS) rcommit = get_commit_rev_by_resp(commit_merge_result) try: mailutils.mail( mergeconf.get_dl(author, mergeconf.ENUM_MERGE), get_merge_success_subject(current_branch_name, next_branch_name, author, rev_as_str), get_merge_success_text(current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result), mergeconf.MAIL_ENABLED) except: LOGGER.error( "Please check mail configuration, failed sending email...") add_row( { mergeconf.TYPE_COL: SPREADSHEET_MERGE, 'who': SPREADSHEET_AUTHOR_PREFIX + author, 'frombranch': current_branch_name, 'tobranch': next_branch_name, 'rfrom': revstart, 'rend': revend, 'rcommit': rcommit, 'bugid': mergeconf.ISSUE_ID_DEFAULT_VALUE, 'details': commit_message }, mergeconf.SPREADSHEET_USERNAME, mergeconf.SPREADSHEET_PASSWORD, mergeconf.SPREADSHEET_KEY, mergeconf.SPREADSHEET_WORKSHEET_ID, mergeconf.APP_KEY)
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])
def handle_merge_failed(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result): mergeconf.LOGGER.debug('merge failed') try: mailutils.mail( mergeconf.get_dl(author, mergeconf.ENUM_MERGE), get_failed_mergecommit_subject(current_branch_name, next_branch_name, author, rev_as_str), get_failed_mergecommit_text(current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result), mergeconf.MAIL_ENABLED) except: LOGGER.error( "Please check mail configuration, failed sending email...") audit_write(AUDIT_OP_MERGE, author, current_branch_name, next_branch_name, revstart, revend, NA, NA, AUDIT_RES_FAILED_CONFLICT) add_row( { mergeconf.TYPE_COL: SPREADSHEET_MERGE_FAILED, 'who': SPREADSHEET_AUTHOR_PREFIX + author, 'frombranch': current_branch_name, 'tobranch': next_branch_name, 'rfrom': revstart, 'rend': revend, 'rcommit': NA, 'bugid': mergeconf.ISSUE_ID_DEFAULT_VALUE, 'details': SPREADSHEET_CONFLICT_MSG }, mergeconf.SPREADSHEET_USERNAME, mergeconf.SPREADSHEET_PASSWORD, mergeconf.SPREADSHEET_KEY, mergeconf.SPREADSHEET_WORKSHEET_ID, mergeconf.APP_KEY)
def handle_success_merge(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_message, commit_merge_result): audit_write(AUDIT_OP_MERGE, author, current_branch_name, next_branch_name, revstart, revend, NA, NA, CSV_STATUS_MERGE_SUCCESS) rcommit = get_commit_rev_by_resp(commit_merge_result) try: mailutils.mail(mergeconf.get_dl(author, mergeconf.ENUM_MERGE), get_merge_success_subject(current_branch_name, next_branch_name, author, rev_as_str), get_merge_success_text(current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result), mergeconf.MAIL_ENABLED) except: LOGGER.error("Please check mail configuration, failed sending email...") add_row({mergeconf.TYPE_COL:SPREADSHEET_MERGE, 'who':SPREADSHEET_AUTHOR_PREFIX + author, 'frombranch':current_branch_name, 'tobranch':next_branch_name, 'rfrom':revstart, 'rend':revend, 'rcommit':rcommit, 'bugid':mergeconf.ISSUE_ID_DEFAULT_VALUE, 'details':commit_message}, mergeconf.SPREADSHEET_USERNAME, mergeconf.SPREADSHEET_PASSWORD, mergeconf.SPREADSHEET_KEY, mergeconf.SPREADSHEET_WORKSHEET_ID, mergeconf.APP_KEY)
def handle_merge_failed(revstart, revend, current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result): mergeconf.LOGGER.debug('merge failed') try: mailutils.mail(mergeconf.get_dl(author, mergeconf.ENUM_MERGE), get_failed_mergecommit_subject(current_branch_name, next_branch_name, author, rev_as_str), get_failed_mergecommit_text(current_branch_name, next_branch_name, message, author, rev_as_str, commit_merge_result), mergeconf.MAIL_ENABLED) except: LOGGER.error("Please check mail configuration, failed sending email...") audit_write(AUDIT_OP_MERGE, author, current_branch_name, next_branch_name, revstart, revend, NA, NA, AUDIT_RES_FAILED_CONFLICT) add_row({mergeconf.TYPE_COL:SPREADSHEET_MERGE_FAILED, 'who':SPREADSHEET_AUTHOR_PREFIX + author, 'frombranch':current_branch_name, 'tobranch':next_branch_name, 'rfrom':revstart, 'rend':revend, 'rcommit':NA, 'bugid':mergeconf.ISSUE_ID_DEFAULT_VALUE, 'details':SPREADSHEET_CONFLICT_MSG}, mergeconf.SPREADSHEET_USERNAME, mergeconf.SPREADSHEET_PASSWORD, mergeconf.SPREADSHEET_KEY, mergeconf.SPREADSHEET_WORKSHEET_ID, mergeconf.APP_KEY)
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
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
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
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
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] )
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