Skip to content

Commit ec02e4e

Browse files
author
dotfiles-bot
committed
feat: implementar --dry-run correctamente
- Pasar flag dry_run desde run_install install_module create_symlink - SymlinkManager.create_symlink retorna temprano en dry-run - Muestra [DRY-RUN] PREFIX en vez de crear symlinks reales - Mensaje inicial: DRY-RUN MODE cuando se activa el flag - No crea backups ni directorios en modo dry-run Ahora --dry-run funciona correctamente mostrando preview sin modificar sistema.
1 parent a1eb853 commit ec02e4e

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

scripts/dotfiles_installer/symlink.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def save_backup_metadata(self):
6868
print(f" ⚠ Error guardando metadata: {e}")
6969

7070
def create_symlink(self, source: Path, destination: Path, module_name: str,
71-
allow_backup: bool = True) -> bool:
71+
allow_backup: bool = True, dry_run: bool = False) -> bool:
7272
"""
7373
Create a symlink, backing up existing file if needed.
7474
@@ -77,6 +77,7 @@ def create_symlink(self, source: Path, destination: Path, module_name: str,
7777
destination: Destination path for symlink
7878
module_name: Name of module (for backup organization)
7979
allow_backup: If True, backup existing files; if False, skip if exists
80+
dry_run: If True, only show what would be done without making changes
8081
8182
Returns:
8283
True if symlink was created, False if skipped
@@ -86,6 +87,11 @@ def create_symlink(self, source: Path, destination: Path, module_name: str,
8687
print(f" ⚠ Source does not exist: {source}")
8788
return False
8889

90+
# DRY-RUN: Solo mostrar lo que se haría
91+
if dry_run:
92+
print(f" [DRY-RUN] {destination}{source}")
93+
return True # Reportar como "exitoso" para contadores
94+
8995
# Create destination parent directory
9096
destination.parent.mkdir(parents=True, exist_ok=True)
9197

scripts/install.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def check_and_install_git_lfs():
145145
def install_module(module_path: Path, config: DotfilesConfig,
146146
mapper: FileMapper, symlink_mgr: SymlinkManager,
147147
fix_eol: bool = False, fix_attribs: bool = False,
148-
allow_backup: bool = True):
148+
allow_backup: bool = True, dry_run: bool = False):
149149
"""
150150
Instala un módulo individual creando symlinks para sus archivos.
151151
@@ -157,6 +157,7 @@ def install_module(module_path: Path, config: DotfilesConfig,
157157
fix_eol: Si True, sanitiza CRLF a LF en archivos candidatos
158158
fix_attribs: Si True, establece permisos ejecutables en scripts
159159
allow_backup: Si True, crea backups de archivos existentes
160+
dry_run: Si True, solo muestra lo que se haría sin crear symlinks
160161
"""
161162
if not module_path.exists() or not module_path.is_dir():
162163
print(f"⚠ Módulo no encontrado: {module_path}")
@@ -209,7 +210,9 @@ def install_module(module_path: Path, config: DotfilesConfig,
209210

210211
# Crear symlink(s) para cada destino
211212
for dest in destinations:
212-
if symlink_mgr.create_symlink(source_to_link, dest, module_name, allow_backup=allow_backup):
213+
if symlink_mgr.create_symlink(source_to_link, dest, module_name,
214+
allow_backup=allow_backup,
215+
dry_run=dry_run):
213216
symlinks_created += 1
214217

215218
# Establecer permisos ejecutables si se solicito
@@ -693,8 +696,10 @@ def run_install(args):
693696
symlink_mgr = SymlinkManager(config.target)
694697

695698
# Iniciar sesión de backup (timestamp compartido) si no se deshabilitó
696-
if not args.no_backup:
699+
if not args.no_backup and not args.dry_run:
697700
symlink_mgr.start_backup_session()
701+
elif args.dry_run:
702+
print("🔍 DRY-RUN MODE: No se crearán symlinks ni backups\n")
698703
else:
699704
print("⚠ Backups deshabilitados (--no-backup)\n")
700705

@@ -704,7 +709,8 @@ def run_install(args):
704709
for module_path in modules:
705710
install_module(module_path, config, mapper, symlink_mgr,
706711
args.fix_eol, args.fix_attribs,
707-
allow_backup=not args.no_backup)
712+
allow_backup=not args.no_backup,
713+
dry_run=args.dry_run)
708714

709715
# Guardar metadata de backups (si se habilitaron)
710716
if not args.no_backup:

0 commit comments

Comments
 (0)