0.1.1
This commit is contained in:
parent
b4a04ae19d
commit
ed6154a974
4 changed files with 158 additions and 159 deletions
|
|
@ -6,6 +6,12 @@ All notable changes to the "dwm-git-simpleuse" extension will be documented in t
|
||||||
|
|
||||||
- Task API
|
- Task API
|
||||||
- no git warnings as errors
|
- no git warnings as errors
|
||||||
|
- progress bar for git commands
|
||||||
|
|
||||||
|
## [0.1.1] - 2024-07-11
|
||||||
|
|
||||||
|
- fixed "initialize existing repository" command
|
||||||
|
- renamed commands with "gitDWM : " prefix
|
||||||
|
|
||||||
## [0.1.0] - 2024-04-10
|
## [0.1.0] - 2024-04-10
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
This extention is in beta, some errors may occur,
|
This extention is in beta, some errors may occur,
|
||||||
errors given through vscode notifications can be ignored for most of them,
|
errors given through vscode notifications can be ignored for most of them,
|
||||||
it needs and will improve over time.
|
it needs to and will improve over time.
|
||||||
|
|
|
||||||
200
extension.js
200
extension.js
|
|
@ -10,67 +10,65 @@ const chp = require("child_process");
|
||||||
* @param {vscode.ExtensionContext} context
|
* @param {vscode.ExtensionContext} context
|
||||||
*/
|
*/
|
||||||
function activate(context) {
|
function activate(context) {
|
||||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||||||
// This line of code will only be executed once when your extension is activated
|
// This line of code will only be executed once when your extension is activated
|
||||||
let lastGitCommitMsg = "";
|
let lastGitCommitMsg = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.chdir(vscode.workspace.workspaceFolders[0].uri.fsPath);
|
process.chdir(vscode.workspace.workspaceFolders[0].uri.fsPath);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
vscode.window.showErrorMessage(err);
|
vscode.window.showErrorMessage(err);
|
||||||
}
|
}
|
||||||
chp.execFile("git", ["pull"], (err, stdout, stderr) => {
|
chp.execFile("git", ["pull"], (err, stdout, stderr) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
vscode.window.showErrorMessage("GITPULL : " + err.message);
|
vscode.window.showErrorMessage("GITPULL : " + err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
vscode.window.showErrorMessage("GITPULL : " + stderr);
|
vscode.window.showErrorMessage("GITPULL : " + stderr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vscode.window.showInformationMessage("GITPULL : " + stdout);
|
vscode.window.showInformationMessage("GITPULL : " + stdout);
|
||||||
});
|
});
|
||||||
|
|
||||||
// The command has been defined in the package.json file
|
// The command has been defined in the package.json file
|
||||||
// Now provide the implementation of the command with registerCommand
|
// Now provide the implementation of the command with registerCommand
|
||||||
// The commandId parameter must match the command field in package.json
|
// The commandId parameter must match the command field in package.json
|
||||||
let disposable = vscode.commands.registerCommand(
|
let disposable = vscode.commands.registerCommand("dwm-git-simpleuse.fullPush", async function () {
|
||||||
"dwm-git-simpleuse.fullPush",
|
const gitCommitMsg = await vscode.window.showInputBox({
|
||||||
async function () {
|
placeHolder: "commit message",
|
||||||
const gitCommitMsg = await vscode.window.showInputBox({
|
prompt: "choose your commit message",
|
||||||
placeHolder: "commit message",
|
value: lastGitCommitMsg.incrementSuffixe(),
|
||||||
prompt: "choose your commit message",
|
});
|
||||||
value: lastGitCommitMsg.incrementSuffixe(),
|
if (gitCommitMsg === undefined) return;
|
||||||
});
|
gitCommitMsg.trim();
|
||||||
if (gitCommitMsg === undefined) return;
|
if (!gitCommitMsg.length) {
|
||||||
gitCommitMsg.trim();
|
vscode.window.showErrorMessage("commit message needed");
|
||||||
if (!gitCommitMsg.length) {
|
return;
|
||||||
vscode.window.showErrorMessage("commit message needed");
|
}
|
||||||
return;
|
lastGitCommitMsg = gitCommitMsg;
|
||||||
}
|
|
||||||
lastGitCommitMsg = gitCommitMsg;
|
|
||||||
|
|
||||||
chp.exec(
|
chp.exec(
|
||||||
`git add . && git commit -am '${gitCommitMsg}' && git pull && git push`,
|
`git add . && git commit -am '${gitCommitMsg}' && git pull && git push`,
|
||||||
{ cwd: vscode.workspace.workspaceFolders[0].uri.fsPath },
|
{ cwd: vscode.workspace.workspaceFolders[0].uri.fsPath },
|
||||||
(err, stdout, stderr) => {
|
(err, stdout, stderr) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
vscode.window.showErrorMessage(err.message);
|
vscode.window.showErrorMessage(err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
vscode.window.showErrorMessage(stderr);
|
vscode.window.showErrorMessage(stderr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vscode.window.showInformationMessage(stdout);
|
vscode.window.showInformationMessage(stdout);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
/* try {
|
/* try {
|
||||||
process.chdir(vscode.workspace.workspaceFolders[0].uri.fsPath);
|
process.chdir(vscode.workspace.workspaceFolders[0].uri.fsPath);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
vscode.window.showErrorMessage(err);
|
vscode.window.showErrorMessage(err);
|
||||||
} */
|
} */
|
||||||
/* chp.execFile("git", ["add", "*"], (err, stdout, stderr) => {
|
/* chp.execFile("git", ["add", "*"], (err, stdout, stderr) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
vscode.window.showErrorMessage("GITADD : " + err.message);
|
vscode.window.showErrorMessage("GITADD : " + err.message);
|
||||||
return;
|
return;
|
||||||
|
|
@ -96,65 +94,61 @@ function activate(context) {
|
||||||
vscode.window.showInformationMessage("GITCOM : " + stdout);
|
vscode.window.showInformationMessage("GITCOM : " + stdout);
|
||||||
}
|
}
|
||||||
); */
|
); */
|
||||||
}
|
});
|
||||||
);
|
context.subscriptions.push(disposable);
|
||||||
context.subscriptions.push(disposable);
|
|
||||||
|
|
||||||
disposable = vscode.commands.registerCommand(
|
disposable = vscode.commands.registerCommand("dwm-git-simpleuse.initRepo", async function () {
|
||||||
"dwm-git-simpleuse.initRepo",
|
const gitLink = await vscode.window.showInputBox({
|
||||||
async function () {
|
placeHolder: "git repo link",
|
||||||
const gitLink = await vscode.window.showInputBox({
|
prompt: "Initialize a git repository",
|
||||||
placeHolder: "git repo link",
|
value: await vscode.env.clipboard.readText(),
|
||||||
prompt: "Initialize a git repository",
|
});
|
||||||
value: await vscode.env.clipboard.readText(),
|
if (gitLink === undefined) return;
|
||||||
});
|
gitLink.trim();
|
||||||
if (gitLink === undefined) return;
|
if (!gitLink.match(/^https?:\/\/\S+\.git$/).length) {
|
||||||
gitLink.trim();
|
vscode.window.showErrorMessage("Link needed");
|
||||||
if (!gitLink.match(/^https?:\/\/\S+\.git$/).length) {
|
return;
|
||||||
vscode.window.showErrorMessage("Link needed");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let gitBranch = await vscode.window.showInputBox({
|
let gitBranch = await vscode.window.showInputBox({
|
||||||
placeHolder: "git branch",
|
placeHolder: "git branch",
|
||||||
prompt: "choose wich branch to use (defaults to 'main')",
|
prompt: "choose wich branch to use (defaults to 'main')",
|
||||||
value: "main",
|
value: "main",
|
||||||
});
|
});
|
||||||
if (gitBranch === undefined) return;
|
if (gitBranch === undefined) return;
|
||||||
gitBranch.trim();
|
gitBranch.trim();
|
||||||
if (!gitBranch.length) gitBranch = "main";
|
if (!gitBranch.length) gitBranch = "main";
|
||||||
|
|
||||||
chp.exec(
|
chp.exec(
|
||||||
`git init && git remote add origin ${gitLink} && git fetch && git reset origin/${gitBranch} && git branch --set-upstream-to=origin/${gitBranch}`,
|
`git init && git remote add origin ${gitLink} && git fetch && git checkout -t origin/${gitBranch}`,
|
||||||
{ cwd: vscode.workspace.workspaceFolders[0].uri.fsPath },
|
{ cwd: vscode.workspace.workspaceFolders[0].uri.fsPath },
|
||||||
(err, stdout, stderr) => {
|
(err, stdout, stderr) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
vscode.window.showErrorMessage(err.message);
|
vscode.window.showErrorMessage(err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
vscode.window.showErrorMessage(stderr);
|
vscode.window.showErrorMessage(stderr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vscode.window.showInformationMessage(stdout);
|
vscode.window.showInformationMessage(stdout);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
);
|
context.subscriptions.push(disposable);
|
||||||
context.subscriptions.push(disposable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method is called when your extension is deactivated
|
// This method is called when your extension is deactivated
|
||||||
function deactivate() {}
|
function deactivate() {}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
activate,
|
activate,
|
||||||
deactivate,
|
deactivate,
|
||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.incrementSuffixe = function () {
|
String.prototype.incrementSuffixe = function () {
|
||||||
//if there's no (\d+) at the end of the string, add "(1)" at the end if there's a (\d+) at the end of the string, increment it but keep the original string before it
|
if (this == "") return "";
|
||||||
return this.replace(/(\d+)?$/, function (match, p1) {
|
return this.replace(/(\d+)?$/, function (match, p1) {
|
||||||
return p1 === undefined ? "(1)" : `(${parseInt(p1) + 1})`;
|
return p1 === undefined ? "(1)" : `(${parseInt(p1) + 1})`;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
105
package.json
105
package.json
|
|
@ -1,55 +1,54 @@
|
||||||
{
|
{
|
||||||
"name": "dwm-git-simpleuse",
|
"name": "dwm-git-simpleuse",
|
||||||
"displayName": "DWM_git_simpleUse",
|
"displayName": "DWM_git_simpleUse",
|
||||||
"icon": "img/icon.png",
|
"icon": "img/icon.png",
|
||||||
"description": "",
|
"description": "",
|
||||||
"publisher": "nyncral",
|
"publisher": "nyncral",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.85.0"
|
"vscode": "^1.85.0"
|
||||||
},
|
},
|
||||||
"categories": [
|
"categories": [
|
||||||
"Other"
|
"Other"
|
||||||
],
|
],
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"onStartupFinished"
|
"onStartupFinished"
|
||||||
],
|
],
|
||||||
"main": "./extension.js",
|
"main": "./extension.js",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "dwm-git-simpleuse.fullPush",
|
"command": "dwm-git-simpleuse.fullPush",
|
||||||
"title": "full push"
|
"title": "gitDWM : full push"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "dwm-git-simpleuse.initRepo",
|
"command": "dwm-git-simpleuse.initRepo",
|
||||||
"title": "initialize existing repository"
|
"title": "gitDWM : initialize existing repository"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"keybindings": [
|
"keybindings": [
|
||||||
{
|
{
|
||||||
"command": "dwm-git-simpleuse.fullPush",
|
"command": "dwm-git-simpleuse.fullPush",
|
||||||
"key": "ctrl+alt+s",
|
"key": "ctrl+alt+s",
|
||||||
"mac": "ctrl+alt+s"
|
"mac": "ctrl+alt+s"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"pretest": "npm run lint",
|
"pretest": "npm run lint",
|
||||||
"test": "vscode-test"
|
"test": "vscode-test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/mocha": "^10.0.6",
|
"@types/mocha": "^10.0.6",
|
||||||
"@types/node": "18.x",
|
"@types/node": "18.x",
|
||||||
"@types/vscode": "^1.85.0",
|
"@types/vscode": "^1.85.0",
|
||||||
"@vscode/test-cli": "^0.0.4",
|
"@vscode/test-cli": "^0.0.4",
|
||||||
"@vscode/test-electron": "^2.3.8",
|
"@vscode/test-electron": "^2.3.8",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.56.0",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"child_process": "^1.0.2",
|
"child_process": "^1.0.2"
|
||||||
"git": "^2.0.0"
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue