Skip to content

Commit 28d8cb6

Browse files
committed
git-sym clean
1 parent bb10f75 commit 28d8cb6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

git_sym.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ def git_sym_missing(symlinks, **arsg):
333333
missing += 1
334334
#if missing:
335335
# raise Exception(missing)
336+
def git_sym_clean(symlinks, **args):
337+
if not symlinks:
338+
symlinks = find_all_symlinks()
339+
log('clean links from %r' %symlinks)
340+
basenames = [os.path.basename(os.readlink(symlink)) for symlink in symlinks]
341+
with cd(GIT_SYM_DIR):
342+
shell('rm -f %s' %' '.join(basenames))
336343
def git_sym_fix(symlinks, old_link, **args):
337344
GIT_SYM_VIA_OLD = os.path.abspath(old_link)
338345
log('via=%r' %GIT_SYM_VIA_OLD)
@@ -354,6 +361,7 @@ def main(args):
354361
cmd_table = {
355362
'add': git_sym_add,
356363
'check': git_sym_check,
364+
'clean': git_sym_clean,
357365
'fix': git_sym_fix,
358366
'missing': git_sym_missing,
359367
'show': git_sym_show,
@@ -424,6 +432,11 @@ def parse_args():
424432
default=os.path.join(GIT_ROOT_DIR, '.git', 'git_sym'),
425433
help='[default=%(default)s]')
426434

435+
parser_clean = subs.add_parser('clean',
436+
help='Remove named or discovered links from DIR. (To remove them all, use rm.) Subsequent `git-sym update` will re-create those links and also re-run make, which *might* update cached files.')
437+
parser_clean.add_argument('symlinks', nargs='*',
438+
help='If not given, walk through tree to find relevant symlinks.')
439+
427440
parser_add = subs.add_parser('add',
428441
help='Move named files/directories to GIT_SYM_CACHE_DIR. Create git-sym symlinks in their places. "git add". You still need to "git commit" before running "git-sym update".')
429442
parser_add.add_argument('paths', nargs='+',

0 commit comments

Comments
 (0)