Skip to content

Commit

Permalink
Stash any changes before resetting
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Feb 16, 2015
1 parent 3dba312 commit 32fdcd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion gdm/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def git_fetch(self, repo):

def git_revert(self):
"""Revert all changes in the working tree."""
self._clean()
self._stash()
self._reset()
self._clean()

def git_update(self, rev):
"""Update the working tree to the specified revision."""
Expand All @@ -86,6 +87,9 @@ def _fetch(self, repo):
self._git('remote', 'add', 'origin', repo)
self._git('fetch', '--all', '--tags', '--force', '--prune')

def _stash(self):
self._git('stash')

def _clean(self):
self._git('clean', '--force', '-d', '-x')

Expand Down
3 changes: 2 additions & 1 deletion gdm/test/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ def test_revert(self, mock_call):
"""Verify the commands to revert all changes in a working tree."""
self.shell.git_revert()
self.assert_calls(mock_call, [
"git clean --force -d -x",
"git stash",
"git reset --hard",
"git clean --force -d -x",
])

def test_update(self, mock_call):
Expand Down

0 comments on commit 32fdcd3

Please sign in to comment.