Skip to content

Commit

Permalink
Merge pull request #338 from emiltorp/master
Browse files Browse the repository at this point in the history
Adding Git Stash List
  • Loading branch information
kemayo committed Jan 5, 2016
2 parents 6b73beb + 75dd473 commit 774d61f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
,{
"caption": "Git: Stash Drop",
"command": "git_stash_drop"
}
,{
"caption": "Git: Stash List",
"command": "git_stash_list"
}
,{
"caption": "Git: Add Current File",
Expand Down
1 change: 1 addition & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
,{ "caption": "Pop", "command": "git_stash_pop" }
,{ "caption": "Apply", "command": "git_stash_apply" }
,{ "caption": "Drop", "command": "git_stash_drop" }
,{ "caption": "List", "command": "git_stash_list" }
]
}
,{ "caption": "-" }
Expand Down
32 changes: 32 additions & 0 deletions stash.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,35 @@ def stash_list_panel_done(self, picked=0):

class GitStashDropCommand(GitStashApplyCommand):
command_to_run_after_list = 'drop'

class GitStashListCommand(GitWindowCommand):
command_to_run_after_list = 'show'

def run(self):
self.run_command(['git', 'stash', 'list'], self.stash_list_done)

def stash_list_done(self, result):
# No stash list at all
if not result:
self.panel('No stash found')
return

self.results = result.rstrip().split('\n')

# If there is only one, apply it
if len(self.results) == 1:
self.stash_list_panel_done()
else:
self.quick_panel(self.results, self.stash_list_panel_done)

def stash_list_panel_done(self, picked=0):
if 0 > picked < len(self.results):
return

# get the stash ref (e.g. stash@{3})
self.stash = self.results[picked].split(':')[0]
self.run_command(['git', 'stash', self.command_to_run_after_list, '-p', self.stash],
self.show_diff, stash = self.stash);

def show_diff(self, result, stash):
self.scratch(result, title="%s" % stash, syntax="Packages/Diff/Diff.tmLanguage")

0 comments on commit 774d61f

Please sign in to comment.