From 87e0bc24fad2baa7dfde5151705000ae7845e88d Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Sun, 5 May 2024 09:43:15 +0200 Subject: [PATCH] feat[close #106]: Prevent pkg apply to apply changes if already applied --- cmd/pkg.go | 11 +++++++++++ locales/en.yml | 1 + 2 files changed, 12 insertions(+) diff --git a/cmd/pkg.go b/cmd/pkg.go index 9c14efc7..05d97083 100644 --- a/cmd/pkg.go +++ b/cmd/pkg.go @@ -155,6 +155,17 @@ func pkg(cmd *cobra.Command, args []string) error { cmdr.Info.Printf(abroot.Trans("pkg.listMsg"), added, removed) return nil case "apply": + unstaged, err := pkgM.GetUnstagedPackages() + if err != nil { + cmdr.Error.Println(err) + return err + } + + if len(unstaged) == 0 { + cmdr.Info.Println(abroot.Trans("pkg.noChanges")) + return nil + } + aBsys, err := core.NewABSystem() if err != nil { cmdr.Error.Println(err) diff --git a/locales/en.yml b/locales/en.yml index 10c20817..d6e3b714 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -47,6 +47,7 @@ pkg: applyFailed: "Apply command failed: %s\n" removedMsg: "Package(s) %s removed.\n" listMsg: "Added packages:\n%s\nRemoved packages:\n%s\n" + noChanges: "No changes to apply." dryRunFlag: "perform a dry run of the operation" forceEnableUserAgreementFlag: "force enable user agreement, for embedded systems" agreementMsg: "To utilize ABRoot's abroot pkg command, explicit user agreement is required. This command facilitates package installations but introduces non-deterministic elements, impacting system trustworthiness. By consenting, you acknowledge and accept these implications, confirming your awareness of the command's potential impact on system behavior. [y/N]: "