diff options
author | André Glüpker <git@wgmd.de> | 2019-01-13 19:51:39 +0100 |
---|---|---|
committer | André Glüpker <git@wgmd.de> | 2019-01-13 19:51:39 +0100 |
commit | 57eaebb6e6d7b30831b086fe59a8a2b49c08215b (patch) | |
tree | a2bcce737f7ae4978204230935dfb4dbc2e5fe91 /updateGit.py | |
parent | 9bf6c0562f02c31660930c9a8290fac7fe338c3b (diff) | |
download | update-git-57eaebb6e6d7b30831b086fe59a8a2b49c08215b.tar.gz update-git-57eaebb6e6d7b30831b086fe59a8a2b49c08215b.tar.bz2 update-git-57eaebb6e6d7b30831b086fe59a8a2b49c08215b.zip |
Stash branch, if if has local changes
Diffstat (limited to 'updateGit.py')
-rwxr-xr-x | updateGit.py | 10 |
1 files 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, [ |