fix(repos): 修复在全新的工作目录中,检出指定commit时,找不到commit.
This commit is contained in:
@@ -26,8 +26,14 @@ export class ReposService {
|
||||
);
|
||||
}
|
||||
|
||||
async lockWorkspace(workspaceRoot: string) {
|
||||
// TODO: 获取锁,失败抛错。
|
||||
}
|
||||
|
||||
async getGit(project: Project) {
|
||||
const workspaceRoot = this.getWorkspaceRoot(project);
|
||||
await this.lockWorkspace(workspaceRoot);
|
||||
|
||||
const firstInit = await access(workspaceRoot, F_OK)
|
||||
.then(() => false)
|
||||
.catch(async () => {
|
||||
@@ -83,12 +89,13 @@ export class ReposService {
|
||||
async checkoutCommit(project: Project, commitNumber: string) {
|
||||
const git = await this.getGit(project);
|
||||
try {
|
||||
await git.checkout([commitNumber]);
|
||||
await git.fetch(DEFAULT_REMOTE_NAME);
|
||||
} catch (err) {
|
||||
if (err.message.includes("couldn't find remote ref nonexistent")) {
|
||||
throw new NotFoundException(err.message);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
await git.checkout([commitNumber]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user