0.1.0
This commit is contained in:
parent
8811c857a8
commit
b4a04ae19d
3 changed files with 97 additions and 14 deletions
18
CHANGELOG.md
18
CHANGELOG.md
|
|
@ -2,8 +2,22 @@
|
||||||
|
|
||||||
All notable changes to the "dwm-git-simpleuse" extension will be documented in this file.
|
All notable changes to the "dwm-git-simpleuse" extension will be documented in this file.
|
||||||
|
|
||||||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Task API
|
||||||
|
- no git warnings as errors
|
||||||
|
|
||||||
|
## [0.1.0] - 2024-04-10
|
||||||
|
|
||||||
|
- choose commmit message
|
||||||
|
- commit message auto increment
|
||||||
|
- command to initialize existing repository
|
||||||
|
- activation event set to "onStartupFinished"
|
||||||
|
|
||||||
|
## [0.0.2] - 2024-02-02
|
||||||
|
|
||||||
|
- renamed command to something else than "helloworld" => ("full push")
|
||||||
|
|
||||||
|
## [0.0.1] - 2024-02-01
|
||||||
|
|
||||||
- Initial release
|
- Initial release
|
||||||
70
extension.js
70
extension.js
|
|
@ -12,7 +12,7 @@ const chp = require("child_process");
|
||||||
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
|
||||||
console.log("yo!");
|
let lastGitCommitMsg = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.chdir(vscode.workspace.workspaceFolders[0].uri.fsPath);
|
process.chdir(vscode.workspace.workspaceFolders[0].uri.fsPath);
|
||||||
|
|
@ -35,10 +35,23 @@ function activate(context) {
|
||||||
// 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.helloWorld",
|
"dwm-git-simpleuse.fullPush",
|
||||||
function () {
|
async function () {
|
||||||
|
const gitCommitMsg = await vscode.window.showInputBox({
|
||||||
|
placeHolder: "commit message",
|
||||||
|
prompt: "choose your commit message",
|
||||||
|
value: lastGitCommitMsg.incrementSuffixe(),
|
||||||
|
});
|
||||||
|
if (gitCommitMsg === undefined) return;
|
||||||
|
gitCommitMsg.trim();
|
||||||
|
if (!gitCommitMsg.length) {
|
||||||
|
vscode.window.showErrorMessage("commit message needed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastGitCommitMsg = gitCommitMsg;
|
||||||
|
|
||||||
chp.exec(
|
chp.exec(
|
||||||
"git add . && git commit -am 'test77' && 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) {
|
||||||
|
|
@ -85,7 +98,49 @@ function activate(context) {
|
||||||
); */
|
); */
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
context.subscriptions.push(disposable);
|
||||||
|
|
||||||
|
disposable = vscode.commands.registerCommand(
|
||||||
|
"dwm-git-simpleuse.initRepo",
|
||||||
|
async function () {
|
||||||
|
const gitLink = await vscode.window.showInputBox({
|
||||||
|
placeHolder: "git repo link",
|
||||||
|
prompt: "Initialize a git repository",
|
||||||
|
value: await vscode.env.clipboard.readText(),
|
||||||
|
});
|
||||||
|
if (gitLink === undefined) return;
|
||||||
|
gitLink.trim();
|
||||||
|
if (!gitLink.match(/^https?:\/\/\S+\.git$/).length) {
|
||||||
|
vscode.window.showErrorMessage("Link needed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let gitBranch = await vscode.window.showInputBox({
|
||||||
|
placeHolder: "git branch",
|
||||||
|
prompt: "choose wich branch to use (defaults to 'main')",
|
||||||
|
value: "main",
|
||||||
|
});
|
||||||
|
if (gitBranch === undefined) return;
|
||||||
|
gitBranch.trim();
|
||||||
|
if (!gitBranch.length) gitBranch = "main";
|
||||||
|
|
||||||
|
chp.exec(
|
||||||
|
`git init && git remote add origin ${gitLink} && git fetch && git reset origin/${gitBranch} && git branch --set-upstream-to=origin/${gitBranch}`,
|
||||||
|
{ cwd: vscode.workspace.workspaceFolders[0].uri.fsPath },
|
||||||
|
(err, stdout, stderr) => {
|
||||||
|
if (err) {
|
||||||
|
vscode.window.showErrorMessage(err.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
vscode.window.showErrorMessage(stderr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vscode.window.showInformationMessage(stdout);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
context.subscriptions.push(disposable);
|
context.subscriptions.push(disposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,3 +151,10 @@ module.exports = {
|
||||||
activate,
|
activate,
|
||||||
deactivate,
|
deactivate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
return this.replace(/(\d+)?$/, function (match, p1) {
|
||||||
|
return p1 === undefined ? "(1)" : `(${parseInt(p1) + 1})`;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
||||||
23
package.json
23
package.json
|
|
@ -4,27 +4,33 @@
|
||||||
"icon": "img/icon.png",
|
"icon": "img/icon.png",
|
||||||
"description": "",
|
"description": "",
|
||||||
"publisher": "nyncral",
|
"publisher": "nyncral",
|
||||||
"version": "0.0.1",
|
"version": "0.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.85.0"
|
"vscode": "^1.85.0"
|
||||||
},
|
},
|
||||||
"categories": [
|
"categories": [
|
||||||
"Other"
|
"Other"
|
||||||
],
|
],
|
||||||
"activationEvents": [],
|
"activationEvents": [
|
||||||
|
"onStartupFinished"
|
||||||
|
],
|
||||||
"main": "./extension.js",
|
"main": "./extension.js",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "dwm-git-simpleuse.helloWorld",
|
"command": "dwm-git-simpleuse.fullPush",
|
||||||
"title": "HelloWorld23"
|
"title": "full push"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "dwm-git-simpleuse.initRepo",
|
||||||
|
"title": "initialize existing repository"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"keybindings": [
|
"keybindings": [
|
||||||
{
|
{
|
||||||
"command": "dwm-git-simpleuse.helloWorld",
|
"command": "dwm-git-simpleuse.fullPush",
|
||||||
"key": "ctrl+alt+r",
|
"key": "ctrl+alt+s",
|
||||||
"mac": "cmd+alt+r"
|
"mac": "ctrl+alt+s"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -43,6 +49,7 @@
|
||||||
"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