From 57eaebb6e6d7b30831b086fe59a8a2b49c08215b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gl=C3=BCpker?= Date: Sun, 13 Jan 2019 19:51:39 +0100 Subject: Stash branch, if if has local changes --- updateGit.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/updateGit.py b/updateGit.py index 2999323..a73d5ae 100755 --- a/updateGit.py +++ b/updateGit.py @@ -71,9 +71,6 @@ def updatePath(path): if not upstream_branch or tracking == 'gone': print('[%s]' % friendly_path, local_branch, 'has no upstream branch.') continue - if local_branch == cur_branch and changed: - print('[%s]' % friendly_path, 'has a working branch with changes, skipped.') - continue dPrint('Update for', friendly_path, local_branch, upstream_branch) local = getGitStdout(path, ['rev-parse', '--quiet', '--verify', local_branch]) remote = getGitStdout(path, ['rev-parse', '--quiet', '--verify', upstream_branch]) @@ -85,6 +82,9 @@ def updatePath(path): dPrint(' Base', base) if local == remote: continue + if local_branch == cur_branch and changed: + print('[%s]' % friendly_path, 'has a working branch with changes. Stashing.') + getGitStdout(path, ['stash', 'push', '--include-untracked', '--message', 'Automatic stash by updateGit.py']) if local == base: if local_branch == cur_branch: getGitStdout(path, ['merge', remote]) @@ -98,6 +98,10 @@ def updatePath(path): print('[%s] Updated branch %s:' % (friendly_path, cur_branch), '{}..{}'.format(local, remote), "\n", shortstat) if remote == base: print('[%s] %s is ahead. Consider pushing your changes.' % (friendly_path, local_branch)) + continue + if local_branch == cur_branch and changed: + print('[%s]' % friendly_path, 'Reapplying stashed changes.') + getGitStdout(path, ['stash', 'pop']) # Find safe branch (master/development/rc) branches = getGitStdout(path, [ -- cgit v1.2.3