File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ export class AntCodeAPIService implements ICodeAPIService {
147147 }
148148 }
149149
150- private getProjectId ( repo : IRepositoryModel ) {
150+ getProjectId ( repo : IRepositoryModel ) {
151151 return `${ repo . owner } %2F${ repo . name } ` ;
152152 }
153153
Original file line number Diff line number Diff line change @@ -94,11 +94,32 @@ export default class CodeAPIService extends AntCodeAPIService {
9494 }
9595 }
9696
97- mergeBase (
97+ /*
98+ * 获取两个分支 的共同祖先
99+ * 类似于 git merge-base branch1 branch2
100+ * 接口暂时只支持查询两个分支
101+ */
102+ async mergeBase (
98103 repo : IRepositoryModel ,
99104 target : string ,
100105 source : string
101106 ) : Promise < API . ResponseCommit > {
102- throw new Error ( 'Method not implemented.' ) ;
107+ let url = `/api/v4/projects/${ this . getProjectId (
108+ repo
109+ ) } /repository/merge_base?refs[]=${ target } &refs[]=${ source } `;
110+ if ( this . config . endpoint ) {
111+ url = createUrl ( this . config . endpoint , url ) ;
112+ }
113+ const urlInstance = new URL ( url , location . origin ) ;
114+ const privateToken = this . PRIVATE_TOKEN ;
115+ return (
116+ await fetch ( urlInstance . toString ( ) , {
117+ method : 'GET' ,
118+ headers : {
119+ ...( privateToken ? { 'PRIVATE-TOKEN' : privateToken } : { } ) ,
120+ ...webgwRequestOpts ,
121+ } ,
122+ } )
123+ ) . json ( ) ;
103124 }
104- }
125+ }
You can’t perform that action at this time.
0 commit comments