mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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
This commit is contained in:
parent
12ee5446e9
commit
d3c0f5914f
@ -136,6 +136,11 @@ directories if they have previously been linked to a different
|
||||
object direcotry. WARNING: This may cause data to be lost since
|
||||
refs may be removed when overwriting.
|
||||
|
||||
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.
|
||||
|
||||
The --no-clone-bundle option disables any attempt to use
|
||||
$URL/clone.bundle to bootstrap a new Git repository from a
|
||||
resumeable bundle file on a content delivery network. This
|
||||
@ -197,6 +202,11 @@ later is required to fix a server side protocol bug.
|
||||
help="overwrite an existing git directory if it needs to "
|
||||
"point to a different object directory. WARNING: this "
|
||||
"may cause loss of data")
|
||||
p.add_option('--force-remove-dirty',
|
||||
dest='force_remove_dirty', action='store_true',
|
||||
help="force remove projects with uncommitted modifications if "
|
||||
"projects no longer exist in the manifest. "
|
||||
"WARNING: this may cause loss of data")
|
||||
p.add_option('-l', '--local-only',
|
||||
dest='local_only', action='store_true',
|
||||
help="only update working tree, don't fetch")
|
||||
@ -525,7 +535,7 @@ later is required to fix a server side protocol bug.
|
||||
|
||||
return 0
|
||||
|
||||
def UpdateProjectList(self):
|
||||
def UpdateProjectList(self, opt):
|
||||
new_project_paths = []
|
||||
for project in self.GetProjects(None, missing_ok=True):
|
||||
if project.relpath:
|
||||
@ -559,7 +569,11 @@ later is required to fix a server side protocol bug.
|
||||
revisionId = None,
|
||||
groups = None)
|
||||
|
||||
if project.IsDirty():
|
||||
if project.IsDirty() and opt.force_remove_dirty:
|
||||
print('WARNING: Removing dirty project "%s": uncommitted changes '
|
||||
'erased' % project.relpath, file=sys.stderr)
|
||||
self._DeleteProject(project.worktree)
|
||||
elif project.IsDirty():
|
||||
print('error: Cannot remove project "%s": uncommitted changes '
|
||||
'are present' % project.relpath, file=sys.stderr)
|
||||
print(' commit changes, then run sync again',
|
||||
@ -827,7 +841,7 @@ later is required to fix a server side protocol bug.
|
||||
# bail out now, we have no working tree
|
||||
return
|
||||
|
||||
if self.UpdateProjectList():
|
||||
if self.UpdateProjectList(opt):
|
||||
sys.exit(1)
|
||||
|
||||
syncbuf = SyncBuffer(mp.config,
|
||||
|
Loading…
Reference in New Issue
Block a user