Skip to content

Commit c3e7717

Browse files
committed
feat: update depot list api
1 parent d9efc90 commit c3e7717

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/init.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ export function registerCommands(context: IContext) {
2020
registerCommand('codingPlugin.pickDepot', async function () {
2121
const options: IQuickPickOption[] = [];
2222
context.depots.forEach((depot: IDepot) => {
23+
const { name, depotPath } = depot;
24+
const project = depotPath.match(/\/p\/([^/]+)\//)?.[1];
2325
options.push({
24-
label: depot.name,
26+
label: name,
27+
description: `(project: ${project})`,
2528
depot,
2629
});
2730
});

src/services/codingServer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'fs';
33
import qs from 'querystring';
44
import axios from '../utils/axios';
55
import git from 'isomorphic-git';
6-
import { IRepoInfo, ISessionData } from '../typings/common';
6+
import { IDepot, IRepoInfo, ISessionData } from '../typings/common';
77
import { parseCloneUrl } from '../utils/repo';
88
import toast from '../utils/toast';
99

@@ -99,20 +99,20 @@ export default class CodingServer {
9999
}
100100
}
101101

102-
async getDepotList(team: string, project: string) {
103-
// TODO: 使用新接口
102+
async getDepotList(team: string) {
104103
try {
105104
const result = await axios({
106105
method: 'get',
107-
url: `https://${team}.coding.net/api/user/${team}/project/${project}/repos`,
106+
url: `https://${team}.coding.net/api/user/${team}/depots`,
108107
headers: this.getHeaders(),
109108
});
110109

111110
if (result.code) {
112111
return Promise.reject(result);
113112
}
114113

115-
return result?.data?.depots || [];
114+
const depots = result?.data || [];
115+
return depots.filter((depot: IDepot) => depot.vcsType === 'git');
116116
} catch (err) {
117117
console.error(err);
118118
}

src/trees/depotMR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class DepotMRTreeDataProvider extends hx.TreeDataProvider {
6969

7070
async getData(repoInfo?: IRepoInfo) {
7171
const { codingServer } = this.context;
72-
const promises = [codingServer.getDepotList(this.user.team, this.context.repoInfo?.project)];
72+
const promises = [codingServer.getDepotList(this.user.team)];
7373
if (repoInfo) {
7474
promises.push(codingServer.getMrList(repoInfo));
7575
}

0 commit comments

Comments
 (0)