仓库不同时调用compare接口

This commit is contained in:
谢思 2021-10-18 17:28:40 +08:00
parent 3e3e9f3681
commit b6b19eabe9
1 changed files with 32 additions and 33 deletions

View File

@ -150,7 +150,7 @@ class CreateMerge extends Component {
}else{ }else{
if(pullOwner === mergeOwner){ if(pullOwner === mergeOwner){
if (!noMergeBranch) { if (!noMergeBranch) {
this.compareProject(result.data.id, branchParams); this.compareProject(true, branchParams);
} else { } else {
this.setState({ this.setState({
showMessage: true, showMessage: true,
@ -172,16 +172,14 @@ class CreateMerge extends Component {
}; };
// compare接口获取分支对比信息 // compare接口获取分支对比信息
compareProject = (baseid, branchParams) => { compareProject = (sameProject, branchParams) => {
// const { project } = this.props; // const { project } = this.props;
// const { owner, projectsId } = this.props.match.params; // const { owner, projectsId } = this.props.match.params;
const projectObj = this.props.project;
const { pullOwner, pullBranch, mergeOwner, mergeBranch, projectId } = const { pullOwner, pullBranch, mergeOwner, mergeBranch, projectId } =
branchParams; branchParams;
let url = `/${mergeOwner}/${projectId}/compare`; let url = `/${mergeOwner}/${projectId}/compare`;
if (projectObj) { if (sameProject) {
if (baseid === projectObj.id) {
url += `/${pullBranch}...${mergeBranch}.json`; url += `/${pullBranch}...${mergeBranch}.json`;
} else { } else {
url += `/${mergeBranch}...${pullOwner}/${projectId}:${pullBranch}.json`; url += `/${mergeBranch}...${pullOwner}/${projectId}:${pullBranch}.json`;
@ -214,11 +212,11 @@ class CreateMerge extends Component {
.catch((error) => { .catch((error) => {
this.setState({ isSpin: false, isCompareSpin: false }); this.setState({ isSpin: false, isCompareSpin: false });
}); });
}
}; };
// 根据所有者、仓库名,获取分支列表,目前仅涉及目标仓库分支查询 // 根据所有者、仓库名,获取分支列表,目前仅涉及目标仓库分支查询
getBranchList = ({ mergeOwner, projectId, mergeBranch }) => { getBranchList = (branchParams) => {
const { mergeOwner, projectId, mergeBranch } = branchParams;
this.setState({ isSpin: true }); this.setState({ isSpin: true });
const url = `/${mergeOwner}/${projectId}/pulls/get_branches.json`; const url = `/${mergeOwner}/${projectId}/pulls/get_branches.json`;
axios axios
@ -234,6 +232,7 @@ class CreateMerge extends Component {
defaultMessage: '目标分支不存在', defaultMessage: '目标分支不存在',
isCompareSpin: false, isCompareSpin: false,
}); });
!noMergeBranch && this.compareProject(false, branchParams);
} }
this.setState({ isSpin: false }); this.setState({ isSpin: false });
}) })