From c8f12fc42ee17d679fb930fead5bc4092386bb8d Mon Sep 17 00:00:00 2001 From: javex Date: Fri, 5 Jun 2015 11:43:21 +0200 Subject: [PATCH 1/3] Ignore submodules when stashing Submodule changes cannot be stashed and thus should not be considered when stashing changes. Requires gitpython-developers/GitPython#294 to be applied first. --- PyGitUp/git_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyGitUp/git_wrapper.py b/PyGitUp/git_wrapper.py index 7bb586c..3a3d2da 100644 --- a/PyGitUp/git_wrapper.py +++ b/PyGitUp/git_wrapper.py @@ -134,7 +134,7 @@ def stash(self): """ stashed = False - if self.repo.is_dirty(): + if self.repo.is_dirty(consider_submodules=False): if self.change_count > 1: message = 'stashing {0} changes' else: From 6e2129d599e21860e8b6420ce31d5dc96bd6ad77 Mon Sep 17 00:00:00 2001 From: javex Date: Fri, 5 Jun 2015 11:44:55 +0200 Subject: [PATCH 2/3] Correctly determine change_count The old version would consider an empty string as "1 change" where it should be 0. This change is able to determine a 0 count. --- PyGitUp/git_wrapper.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/PyGitUp/git_wrapper.py b/PyGitUp/git_wrapper.py index 3a3d2da..74a9cbf 100644 --- a/PyGitUp/git_wrapper.py +++ b/PyGitUp/git_wrapper.py @@ -188,10 +188,11 @@ def config(self, key): @property def change_count(self): """ The number of changes in the working directory. """ - return len( - self.git.status(porcelain=True, untracked_files='no').split( - '\n') - ) + status = self.git.status(porcelain=True, untracked_files='no').strip() + if not status: + return 0 + else: + return len(status.split('\n')) @property def version(self): From 46b0bd3e2f3fc7f5bcf4b666f334e872a817aeda Mon Sep 17 00:00:00 2001 From: javex Date: Thu, 11 Jun 2015 22:43:31 +0200 Subject: [PATCH 3/3] Use the updated is_dirty API The pull request gitpython-developers/GitPython#294 has been merged but the API was changed slighty. This commit reflects this change so that it works again. --- PyGitUp/git_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyGitUp/git_wrapper.py b/PyGitUp/git_wrapper.py index 74a9cbf..88aa91e 100644 --- a/PyGitUp/git_wrapper.py +++ b/PyGitUp/git_wrapper.py @@ -134,7 +134,7 @@ def stash(self): """ stashed = False - if self.repo.is_dirty(consider_submodules=False): + if self.repo.is_dirty(submodules=False): if self.change_count > 1: message = 'stashing {0} changes' else: