-
Notifications
You must be signed in to change notification settings - Fork 9
/
repair.py
30 lines (23 loc) · 823 Bytes
/
repair.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
from core import *
class repair(Command):
"""Repair local TFS state, synchronize it with Git."""
checkoutBranch = 'master'
def initArgParser(self, parser):
Command.initArgParser(self, parser)
parser.addVerbose()
def __enter__(self):
self.switchBranch('master', True)
self.checkStatus(checkGit=True, checkTfs=False)
self.moveToRootDir()
def _run(self):
print('Restoring Git and TFS state...')
if not tf.hasPendingChanges():
print('It\'s OK')
return
with ReadOnlyWorktree():
print('Clearing TFS pending changes...')
tf('undo -recursive .', allowedExitCodes=[0, 100])
git('checkout -f ' + self.checkoutBranch)
if __name__ == '__main__':
repair().run()