Skip to content

Instantly share code, notes, and snippets.

@akalongman
Created March 31, 2016 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akalongman/43831b5b60413f66b8cd1c020c9e5124 to your computer and use it in GitHub Desktop.
Save akalongman/43831b5b60413f66b8cd1c020c9e5124 to your computer and use it in GitHub Desktop.
GitHelper.py
# @author Avtandil Kikabidze
# @copyright Copyright (c) 2008-2016, Avtandil Kikabidze aka LONGMAN (akalongman@gmail.com)
# @link http://longman.me
# @license The MIT License (MIT)
import sublime
import sublime_plugin
import Git.git
import functools
class GitHelperAddCommand(Git.git.GitTextCommand):
def __init__(self, view):
self.view = view
def run(self, edit):
self.run_command(['git', 'add', '.'],
functools.partial(self.add_done, "Committing whole repo"))
def add_done(self, message, result):
if result.strip():
sublime.error_message("Error adding files: " + result)
return
self.view.window().show_input_panel('Commit msg', '', lambda s: self.on_done(s), None, None)
def on_done(self, text):
if text.strip() == "":
sublime.error_message("Commit message is empty!")
return
self.run_command(['git', 'commit', '-m', text],
callback=self.update_status)
def update_status(self, output, **kwargs):
if output.find('nothing to commit, working directory clean') != -1:
sublime.status_message("Nothing to commit, working directory clean")
return
sublime.status_message("Commit success: "+output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment