-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'git commit' command should run in a new terminal #39
Comments
Hi @alessandro-newzoo thanks for checking! 👍 I've experienced this too but I can't seem to have a proper solution if there are multiple tabs and you just lost the "focus". In your use case, I understand that creating another terminal will solve it. But I usually have multiple terminals like 1 terminal for the React server, and 1 terminal for another process. Then another 1 for commiting my changes. From a user perspective, I'm not sure if I would like to open multiple terminals for my 5 files changed... What do you think about that? Can VSCode find the available terminal where it can do the command? 🤔 🤔 🤔 The alternative working solution I've found here is to copy the commit on the clipboard so that it doesn't get lost |
hey, I'm the issue reporter, from my personal account! Yeah I also usually use multiple terminals, but always keep gulp in the foreground as I need to see if LESS throws any errors when I save the files. Now that I think about it, why use the terminal at all for your extension? You can run a shell command with NodeJS's If you wanna go without the terminal, add this at the top of your file: const cp = require('child_process'); And then this to replace your function that writes to the terminal: // Get this value from the commit message:
let commitText = 'test';
// Replace this path with a config where the user can specify the directory
// containing the repo they want to work with
let folderPath = "C:\\Users\\Alessandro\\Project";
let command = `git commit -m "${commitText}"`;
let opts = {
"cwd": folderPath
}
// console.log() is for you to debug, you can either remove it, or send "stdout" to an output channel
// or a notification with "vscode.window.showInformationMessage". I personally wouldn't show anything
cp.exec(command, opts, function(err, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (err) {
console.log('error: ' + err);
}
}); If you check your Debug Console, you'll see the git command has run in the specified directory, and didn't need to open a terminal. The only challenge for you to solve is the Based on my research, there are mainly 3 ways to go about it: 1 - You let the user enter the path in a setting, like I said above.2 -
|
Forgot to add, if you really wanna go the terminal way, then you can create a new terminal for the git command to run, and add let command = `git commit -m "${commitText}"; exit` |
@solid-pixel - Thanks again for your time! The reason I have gone with the terminal approach and not with the "automatic commit behind the scene" approach is that I want the user to "see" or "verify" what is going to be committed. It seems like there are users who are okay not seeing or verifying it already and find the process redundant (I guess). I'm thinking maybe we can extend the current setting "Auto Commit" which paste it into the terminal and automatically enters it without you manually doing it. What do you think? Would you be okay enabling the "Auto Commit" setting and then it would spin up a node process at the background or terminal then close it without you seeing the constructed commit? 😄 |
hey sorry for the late reply, I've been busy finishing my extension! I understand why you want the user to see what happens, that makes sense, but still, relying on the terminal seems quite unreliable for the reasons explained above - perhaps you can use the status bar, notification messages, or the quick pick (command palette) to ask for confirmation? Or at the very least instruct the user to open a terminal in the right directory before committing. To answer your question, yeah I would be ok I think, because I commit all the time and having to confirm each commit would disrupt my flow a bit, but that is just my personal opinion and use case, and your idea of showing what's going on might apply to a lot of other people :) Either way, I've decided I don't want my commits to contain emojis, so I'm not using the extension anymore sorry :D But still happy to provide my input if it helps other users out there 👍 |
Thanks for your feedback! I am considering your input :)
No problem! In case you haven't checked it, you can remove the emojis and customize the "format" of the commit message 😉 Good luck with your extension! Hope you can share it with me too once it's done! |
oh nice, I'll give it a try when I have a moment, and no worries happy to help! Here's my (first) extension, very niche use case though so I doubt you'll need it :D it was made out of necessity for myself, then decided to share it: https://marketplace.visualstudio.com/items?itemName=AlessandroBenassi.cloudflare-devtools I left you a 5 stars review :) Take care! |
Hello!
I still need to figure out how to use this, but thanks a lot for your hard work!
When I run the extension's command,
git commit
runs in the terminal I'm currently using, which might cause issues if something like Gulp is running.Besides potential issues,
git commit
will not actually commit since the terminal is running a task, hence won't take any input.It will just print it and that's it:
So I suggest you have the extension command to open a new terminal tab, and run the command in it.
You can use
vscode.window.createTerminal
for that 🙂The text was updated successfully, but these errors were encountered: