From b6b19eabe92fba29b8632a7eaca7217105fee844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Mon, 18 Oct 2021 17:28:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=93=E5=BA=93=E4=B8=8D=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E8=B0=83=E7=94=A8compare=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Merge/CreateMerge.js | 65 +++++++++++++++++----------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/src/forge/Merge/CreateMerge.js b/src/forge/Merge/CreateMerge.js index c335d79fd..b766c023e 100644 --- a/src/forge/Merge/CreateMerge.js +++ b/src/forge/Merge/CreateMerge.js @@ -150,7 +150,7 @@ class CreateMerge extends Component { }else{ if(pullOwner === mergeOwner){ if (!noMergeBranch) { - this.compareProject(result.data.id, branchParams); + this.compareProject(true, branchParams); } else { this.setState({ showMessage: true, @@ -172,53 +172,51 @@ class CreateMerge extends Component { }; // compare接口,获取分支对比信息 - compareProject = (baseid, branchParams) => { + compareProject = (sameProject, branchParams) => { // const { project } = this.props; // const { owner, projectsId } = this.props.match.params; - const projectObj = this.props.project; const { pullOwner, pullBranch, mergeOwner, mergeBranch, projectId } = branchParams; let url = `/${mergeOwner}/${projectId}/compare`; - if (projectObj) { - if (baseid === projectObj.id) { - url += `/${pullBranch}...${mergeBranch}.json`; - } else { - url += `/${mergeBranch}...${pullOwner}/${projectId}:${pullBranch}.json`; - } - this.setState({ isSpin: false, isCompareSpin: true }); - axios - .get(url) - .then((result) => { - if (result) { - if (result.data.status === 0) { - this.setState({ - showMessage: false, - }); - } else { - this.setState({ - showMessage: true, - defaultMessage: result.data.message, - }); - } + if (sameProject) { + url += `/${pullBranch}...${mergeBranch}.json`; + } else { + url += `/${mergeBranch}...${pullOwner}/${projectId}:${pullBranch}.json`; + } + this.setState({ isSpin: false, isCompareSpin: true }); + axios + .get(url) + .then((result) => { + if (result) { + if (result.data.status === 0) { this.setState({ - comparesData: result.data, + showMessage: false, + }); + } else { + this.setState({ + showMessage: true, + defaultMessage: result.data.message, }); } this.setState({ - isFirstLoading: false, - isSpin: false, - isCompareSpin: false, + comparesData: result.data, }); - }) - .catch((error) => { - this.setState({ isSpin: false, isCompareSpin: false }); + } + this.setState({ + isFirstLoading: false, + isSpin: false, + isCompareSpin: false, }); - } + }) + .catch((error) => { + this.setState({ isSpin: false, isCompareSpin: false }); + }); }; // 根据所有者、仓库名,获取分支列表,目前仅涉及目标仓库分支查询 - getBranchList = ({ mergeOwner, projectId, mergeBranch }) => { + getBranchList = (branchParams) => { + const { mergeOwner, projectId, mergeBranch } = branchParams; this.setState({ isSpin: true }); const url = `/${mergeOwner}/${projectId}/pulls/get_branches.json`; axios @@ -234,6 +232,7 @@ class CreateMerge extends Component { defaultMessage: '目标分支不存在', isCompareSpin: false, }); + !noMergeBranch && this.compareProject(false, branchParams); } this.setState({ isSpin: false }); })