Skip to content

Commit 1c10ca3

Browse files
committed
feat: 支持强制 reinit head
1 parent f9612a0 commit 1c10ca3

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ export class AtomGitAPIService implements ICodeAPIService {
8989
});
9090
if (tokenResult && tokenResult.access_token) {
9191
this.helper.ATOMGIT_TOKEN = tokenResult.access_token;
92-
resolve(true);
93-
return;
92+
this.helper.reinitializeCodeService(true);
9493
}
95-
resolve(false);
94+
resolve(true);
9695
}
9796
} catch (error) {
9897
reject(error);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ export class HelperService {
104104
this.commandService.executeCommand(`workbench.view.${id}`);
105105
}
106106

107-
reinitializeCodeService() {
108-
this.commandService.executeCommand('code-service.reinitialize');
107+
reinitializeCodeService(isForce: boolean = false) {
108+
this.commandService.executeCommand('code-service.reinitialize', isForce);
109109
}
110110

111111
showMessage(

packages/code-service/src/code-model.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ export class CodeModelService {
8989
/**
9090
* 无权限时需要再设置 token 后重新初始化
9191
*/
92-
async reinitialize() {
92+
async reinitialize(isForce?: boolean) {
9393
const { codeServiceConfig: config } = this;
9494
await this.rootRepository.initHEAD({
9595
commit: config.commit,
9696
ref: config.branch || config.tag || config.ref,
9797
refPath: config.refPath,
98+
isForce
9899
});
99100
}
100101

packages/code-service/src/code-service.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ export class CodeContribution
327327
}),
328328

329329
commandRegistry.registerCommand(CODE_SERVICE_COMMANDS.REINITIALIZE, {
330-
execute: () => {
331-
this.codeModel.reinitialize();
330+
execute: (isForce?: boolean) => {
331+
this.codeModel.reinitialize(isForce);
332332
},
333333
}),
334334
commandRegistry.registerCommand(CODE_SERVICE_COMMANDS.CREATEBRANCH, {

packages/code-service/src/repository.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class RootRepository extends Repository {
145145
private _onDidChangeRef = new Emitter<void>();
146146
readonly onDidChangeRef = this._onDidChangeRef.event;
147147

148-
private _initialized = false;
148+
public _initialized = false;
149149

150150
private _refs: Refs = { branches: [], tags: [] };
151151
get refs() {
@@ -194,8 +194,8 @@ export class RootRepository extends Repository {
194194
* @param ref tag, branch
195195
* @param refPath [tree|blob]/branch/path
196196
*/
197-
async initHEAD({ commit, ref, refPath }: { commit?: string; ref?: string; refPath?: string }) {
198-
if (this._initialized) {
197+
async initHEAD({ commit, ref, refPath, isForce }: { commit?: string; ref?: string; refPath?: string, isForce?: boolean }) {
198+
if (this._initialized && !isForce) {
199199
return;
200200
}
201201
this._initialized = true;

0 commit comments

Comments
 (0)