Created
November 18, 2017 01:16
-
-
Save yutin1987/57954c20cc390cdbc04572c7903da26e to your computer and use it in GitHub Desktop.
undo-last-commit for atmo
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
{ BufferedProcess } = require 'atom' | |
atom.commands.add 'atom-text-editor', 'undo-last-commit': (event) -> | |
path = atom.workspace.getCenter().getActiveTextEditor()?.getPath() | |
directory = atom.project.getDirectories().filter((d) -> d.contains(path))[0] | |
output = '' | |
new BufferedProcess | |
command: 'git' | |
args: ['reset', 'HEAD^'] | |
options: | |
cwd: directory.getPath() | |
stdout: (data) -> output += data.toString() | |
stderr: (data) -> output += data.toString() | |
exit: (code) -> | |
if code is 0 | |
atom.notifications.addSuccess('Undo Last Commit', detail: output); | |
else | |
atom.notifications.addError('Undo Last Commit', detail: output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment