# Path: sgit/util.py
# def noop(*args, **kwargs):
#     pass
# 
# def abbreviate_dir(dirname):
#     user_dir = get_user_dir()
#     try:
#         if dirname.startswith(user_dir):
#             dirname = u'~%s' % dirname[len(user_dir):]
#     except:
#         pass
#     return dirname
# 
# 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)


import os
import sublime
from sublime_plugin import WindowCommand
from .util import noop, abbreviate_dir
from .cmd import GitCmd

    .. note::
        The initial suggestion for the directory is calculated in the
        following way:

        1. The first open folder, if any.
        2. The directory name of the currently active file, if any.
        3. The directory name of the first open file which has a filename,
           if any.
        4. The user directory of the currently logged in user.
    """

    def get_dir_candidate(self):
        if self.window:
            if self.window.folders():
                return self.window.folders()[0]

            active_dir = self.get_dir_from_view(self.window.active_view())
            if active_dir:
                return active_dir

            for view in self.window.views():
                view_dir = self.get_dir_from_view(view)
                if view_dir:
                    return view_dir
        return os.path.expanduser('~')

    def run(self):
        dir_candidate = self.get_dir_candidate()
        initial_text = dir_candidate if dir_candidate else ''

# Path: sgit/util.py
# def noop(*args, **kwargs):
#     pass
# 
# def abbreviate_dir(dirname):
#     user_dir = get_user_dir()
#     try:
#         if dirname.startswith(user_dir):
#             dirname = u'~%s' % dirname[len(user_dir):]
#     except:
#         pass
#     return dirname
# 
# 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/repo.py
import os
import sublime
from sublime_plugin import WindowCommand
from .util import noop, abbreviate_dir
from .cmd import GitCmd


    .. note::
        The initial suggestion for the directory is calculated in the
        following way:

        1. The first open folder, if any.
        2. The directory name of the currently active file, if any.
        3. The directory name of the first open file which has a filename,
           if any.
        4. The user directory of the currently logged in user.
    """

    def get_dir_candidate(self):
        if self.window:
            if self.window.folders():
                return self.window.folders()[0]

            active_dir = self.get_dir_from_view(self.window.active_view())
            if active_dir:
                return active_dir

            for view in self.window.views():
                view_dir = self.get_dir_from_view(view)
                if view_dir:
                    return view_dir
        return os.path.expanduser('~')

    def run(self):
        dir_candidate = self.get_dir_candidate()
        initial_text = dir_candidate if dir_candidate else ''

        self.window.show_input_panel(GIT_INIT_DIR_LABEL, initial_text, self.on_done, noop, noop)