# Path: sgit/util.py
# def noop(*args, **kwargs):
#     pass
# 
# class StatusSpinner(object):
# 
#     SIZE = 10  # 10 equal signs
#     TIME = 50  # 50 ms delay
# 
#     def __init__(self, thread, msg):
#         self.counter = 0
#         self.direction = 1
#         self.msg = msg
#         self.thread = thread
# 
#     def progress(self):
#         if not self.thread.is_alive():
#             sublime.status_message('')
#             return
# 
#         left, right = self.counter, (self.SIZE - 1 - self.counter)
#         self.counter += self.direction
#         if self.counter in (0, self.SIZE - 1):
#             self.direction *= -1
# 
#         status = "[%s=%s] %s" % (' ' * left, ' ' * right, self.msg)
# 
#         sublime.status_message(status)
#         sublime.set_timeout(self.progress, self.TIME)
# 
#     def start(self):
#         self.thread.start()
#         sublime.set_timeout(self.progress, 0)
# 
# Path: sgit/cmd.py
# class GitCmd(GitRepoHelper, Cmd):
#     executable = 'git'
#     bin = ['git']
#     opts = [
#         '--no-pager',
#         '-c', 'color.diff=false',
#         '-c', 'color.status=false',
#         '-c', 'color.branch=false',
#         '-c', 'status.displayCommentPrefix=true',
#         '-c', 'core.commentchar=#',
#     ]
# 
#     def git(self, cmd, *args, **kwargs):
#         return self.cmd(cmd, *args, **kwargs)
# 
#     def git_string(self, cmd, *args, **kwargs):
#         return self._string(cmd, *args, **kwargs)
# 
#     def git_lines(self, cmd, *args, **kwargs):
#         return self._lines(cmd, *args, **kwargs)
# 
#     def git_exit_code(self, cmd, *args, **kwargs):
#         return self._exit_code(cmd, *args, **kwargs)
# 
#     def git_async(self, cmd, *args, **kwargs):
#         return self.cmd_async(cmd, *args, **kwargs)
# 
# Path: sgit/helpers.py
# class GitErrorHelper(object):
# 
#     def format_error_message(self, msg):
#         if msg.startswith('error: '):
#             msg = msg[7:]
#         elif msg.lower().startswith('Note: '):
#             msg = msg[6:]
#         if msg.endswith('Aborting\n'):
#             msg = msg.rstrip()[:-8]
#         return msg


import sublime
import shlex
from sublime_plugin import WindowCommand, TextCommand
from .util import noop, StatusSpinner
from .cmd import GitCmd
from .helpers import GitErrorHelper
    * **cmd**: The command to execute (without the initial "git")
    * **async**: ``true`` to run asynchronously, ``false`` otherwise. Default: ``false``
    * **output**: ``"view"`` for a new buffer, ``"panel"`` for an output panel, ``null`` for no output. Default: ``"view"``
    * **syntax**: If output is set to ``"view"``, the new buffer will get this syntax file. Should be a name along the
                  lines of ``Packages/Python/Python.tmLanguage``. To see the current syntax for a view, execute
                  ``view.settings().get('syntax')`` from the console.

    .. note::
        See :ref:`customizations-commands` for more information on how to create your own SublimeGit commands.

    """

    def run(self, cmd=None, async=False, output="view", syntax=None):
        repo = self.get_repo()
        if not repo:
            return

        if output not in (None, "panel", "view"):
            sublime.error_message("Output parameter must be one of None, 'panel' or 'view'")
            return
        self.output = output
        self.syntax = syntax

        if not cmd:
            def on_done(cmd):
                cmd = cmd.strip()
                if not cmd:
                    return
                self.on_command(repo, cmd, async=async)


# Path: sgit/util.py
# def noop(*args, **kwargs):
#     pass
# 
# class StatusSpinner(object):
# 
#     SIZE = 10  # 10 equal signs
#     TIME = 50  # 50 ms delay
# 
#     def __init__(self, thread, msg):
#         self.counter = 0
#         self.direction = 1
#         self.msg = msg
#         self.thread = thread
# 
#     def progress(self):
#         if not self.thread.is_alive():
#             sublime.status_message('')
#             return
# 
#         left, right = self.counter, (self.SIZE - 1 - self.counter)
#         self.counter += self.direction
#         if self.counter in (0, self.SIZE - 1):
#             self.direction *= -1
# 
#         status = "[%s=%s] %s" % (' ' * left, ' ' * right, self.msg)
# 
#         sublime.status_message(status)
#         sublime.set_timeout(self.progress, self.TIME)
# 
#     def start(self):
#         self.thread.start()
#         sublime.set_timeout(self.progress, 0)
# 
# Path: sgit/cmd.py
# class GitCmd(GitRepoHelper, Cmd):
#     executable = 'git'
#     bin = ['git']
#     opts = [
#         '--no-pager',
#         '-c', 'color.diff=false',
#         '-c', 'color.status=false',
#         '-c', 'color.branch=false',
#         '-c', 'status.displayCommentPrefix=true',
#         '-c', 'core.commentchar=#',
#     ]
# 
#     def git(self, cmd, *args, **kwargs):
#         return self.cmd(cmd, *args, **kwargs)
# 
#     def git_string(self, cmd, *args, **kwargs):
#         return self._string(cmd, *args, **kwargs)
# 
#     def git_lines(self, cmd, *args, **kwargs):
#         return self._lines(cmd, *args, **kwargs)
# 
#     def git_exit_code(self, cmd, *args, **kwargs):
#         return self._exit_code(cmd, *args, **kwargs)
# 
#     def git_async(self, cmd, *args, **kwargs):
#         return self.cmd_async(cmd, *args, **kwargs)
# 
# Path: sgit/helpers.py
# class GitErrorHelper(object):
# 
#     def format_error_message(self, msg):
#         if msg.startswith('error: '):
#             msg = msg[7:]
#         elif msg.lower().startswith('Note: '):
#             msg = msg[6:]
#         if msg.endswith('Aborting\n'):
#             msg = msg.rstrip()[:-8]
#         return msg


# Path: sgit/custom.py
import sublime
import shlex
from sublime_plugin import WindowCommand, TextCommand
from .util import noop, StatusSpinner
from .cmd import GitCmd
from .helpers import GitErrorHelper

    * **cmd**: The command to execute (without the initial "git")
    * **async**: ``true`` to run asynchronously, ``false`` otherwise. Default: ``false``
    * **output**: ``"view"`` for a new buffer, ``"panel"`` for an output panel, ``null`` for no output. Default: ``"view"``
    * **syntax**: If output is set to ``"view"``, the new buffer will get this syntax file. Should be a name along the
                  lines of ``Packages/Python/Python.tmLanguage``. To see the current syntax for a view, execute
                  ``view.settings().get('syntax')`` from the console.

    .. note::
        See :ref:`customizations-commands` for more information on how to create your own SublimeGit commands.

    """

    def run(self, cmd=None, async=False, output="view", syntax=None):
        repo = self.get_repo()
        if not repo:
            return

        if output not in (None, "panel", "view"):
            sublime.error_message("Output parameter must be one of None, 'panel' or 'view'")
            return
        self.output = output
        self.syntax = syntax

        if not cmd:
            def on_done(cmd):
                cmd = cmd.strip()
                if not cmd:
                    return
                self.on_command(repo, cmd, async=async)


            self.window.show_input_panel('git', '', on_done, noop, noop)