diff --git a/gdm/shell.py b/gdm/shell.py index 60f1bf8e..03fbf425 100644 --- a/gdm/shell.py +++ b/gdm/shell.py @@ -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.""" @@ -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') diff --git a/gdm/test/test_shell.py b/gdm/test/test_shell.py index 416918ce..51dfd8e6 100644 --- a/gdm/test/test_shell.py +++ b/gdm/test/test_shell.py @@ -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):