diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/sync.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index b7542cca..862c7e2c 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -68,9 +68,12 @@ from manifest_xml import GitcManifest | |||
| 68 | _ONE_DAY_S = 24 * 60 * 60 | 68 | _ONE_DAY_S = 24 * 60 * 60 |
| 69 | # Env var to implicitly turn off object backups. | 69 | # Env var to implicitly turn off object backups. |
| 70 | REPO_BACKUP_OBJECTS = 'REPO_BACKUP_OBJECTS' | 70 | REPO_BACKUP_OBJECTS = 'REPO_BACKUP_OBJECTS' |
| 71 | |||
| 72 | _BACKUP_OBJECTS = os.environ.get(REPO_BACKUP_OBJECTS) != '0' | 71 | _BACKUP_OBJECTS = os.environ.get(REPO_BACKUP_OBJECTS) != '0' |
| 73 | 72 | ||
| 73 | # Env var to implicitly turn auto-gc back on. | ||
| 74 | _REPO_AUTO_GC = 'REPO_AUTO_GC' | ||
| 75 | _AUTO_GC = os.environ.get(_REPO_AUTO_GC) == '1' | ||
| 76 | |||
| 74 | 77 | ||
| 75 | class _FetchOneResult(NamedTuple): | 78 | class _FetchOneResult(NamedTuple): |
| 76 | """_FetchOne return value. | 79 | """_FetchOne return value. |
| @@ -312,7 +315,7 @@ later is required to fix a server side protocol bug. | |||
| 312 | help='delete refs that no longer exist on the remote (default)') | 315 | help='delete refs that no longer exist on the remote (default)') |
| 313 | p.add_option('--no-prune', dest='prune', action='store_false', | 316 | p.add_option('--no-prune', dest='prune', action='store_false', |
| 314 | help='do not delete refs that no longer exist on the remote') | 317 | help='do not delete refs that no longer exist on the remote') |
| 315 | p.add_option('--auto-gc', action='store_true', | 318 | p.add_option('--auto-gc', action='store_true', default=None, |
| 316 | help='run garbage collection on all synced projects') | 319 | help='run garbage collection on all synced projects') |
| 317 | p.add_option('--no-auto-gc', dest='auto_gc', action='store_false', | 320 | p.add_option('--no-auto-gc', dest='auto_gc', action='store_false', |
| 318 | help='do not run garbage collection on any projects (default)') | 321 | help='do not run garbage collection on any projects (default)') |
| @@ -1219,6 +1222,11 @@ later is required to fix a server side protocol bug. | |||
| 1219 | if opt.prune is None: | 1222 | if opt.prune is None: |
| 1220 | opt.prune = True | 1223 | opt.prune = True |
| 1221 | 1224 | ||
| 1225 | if opt.auto_gc is None and _AUTO_GC: | ||
| 1226 | print(f"Will run `git gc --auto` because {_REPO_AUTO_GC} is set.", | ||
| 1227 | file=sys.stderr) | ||
| 1228 | opt.auto_gc = True | ||
| 1229 | |||
| 1222 | def Execute(self, opt, args): | 1230 | def Execute(self, opt, args): |
| 1223 | manifest = self.outer_manifest | 1231 | manifest = self.outer_manifest |
| 1224 | if not opt.outer_manifest: | 1232 | if not opt.outer_manifest: |
