feat(commit): individual packages from config respected

This commit is contained in:
2026-05-07 18:25:19 +02:00
parent b7218c2a82
commit ecb2952a7e
9 changed files with 69 additions and 16 deletions
+3 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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)