feat(commit): individual packages from config respected
This commit is contained in:
+3
-2
@@ -3,9 +3,10 @@ from commands.util.diff import pkg_diff
|
||||
from commands.util.input_mgr import confirm, password
|
||||
|
||||
from commands.util.printing.diff import print_diff
|
||||
from config.dtype import ArchMgrConfig
|
||||
|
||||
|
||||
def commit(force: bool = False, no_render: bool = False):
|
||||
def commit(config: ArchMgrConfig, force: bool = False, no_render: bool = False):
|
||||
"""Commit the changes to the system
|
||||
|
||||
Args:
|
||||
@@ -15,7 +16,7 @@ def commit(force: bool = False, no_render: bool = False):
|
||||
"""
|
||||
# TODO: Make sure we don't uninstall critical system packages by accident (i.e. prompt user)
|
||||
# Probably do that check in the pacman util lib tho
|
||||
add, remove = pkg_diff([], pacman.list_explicitly_installed())
|
||||
add, remove = pkg_diff(config["pkgs"]["individual"] or [], pacman.list_explicitly_installed())
|
||||
print_diff(add, remove)
|
||||
if confirm(False, "Do you really want to proceed?"):
|
||||
pacman.install_package_list(add)
|
||||
|
||||
+5
-1
@@ -1,4 +1,8 @@
|
||||
def config():
|
||||
from config.dtype import ArchMgrConfig
|
||||
|
||||
|
||||
def config(config: ArchMgrConfig):
|
||||
print("""
|
||||
Your config can be found at
|
||||
""")
|
||||
print(config)
|
||||
|
||||
+4
-1
@@ -1,2 +1,5 @@
|
||||
def pull(rebase: bool = False, apply: bool = False):
|
||||
from config.dtype import ArchMgrConfig
|
||||
|
||||
|
||||
def pull(config: ArchMgrConfig, rebase: bool = False, apply: bool = False):
|
||||
print("pull")
|
||||
|
||||
+18
-6
@@ -12,11 +12,23 @@ def pkg_diff(target: List[str], actual: List[str]) -> tuple[List[str], List[str]
|
||||
A tuple with first the missing (not installed) packages
|
||||
and second the extraneous (to be uninstalled) packages
|
||||
"""
|
||||
for i, pkg in enumerate(actual):
|
||||
removed = []
|
||||
diffed_out = []
|
||||
for pkg in actual:
|
||||
try:
|
||||
idx = target.index(pkg)
|
||||
target.pop(idx)
|
||||
actual.pop(i)
|
||||
diffed_out.append(target.index(pkg))
|
||||
except Exception:
|
||||
pass
|
||||
return (target, actual)
|
||||
removed.append(pkg)
|
||||
|
||||
diffed_out.reverse()
|
||||
new_pkgs = []
|
||||
if len(diffed_out) > 0:
|
||||
curr = diffed_out.pop()
|
||||
for i, pkg in enumerate(target):
|
||||
if i != curr:
|
||||
new_pkgs.append(pkg)
|
||||
else:
|
||||
if len(diffed_out) > 0:
|
||||
curr = diffed_out.pop()
|
||||
|
||||
return (new_pkgs, removed)
|
||||
|
||||
Reference in New Issue
Block a user