Skip to content

Commit

Permalink
Merge 18c9240 into 35491ce
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Jul 10, 2018
2 parents 35491ce + 18c9240 commit a62b0b6
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 71 deletions.
10 changes: 10 additions & 0 deletions Default (OSX).sublime-keymap
Expand Up @@ -242,5 +242,15 @@
"context": [
{ "key": "selector", "operator": "equal", "operand": "git-savvy.tags" }
]
},

/////////////////////////////
// SINGLE LINE INPUT PANEL //
////////////////////////////

{
"keys": ["super+enter"],
"command": "noop",
"context": [{ "key": "setting.git_savvy.single_line_input_panel" }]
}
]
15 changes: 15 additions & 0 deletions Default.sublime-keymap
Expand Up @@ -1818,5 +1818,20 @@
{ "key": "setting.git_savvy.git-rebase-todo_view", "operator": "equal", "operand": true },
{ "key": "selector", "operator": "equal", "operand": "git-savvy.rebase.interactive meta.git-savvy.rebase-interactive.line" }
]
},

/////////////////////////////
// SINGLE LINE INPUT PANEL //
////////////////////////////

{
"keys": ["shift+enter"],
"command": "noop",
"context": [{ "key": "setting.git_savvy.single_line_input_panel" }]
},
{
"keys": ["ctrl+enter"],
"command": "noop",
"context": [{ "key": "setting.git_savvy.single_line_input_panel" }]
}
]
3 changes: 2 additions & 1 deletion core/commands/changelog.py
Expand Up @@ -4,6 +4,7 @@
from sublime_plugin import WindowCommand

from ..git_command import GitCommand
from ..ui_mixins.input_panel import show_single_line_input_panel

REF_PROMPT = "Ref or commit hash:"

Expand All @@ -28,7 +29,7 @@ def run(self):
sublime.set_timeout_async(self.run_async, 0)

def run_async(self):
view = self.window.show_input_panel(
view = show_single_line_input_panel(
REF_PROMPT, self.get_last_local_tag(), self.on_done, None, None)
view.run_command("select_all")

Expand Down
13 changes: 5 additions & 8 deletions core/commands/checkout.py
Expand Up @@ -5,6 +5,7 @@
from .log import LogMixin
from ...common import util
from ..ui_mixins.quick_panel import show_branch_panel
from ..ui_mixins.input_panel import show_single_line_input_panel


NEW_BRANCH_PROMPT = "Branch name:"
Expand Down Expand Up @@ -50,9 +51,8 @@ def run(self, base_branch=None):

def run_async(self, base_branch=None, new_branch=None):
self.base_branch = base_branch
v = self.window.show_input_panel(
NEW_BRANCH_PROMPT, new_branch or base_branch or "", self.on_done, None, None)
v.run_command("select_all")
show_single_line_input_panel(
NEW_BRANCH_PROMPT, new_branch or base_branch or "", self.on_done)

def on_done(self, branch_name):
if not self.validate_branch_name(branch_name):
Expand Down Expand Up @@ -97,13 +97,10 @@ def on_branch_selection(self, remote_branch, local_name=None):
self.remote_branch = remote_branch
if not local_name:
local_name = remote_branch.split("/", 1)[1]
v = self.window.show_input_panel(
show_single_line_input_panel(
NEW_BRANCH_PROMPT,
local_name,
self.on_enter_local_name,
None,
None)
v.run_command("select_all")
self.on_enter_local_name)

def on_enter_local_name(self, branch_name):
if not self.validate_branch_name(branch_name):
Expand Down
3 changes: 2 additions & 1 deletion core/commands/commit_compare.py
Expand Up @@ -5,6 +5,7 @@
from ...common import util
from ..git_command import GitCommand
from ..ui_mixins.quick_panel import PanelActionMixin, show_branch_panel
from ..ui_mixins.input_panel import show_single_line_input_panel


COMMIT_NODE_CHAR = "●"
Expand Down Expand Up @@ -121,7 +122,7 @@ def run(self, base_commit=None, target_commit=None, file_path=None):
sublime.set_timeout_async(self.run_async)

def run_async(self):
self.window.show_input_panel("Ref:", "", self.show_diff, None, self.on_cancel)
show_single_line_input_panel("Ref:", "", self.show_diff, None, self.on_cancel)

def show_diff(self, ref):
self.window.run_command("gs_compare_commit", {
Expand Down
7 changes: 3 additions & 4 deletions core/commands/custom.py
Expand Up @@ -4,6 +4,7 @@

from ..git_command import GitCommand
from ...common import util
from ..ui_mixins.input_panel import show_single_line_input_panel


class CustomCommandThread(threading.Thread):
Expand Down Expand Up @@ -33,14 +34,12 @@ def run(self, **kwargs):
# prompt for custom command argument
if '{PROMPT_ARG}' in kwargs.get('args'):
prompt_msg = kwargs.pop("prompt_msg", "Command argument: ")
return self.window.show_input_panel(
return show_single_line_input_panel(
prompt_msg,
"",
lambda arg: sublime.set_timeout_async(
lambda: self.run_async(custom_argument=arg, **kwargs), 0
),
None,
None
)
)

sublime.set_timeout_async(lambda: self.run_async(**kwargs), 0)
Expand Down
3 changes: 2 additions & 1 deletion core/commands/ignore.py
Expand Up @@ -5,6 +5,7 @@

from ..git_command import GitCommand
from ...common import util
from ..ui_mixins.input_panel import show_single_line_input_panel


IGNORE_PATTERN_PROMPT = "Enter pattern to ignore:"
Expand Down Expand Up @@ -35,7 +36,7 @@ class GsIgnorePatternCommand(WindowCommand, GitCommand):
"""

def run(self, pre_filled=None):
self.window.show_input_panel(IGNORE_PATTERN_PROMPT, pre_filled or "", self.on_done, None, None)
show_single_line_input_panel(IGNORE_PATTERN_PROMPT, pre_filled or "", self.on_done)

def on_done(self, ignore_pattern):
self.add_ignore(ignore_pattern)
Expand Down
11 changes: 6 additions & 5 deletions core/commands/init.py
Expand Up @@ -5,6 +5,7 @@

from ..git_command import GitCommand
from ...common import util
from ..ui_mixins.input_panel import show_single_line_input_panel


NO_REPO_MESSAGE = ("It looks like you haven't initialized Git in this directory. "
Expand Down Expand Up @@ -67,7 +68,7 @@ def run_async(self):
self.on_done(git_root, re_init=True)
return

self.window.show_input_panel(REPO_PATH_PROMPT, git_root, self.on_done, None, None)
show_single_line_input_panel(REPO_PATH_PROMPT, git_root, self.on_done, None, None)

def on_done(self, path, re_init=False):
self.git("init", working_dir=path)
Expand All @@ -89,12 +90,12 @@ class GsClone(WindowCommand, GitCommand):
"""

def run(self):
self.window.show_input_panel(GIT_URL, '', self.on_enter_url, None, None)
show_single_line_input_panel(GIT_URL, '', self.on_enter_url, None, None)

def on_enter_url(self, url):
self.git_url = url
self.suggested_git_root = self.find_suggested_git_root()
self.window.show_input_panel(REPO_PATH_PROMPT, self.suggested_git_root, self.on_enter_directory, None, None)
show_single_line_input_panel(REPO_PATH_PROMPT, self.suggested_git_root, self.on_enter_directory, None, None)

def find_suggested_git_root(self):
folder = self.find_working_dir()
Expand Down Expand Up @@ -144,14 +145,14 @@ def run_async(self):
self.get_name()

def get_name(self):
self.window.show_input_panel(NAME_MESSAGE, "", self.on_done_name, None, None)
show_single_line_input_panel(NAME_MESSAGE, "", self.on_done_name, None, None)

def on_done_name(self, name):
self.git("config", "--global", "user.name", "\"{}\"".format(name))
self.get_email()

def get_email(self):
self.window.show_input_panel(EMAIL_MESSAGE, "", self.on_done_email, None, None)
show_single_line_input_panel(EMAIL_MESSAGE, "", self.on_done_email, None, None)

def on_done_email(self, email):
self.git("config", "--global", "user.email", "\"{}\"".format(email))
3 changes: 2 additions & 1 deletion core/commands/mv.py
Expand Up @@ -4,6 +4,7 @@
from sublime_plugin import WindowCommand

from ..git_command import GitCommand
from ..ui_mixins.input_panel import show_single_line_input_panel


class GsMvCurrentFileCommand(WindowCommand, GitCommand):
Expand All @@ -18,7 +19,7 @@ def run(self):
on_done = functools.partial(
self.on_done,
self.file_path, parent, base_name)
v = self.window.show_input_panel(
v = show_single_line_input_panel(
"New Name:", base_name,
on_done, None, None)
name, ext = os.path.splitext(base_name)
Expand Down
7 changes: 3 additions & 4 deletions core/commands/push.py
Expand Up @@ -4,6 +4,7 @@
from ..git_command import GitCommand
from ...common import util
from ..ui_mixins.quick_panel import show_remote_panel, show_branch_panel
from ..ui_mixins.input_panel import show_single_line_input_panel


START_PUSH_MESSAGE = "Starting push..."
Expand Down Expand Up @@ -127,12 +128,10 @@ def on_remote_selection(self, remote):
self.on_entered_branch_name(self.branch_name)
else:
current_local_branch = self.get_current_branch_name()
self.window.show_input_panel(
show_single_line_input_panel(
PUSH_TO_BRANCH_NAME_PROMPT,
current_local_branch,
self.on_entered_branch_name,
None,
None
self.on_entered_branch_name
)

def on_entered_branch_name(self, branch):
Expand Down
13 changes: 5 additions & 8 deletions core/commands/quick_commit.py
Expand Up @@ -3,6 +3,7 @@

from ..git_command import GitCommand
from ...common import util
from ..ui_mixins.input_panel import show_single_line_input_panel


COMMIT_MSG_PROMPT = "Commit message:"
Expand All @@ -16,12 +17,10 @@ class GsQuickCommitCommand(WindowCommand, GitCommand):
"""

def run(self):
self.window.show_input_panel(
show_single_line_input_panel(
COMMIT_MSG_PROMPT,
"",
lambda msg: sublime.set_timeout_async(lambda: self.on_done(msg), 0),
None,
None
lambda msg: sublime.set_timeout_async(lambda: self.on_done(msg), 0)
)

def on_done(self, commit_message):
Expand All @@ -39,12 +38,10 @@ class GsQuickStageCurrentFileCommitCommand(WindowCommand, GitCommand):
"""

def run(self):
self.window.show_input_panel(
show_single_line_input_panel(
COMMIT_MSG_PROMPT,
"",
lambda msg: sublime.set_timeout_async(lambda: self.on_done(msg), 0),
None,
None
lambda msg: sublime.set_timeout_async(lambda: self.on_done(msg), 0)
)

def on_done(self, commit_message):
Expand Down
8 changes: 4 additions & 4 deletions core/commands/remote.py
Expand Up @@ -4,6 +4,7 @@
from ..git_command import GitCommand
from ...common import util
from ..ui_mixins.quick_panel import show_remote_panel
from ..ui_mixins.input_panel import show_single_line_input_panel


class GsRemoteAddCommand(WindowCommand, GitCommand):
Expand All @@ -16,13 +17,13 @@ def run(self, url=None):
if url:
self.on_enter_remote(url)
else:
self.window.show_input_panel("Remote URL", "", self.on_enter_remote, None, None)
show_single_line_input_panel("Remote URL", "", self.on_enter_remote, None, None)

def on_enter_remote(self, input_url):
self.url = input_url
owner = self.username_from_url(input_url)

self.window.show_input_panel("Remote name", owner, self.on_enter_name, None, None)
show_single_line_input_panel("Remote name", owner, self.on_enter_name, None, None)

def on_enter_name(self, remote_name):
self.git("remote", "add", remote_name, self.url)
Expand Down Expand Up @@ -62,8 +63,7 @@ def on_remote_selection(self, remote):
return

self.remote = remote
v = self.window.show_input_panel("Remote name", remote, self.on_enter_name, None, None)
v.run_command("select_all")
show_single_line_input_panel("Remote name", remote, self.on_enter_name, None, None)

def on_enter_name(self, new_name):
self.git("remote", "rename", self.remote, new_name)
Expand Down
3 changes: 2 additions & 1 deletion core/commands/stash.py
Expand Up @@ -2,6 +2,7 @@

from ..git_command import GitCommand
from ..ui_mixins.quick_panel import show_stash_panel
from ..ui_mixins.input_panel import show_single_line_input_panel
from ...common import util


Expand Down Expand Up @@ -88,7 +89,7 @@ class GsStashSaveCommand(WindowCommand, GitCommand):
def run(self, include_untracked=False, stash_of_indexed=False):
self.include_untracked = include_untracked
self.stash_of_indexed = stash_of_indexed
self.window.show_input_panel("Description:", "", self.on_done, None, None)
show_single_line_input_panel("Description:", "", self.on_done)

def on_done(self, description):
if not self.stash_of_indexed:
Expand Down
9 changes: 4 additions & 5 deletions core/commands/tag.py
Expand Up @@ -5,6 +5,7 @@
from ...common import util
from ..git_command import GitCommand
from ..ui_mixins.quick_panel import PanelActionMixin
from ..ui_mixins.input_panel import show_single_line_input_panel

RELEASE_REGEXP = re.compile(r"^([0-9A-Za-z-]*[A-Za-z-])?([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-\.]*?)?([0-9]+))?$")

Expand Down Expand Up @@ -67,7 +68,7 @@ def run_async(self):
"""
Prompt the user for a tag name.
"""
self.window.show_input_panel(TAG_CREATE_PROMPT, self.tag_name, self.on_entered_name, None, None)
show_single_line_input_panel(TAG_CREATE_PROMPT, self.tag_name, self.on_entered_name)

def on_entered_name(self, tag_name):
"""
Expand All @@ -88,12 +89,10 @@ def on_entered_name(self, tag_name):
return util.log.panel("\"{}\" is not a valid tag name.".format(tag_name))

self.tag_name = stdout.strip()[10:]
self.window.show_input_panel(
show_single_line_input_panel(
TAG_CREATE_MESSAGE_PROMPT,
self.savvy_settings.get("default_tag_message").format(tag_name=tag_name),
self.on_entered_message,
None,
None
self.on_entered_message
)

def on_entered_message(self, message):
Expand Down
13 changes: 5 additions & 8 deletions core/interfaces/branch.py
Expand Up @@ -10,6 +10,7 @@
from ..commands.log_graph import LogGraphMixin
from ..git_command import GitCommand
from ..ui_mixins.quick_panel import show_remote_panel, show_branch_panel
from ..ui_mixins.input_panel import show_single_line_input_panel


class GsShowBranchCommand(WindowCommand, GitCommand):
Expand Down Expand Up @@ -321,12 +322,10 @@ def run_async(self):
return
self.branch_name = branch_name

self.view.window().show_input_panel(
show_single_line_input_panel(
"Enter new branch name (for {}):".format(self.branch_name),
self.branch_name,
self.on_entered_name,
None,
None
self.on_entered_name
)

def on_entered_name(self, new_name):
Expand Down Expand Up @@ -569,12 +568,10 @@ def run_async(self):
throw_on_stderr=False
).strip(" \n")

self.view.window().show_input_panel(
show_single_line_input_panel(
"Enter new description (for {}):".format(self.branch_name),
current_description,
self.on_entered_description,
None,
None
self.on_entered_description
)

def on_entered_description(self, new_description):
Expand Down

0 comments on commit a62b0b6

Please sign in to comment.