diff options
author | Oleksii Okolielov <oleksii.okolielov@globallogic.com> | 2018-12-17 19:23:44 -0500 |
---|---|---|
committer | Oleksii Okolielov <oleksii.okolielov@globallogic.com> | 2019-03-11 13:06:49 -0400 |
commit | d3c0f5914f7cec4af75a689cf6a465708bd24969 (patch) | |
tree | f2c472d34e4e893a89d46d46be6ab6c7adb795bd /subcmds/sync.py | |
parent | 12ee5446e9eb8b9d0ae5425fb1e00bf05f93facd (diff) | |
download | git-repo-d3c0f5914f7cec4af75a689cf6a465708bd24969.tar.gz |
sync: Add option '--force-remove-dirty'
Forcefully remove dirty projects if option '--force-remove-dirty' is given.
The '--force-remove-dirty' option can be used to remove previously used
projects with uncommitted changes. WARNING: This may cause data to be lost
since uncommitted changes may be removed with projects that no longer exist
in the manifest.
Change-Id: I844a6e943ded522fdc7b1b942c0a1269768054bc
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index f6bd983d..fafc1e5c 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -136,6 +136,11 @@ directories if they have previously been linked to a different | |||
136 | object direcotry. WARNING: This may cause data to be lost since | 136 | object direcotry. WARNING: This may cause data to be lost since |
137 | refs may be removed when overwriting. | 137 | refs may be removed when overwriting. |
138 | 138 | ||
139 | The --force-remove-dirty option can be used to remove previously used | ||
140 | projects with uncommitted changes. WARNING: This may cause data to be | ||
141 | lost since uncommitted changes may be removed with projects that no longer | ||
142 | exist in the manifest. | ||
143 | |||
139 | The --no-clone-bundle option disables any attempt to use | 144 | The --no-clone-bundle option disables any attempt to use |
140 | $URL/clone.bundle to bootstrap a new Git repository from a | 145 | $URL/clone.bundle to bootstrap a new Git repository from a |
141 | resumeable bundle file on a content delivery network. This | 146 | resumeable bundle file on a content delivery network. This |
@@ -197,6 +202,11 @@ later is required to fix a server side protocol bug. | |||
197 | help="overwrite an existing git directory if it needs to " | 202 | help="overwrite an existing git directory if it needs to " |
198 | "point to a different object directory. WARNING: this " | 203 | "point to a different object directory. WARNING: this " |
199 | "may cause loss of data") | 204 | "may cause loss of data") |
205 | p.add_option('--force-remove-dirty', | ||
206 | dest='force_remove_dirty', action='store_true', | ||
207 | help="force remove projects with uncommitted modifications if " | ||
208 | "projects no longer exist in the manifest. " | ||
209 | "WARNING: this may cause loss of data") | ||
200 | p.add_option('-l', '--local-only', | 210 | p.add_option('-l', '--local-only', |
201 | dest='local_only', action='store_true', | 211 | dest='local_only', action='store_true', |
202 | help="only update working tree, don't fetch") | 212 | help="only update working tree, don't fetch") |
@@ -525,7 +535,7 @@ later is required to fix a server side protocol bug. | |||
525 | 535 | ||
526 | return 0 | 536 | return 0 |
527 | 537 | ||
528 | def UpdateProjectList(self): | 538 | def UpdateProjectList(self, opt): |
529 | new_project_paths = [] | 539 | new_project_paths = [] |
530 | for project in self.GetProjects(None, missing_ok=True): | 540 | for project in self.GetProjects(None, missing_ok=True): |
531 | if project.relpath: | 541 | if project.relpath: |
@@ -559,7 +569,11 @@ later is required to fix a server side protocol bug. | |||
559 | revisionId = None, | 569 | revisionId = None, |
560 | groups = None) | 570 | groups = None) |
561 | 571 | ||
562 | if project.IsDirty(): | 572 | if project.IsDirty() and opt.force_remove_dirty: |
573 | print('WARNING: Removing dirty project "%s": uncommitted changes ' | ||
574 | 'erased' % project.relpath, file=sys.stderr) | ||
575 | self._DeleteProject(project.worktree) | ||
576 | elif project.IsDirty(): | ||
563 | print('error: Cannot remove project "%s": uncommitted changes ' | 577 | print('error: Cannot remove project "%s": uncommitted changes ' |
564 | 'are present' % project.relpath, file=sys.stderr) | 578 | 'are present' % project.relpath, file=sys.stderr) |
565 | print(' commit changes, then run sync again', | 579 | print(' commit changes, then run sync again', |
@@ -827,7 +841,7 @@ later is required to fix a server side protocol bug. | |||
827 | # bail out now, we have no working tree | 841 | # bail out now, we have no working tree |
828 | return | 842 | return |
829 | 843 | ||
830 | if self.UpdateProjectList(): | 844 | if self.UpdateProjectList(opt): |
831 | sys.exit(1) | 845 | sys.exit(1) |
832 | 846 | ||
833 | syncbuf = SyncBuffer(mp.config, | 847 | syncbuf = SyncBuffer(mp.config, |