-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 【功能优化】改进提交消息生成后的处理流程 - 【新增功能】添加命令行SVN支持 - 【文案优化】更新中英文提示信息,使其更准确清晰 - 【SCM检测】增加目录结构和系统命令检测功能 - 【错误处理】完善写入失败时的降级策略 - 【国际化】新增多个本地化文案条目
- Loading branch information
1 parent
d0f22e8
commit d92553e
Showing
5 changed files
with
162 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { exec } from "child_process"; | ||
import { promisify } from "util"; | ||
import { ISCMProvider } from "./SCMProvider"; | ||
import { LocalizationManager } from "../utils/LocalizationManager"; | ||
|
||
const execAsync = promisify(exec); | ||
|
||
export class CliSvnProvider implements ISCMProvider { | ||
type: "svn" = "svn"; | ||
private workspaceRoot: string; | ||
|
||
constructor(workspaceRoot: string) { | ||
this.workspaceRoot = workspaceRoot; | ||
} | ||
|
||
async isAvailable(): Promise<boolean> { | ||
try { | ||
await execAsync("svn --version"); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
||
async getDiff(files?: string[]): Promise<string | undefined> { | ||
try { | ||
const filePaths = files?.join(" ") || "."; | ||
const { stdout } = await execAsync(`svn diff ${filePaths}`, { | ||
cwd: this.workspaceRoot, | ||
}); | ||
return stdout; | ||
} catch (error) { | ||
console.error("Failed to get SVN diff:", error); | ||
return undefined; | ||
} | ||
} | ||
|
||
async commit(message: string, files?: string[]): Promise<void> { | ||
const filePaths = files?.join(" ") || "."; | ||
await execAsync(`svn commit -m "${message}" ${filePaths}`, { | ||
cwd: this.workspaceRoot, | ||
}); | ||
} | ||
|
||
// 由于是命令行方式,这两个方法可能用不到,但需要实现接口 | ||
async setCommitInput(message: string): Promise<void> { | ||
throw new Error( | ||
LocalizationManager.getInstance().getMessage( | ||
"cli.commit.input.not.supported" | ||
) | ||
); | ||
} | ||
|
||
async getCommitInput(): Promise<string> { | ||
return ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters