1 Star 0 Fork 0

CC/clean-git

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
extension.js 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
CC 提交于 2023-11-06 11:40 +08:00 . ✨ feat(git检测): 新增检测master分支
const vscode = require("vscode");
const simpleGit = require("simple-git");
const { checkGitFile } = require("./fs-service/operaFile.js");
const workspace = vscode.workspace;
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
const cleanGit = vscode.commands.registerCommand(
"cleanLocalBranch",
async () => {
const projectRoot = workspace.workspaceFolders[0].uri.fsPath || "";
// 使用 simple-git 或其他 Git 库来获取根目录下的分支信息
// @ts-ignore
const git = simpleGit(projectRoot);
git.branch(async (err, branchSummary) => {
if (err) {
console.error("Failed to get branch information:", err);
return;
}
const currentBranch = branchSummary.current;
if (currentBranch !== "master") {
vscode.window.showErrorMessage("请先切换到默认分支,例如master");
return;
} else {
const isDefaultBranch = await vscode.window.showInformationMessage(
"当前分支是否已经为默认分支?",
"",
""
);
if (isDefaultBranch === "") {
vscode.window.showErrorMessage("请先切换到默认分支,例如master");
} else {
await checkGitFile(projectRoot, vscode);
// 在 checkGitFile 完成后执行 git pull 命令
const gitCommand = "git pull origin";
const terminal =
vscode.window.activeTerminal || vscode.window.createTerminal();
terminal.sendText(gitCommand);
}
}
});
}
);
context.subscriptions.push(cleanGit);
}
function deactivate() {}
module.exports = {
activate,
deactivate,
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/cc-2018_admin/clean-git.git
git@gitee.com:cc-2018_admin/clean-git.git
cc-2018_admin
clean-git
clean-git
master

搜索帮助