diff --git a/gitcheck/gitcheck.py b/gitcheck/gitcheck.py index 448f0e9..e02723a 100755 --- a/gitcheck/gitcheck.py +++ b/gitcheck/gitcheck.py @@ -103,8 +103,13 @@ def checkRepository(rep, branch): if re.match(argopts.get('ignoreBranch', r'^$'), branch): return False + # Local changes include changes to commit and stashed changes changes = getLocalFilesChange(rep) - ischange = len(changes) > 0 + islocal = len(changes) > 0 + if argopts.get('showStash', False): + islocal = islocal or len(getStashed(rep)) > 0 + + ischange = islocal # initialize ischange with local changes, update later actionNeeded = False # actionNeeded is branch push/pull, not local file change. topush = "" @@ -178,18 +183,40 @@ def checkRepository(rep, branch): html.prjname = '%s' % (repname) # Print result - if len(changes) > 0: + if islocal: strlocal = "%sLocal%s[" % (colortheme['reponame'], colortheme['default']) - lenFilesChnaged = len(getLocalFilesChange(rep)) - strlocal += "%sTo Commit:%s%s" % ( - colortheme['remoteto'], - colortheme['default'], - lenFilesChnaged - ) html.strlocal = ' Local[' - html.strlocal += "To Commit:%s" % ( - lenFilesChnaged - ) + + # Show local changes (to commit) + lenFilesChanged = len(getLocalFilesChange(rep)) + if lenFilesChanged: + strlocal += "%sTo Commit:%s%s" % ( + colortheme['remoteto'], + colortheme['default'], + lenFilesChanged + ) + html.strlocal += "To Commit:%s" % ( + lenFilesChanged + ) + + # Show stashed changes if requested + if argopts.get('showStash', False): + lenStashed = len(getStashed(rep)) + if lenStashed: + # include a space to separate changes to commit and stashed changes + separator = '' + if lenFilesChanged: + separator = ' ' + + strlocal += separator + "%sStashed:%s%s" % ( + colortheme['remoteto'], + colortheme['default'], + lenStashed + ) + html.strlocal += separator + "Stashed:%s" % ( + lenStashed + ) + strlocal += "]" html.strlocal += "]" else: @@ -204,7 +231,7 @@ def checkRepository(rep, branch): print("%(prjname)s/%(cbranch)s %(strlocal)s%(topush)s%(topull)s" % locals()) if argopts.get('verbose', False): - if ischange > 0: + if len(changes) > 0: filename = " |--Local" if not argopts.get('email', False): print(filename) @@ -219,6 +246,26 @@ def checkRepository(rep, branch): html.msg += '