Skip to content
Permalink
Browse files

Fixes stash issues

  • Loading branch information
miped committed Mar 16, 2014
1 parent 0857914 commit b0aa1606386b63900af1358a5951c230748661b9
@@ -26,6 +26,7 @@
{ "caption": "Git: Quick Commit Current File", "command": "git_quick_commit_current_file"},

{ "caption": "Git: Stash", "command": "git_stash"},
{ "caption": "Git: Stash Include Untracked", "command": "git_stash", "args": {"untracked": true}},
{ "caption": "Git: Snapshot", "command": "git_snapshot"},
{ "caption": "Git: Pop Stash", "command": "git_stash_pop"},
{ "caption": "Git: Apply Stash", "command": "git_stash_apply"},
@@ -168,6 +168,11 @@
{ "key": "selector", "operator": "equal", "operand": "text.git-status"}
]
},
{ "keys": ["Z"], "command": "git_stash", "args": {"untracked": true},
"context": [
{ "key": "selector", "operator": "equal", "operand": "text.git-status"}
]
},
{ "keys": ["a"], "command": "git_status_stash_apply",
"context": [
{ "key": "selector", "operator": "equal", "operand": "meta.git-status.stashes"},
@@ -187,7 +192,7 @@
{ "key": "selector", "operator": "equal", "operand": "text.git-status"}
]
},
{ "keys": ["C"], "command": "git_commit", "args": {"add": true },
{ "keys": ["C"], "command": "git_commit", "args": {"add": true},
"context": [
{ "key": "selector", "operator": "equal", "operand": "text.git-status"}
]
@@ -0,0 +1,15 @@
SublimeGit 1.0.32
=================


Enhancements
------------
- Adds command for creating a stash including untracked files. This can be
run from the command palette, or by using Z in the status view.


Bug Fixes:
----------
- Fix clashes with Vintageous. (Issue #120)

- Fix issues with stashes not being applied/popped. (Issues #90 and #107)
@@ -6,7 +6,7 @@

from .util import noop
from .cmd import GitCmd
from .helpers import GitStashHelper, GitErrorHelper
from .helpers import GitStashHelper, GitStatusHelper, GitErrorHelper


class GitStashWindowCmd(GitCmd, GitStashHelper, GitErrorHelper):
@@ -41,28 +41,33 @@ def inner(choice):
return inner


class GitStashCommand(WindowCommand, GitStashWindowCmd):
class GitStashCommand(WindowCommand, GitCmd, GitStatusHelper):
"""
Documentation coming soon.
"""

def run(self):
def run(self, untracked=False):
repo = self.get_repo()
if not repo:
return

def on_done(title):
title = title.strip()
self.git(['stash', 'save', '--', title], cwd=repo)
self.git(['stash', 'save', '--include-untracked' if untracked else None, '--', title], cwd=repo)
self.window.run_command('git_status', {'refresh_only': True})

# update the index
self.git_exit_code(['update-index', '--refresh'], cwd=repo)

if self.git_exit_code(['diff', '--exit-code', '--quiet'], cwd=repo) != 0:
self.window.show_input_panel('Stash title:', '', on_done, noop, noop)
else:
sublime.error_message("No local changes to save")
# get files status
untracked_files, unstaged_files, _ = self.get_files_status(repo)

# check for if there's something to stash
if not unstaged_files:
if (untracked and not untracked_files) or (not untracked):
return sublime.error_message("No local changes to save")

self.window.show_input_panel('Stash title:', '', on_done, noop, noop)


class GitSnapshotCommand(WindowCommand, GitStashWindowCmd):
@@ -91,7 +91,7 @@
#
# Stashes:
# a = apply stash, A = pop stash
# z = create stash from worktree
# z = create stash, Z = create stash including untracked files
# backspace = discard stash"""


@@ -58,7 +58,7 @@
"patterns": [
{
"name": "meta.git-status.line",
"match": "\\t(.+): On (.+): (.+)\\n",
"match": "\\t(.+): (?:WIP )?[oO]n (.+): (.+)\\n",
"captures": {
"1": { "name": "meta.git-status.stash.name" },
"2": { "name": "meta.git-status.stash.branch" },
@@ -148,7 +148,7 @@
</dict>
</dict>
<key>match</key>
<string>\t(.+): On (.+): (.+)\n</string>
<string>\t(.+): (?:WIP )?[oO]n (.+): (.+)\n</string>
<key>name</key>
<string>meta.git-status.line</string>
</dict>

0 comments on commit b0aa160

Please sign in to comment.
You can’t perform that action at this time.