Skip to content

Commit 6bbba76

Browse files
committed
chore: 新增 project 接口
1 parent 78bfaa9 commit 6bbba76

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

packages/code-api/src/atomgit/atomgit.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class AtomGitAPIService implements ICodeAPIService {
133133
return branches.map((data) => ({
134134
name: data.name,
135135
commit: {
136-
id: data.sha
136+
id: data.commit.sha
137137
},
138138
protected: data.protected
139139
}));
@@ -223,9 +223,10 @@ export class AtomGitAPIService implements ICodeAPIService {
223223
}
224224

225225
public async getProject(repo: IRepositoryModel): Promise<Project> {
226+
const repoInfo = await this.request<API.ResponseRepoInfo>(`/repos/${this.getProjectPath(repo)}`);
226227
return {
227-
id: 'atomgit_mock',
228-
default_branch: 'main'
228+
id: repoInfo.name,
229+
default_branch: repoInfo.default_branch
229230
};
230231
}
231232
canResolveConflict(_repo: IRepositoryModel, _sourceBranch: string, _targetBranch: string, _prId: string): Promise<ConflictAPI.CanResolveConflictResponse> {

packages/code-api/src/atomgit/types.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export namespace API {
2020

2121
export interface ResponseBranchesInfo {
2222
name: string;
23-
sha: string;
23+
commit: {
24+
sha: string;
25+
};
2426
protected: boolean
2527
}
2628

@@ -41,4 +43,9 @@ export namespace API {
4143
sha: string
4244
}
4345
}
46+
47+
export interface ResponseRepoInfo {
48+
name: string;
49+
default_branch: string;
50+
}
4451
}

0 commit comments

Comments
 (0)