File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ class InstallCommand(EnvCommand):
19
19
"Output the operations but do not execute anything "
20
20
"(implicitly enables --verbose)." ,
21
21
),
22
+ option (
23
+ "keep-untracked" ,
24
+ None ,
25
+ "Does not remove packages not present in the lock file." ,
26
+ ),
22
27
option (
23
28
"extras" ,
24
29
"E" ,
@@ -58,6 +63,7 @@ def handle(self):
58
63
installer .extras (extras )
59
64
installer .dev_mode (not self .option ("no-dev" ))
60
65
installer .dry_run (self .option ("dry-run" ))
66
+ installer .keep_untracked (self .option ("keep-untracked" ))
61
67
installer .verbose (self .option ("verbose" ))
62
68
63
69
return_code = installer .run ()
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def __init__(
39
39
self ._pool = pool
40
40
41
41
self ._dry_run = False
42
+ self ._keep_untracked = False
42
43
self ._update = False
43
44
self ._verbose = False
44
45
self ._write_lock = True
@@ -83,6 +84,14 @@ def dry_run(self, dry_run=True): # type: (bool) -> Installer
83
84
def is_dry_run (self ): # type: () -> bool
84
85
return self ._dry_run
85
86
87
+ def keep_untracked (self , keep_untracked = True ): # type: (bool) -> Installer
88
+ self ._keep_untracked = keep_untracked
89
+
90
+ return self
91
+
92
+ def is_keep_untracked (self ): # type: () -> bool
93
+ return self ._keep_untracked
94
+
86
95
def verbose (self , verbose = True ): # type: (bool) -> Installer
87
96
self ._verbose = verbose
88
97
@@ -424,6 +433,17 @@ def _get_operations_from_lock(
424
433
425
434
ops .append (op )
426
435
436
+ if not self ._keep_untracked :
437
+ for installed in installed_repo .packages :
438
+ is_in_lock_file = False
439
+ for locked in locked_repository .packages :
440
+ if locked .name == installed .name :
441
+ is_in_lock_file = True
442
+ break
443
+
444
+ if not is_in_lock_file :
445
+ ops .append (Uninstall (installed ))
446
+
427
447
return ops
428
448
429
449
def _filter_operations (
You can’t perform that action at this time.
0 commit comments