def mergeBack(requestInfo): ''' 分支合并入回来源分支 ''' projectId = int(requestInfo['projectId']) if 'projectId' in requestInfo else 0 project = Project.objects.get(id=projectId) if projectId > 0 else None if project: result, message, gitOutputs = Git.mergeToBranch(project.branch, project.parent.branch if project.parent else project.branch) if result: project.setStatus(5) return result, message, gitOutputs else: return False, '参数错误', gitOutputs
def merge_to_master(requestInfo): """ """ branch_name = requestInfo["branchName"] if "branchName" in requestInfo else "" branch_name = branch_name.strip() branch_type = requestInfo["which"] if "which" in requestInfo else "" type1 = requestInfo["type"] if "type" in requestInfo else "" print (branch_name) start = branch_name.find("-") end = start + 6 branch_id = branch_name[start + 1 : end] if "pmt" in branch_name: bt = 1 else: bt = 2 try: branch = Project.objects.filter(relatedId=branch_id, type=bt)[0] branch_desc = branch.name if str(bt) == "1": plist_id = branch.id else: plist_id = 0 if "(" in branch_desc: branch_desc = branch_desc.replace("(", "") if ")" in branch_desc: branch_desc = branch_desc.replace(")", "") if "(" in branch_desc: branch_desc = branch_desc.replace("(", "") if ")" in branch_desc: branch_desc = branch_desc.replace(")", "") except: branch_desc = "" if not branch_name: return "请输入分支名" # if branch_type not in branch_name: # message = '分支名:'+branch_name+"当前仓库:"+branch_type+'不匹配。请去对应的页面做操作。' # return message if ( "api" not in branch_type and "java" not in branch_type and "_chat" not in branch_type and "cms" not in branch_type ): try: if_check = BranchDiff.objects.filter(branch_name=branch_name).order_by("-id")[0] if_check_status = if_check.status except: if_check_status = 0 else: if_check_status = 1 if str(if_check_status) == "1": message = Git.mergeToBranch(branch_name, branch_type, branch_desc) else: message = branch_name + "分支还没被check,请找开发check" def sha1(type): try: shellPath = settings.SHELL_PATH opResult = os.popen(shellPath + "get-sha1.sh %s" % (type)).read() sha = str(opResult) sha1 = sha[0:6] except: sha1 = "error" return sha1 if message == "合并成功": versionList = VersionList( version="", branch_type=type1, branch_name=branch_name, title=branch_desc, sha1=sha1(branch_type), if_on_beta=0, if_on_ga=0, first_create_ga_generator=0, last_create_ga_generator=0, status=0, back_num=0, branch_id=branch_id, plist_id=plist_id, ) versionList.save() branch_info = BranchInfo.objects.get(branch_name=branch_name) branch_info.status = 88 branch_info.save() if str(bt) == "1": ProjectModule.updateInfo(plist_id, branch_id) print (message) return message