Skip to content

Instantly share code, notes, and snippets.

@yutin1987
Created November 18, 2017 01:16
Show Gist options
  • Save yutin1987/57954c20cc390cdbc04572c7903da26e to your computer and use it in GitHub Desktop.
Save yutin1987/57954c20cc390cdbc04572c7903da26e to your computer and use it in GitHub Desktop.
undo-last-commit for atmo
{ 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