From bf9874af6b27901f5d9ecb90407649c7f8bd21df Mon Sep 17 00:00:00 2001 From: EnumDev Date: Sun, 11 Jan 2026 11:50:03 +0200 Subject: [PATCH] bpm-repo: add 'apply' flag to 'check-versions' subcommand --- src/bpm-repo/main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/bpm-repo/main.go b/src/bpm-repo/main.go index 85d654a..c5fed56 100644 --- a/src/bpm-repo/main.go +++ b/src/bpm-repo/main.go @@ -3,6 +3,7 @@ package main import ( bpmutilsshared "bpm-utils-shared" "bufio" + "bytes" "context" "fmt" "io/fs" @@ -85,6 +86,7 @@ func main() { flagset := flag.NewFlagSet("check-versions", flag.ExitOnError) flagset.BoolP("verbose", "v", false, "Show additional information about the current operation") flagset.BoolP("force", "f", false, "Force current operation to bypass certain conditions") + flagset.BoolP("apply", "a", false, "Apply new versions to packages") setupFlagsAndHelp(flagset, fmt.Sprintf("bpm-repo %s ", subcommand), "Manage BPM repositories and databases", os.Args[2:]) currentFlagSet = flagset @@ -126,6 +128,7 @@ func checkVersionsFunc(repo string) { // Get flags verbose, _ := currentFlagSet.GetBool("verbose") force, _ := currentFlagSet.GetBool("force") + apply, _ := currentFlagSet.GetBool("apply") // Read environment files err := readEnvFile(repo) @@ -241,6 +244,23 @@ func checkVersionsFunc(repo string) { OldVersion: pkgInfo.Version, NewVersion: latestVersion, } + + // Apply new version + pkgInfo.Version = latestVersion + pkgInfo.Revision = 1 + if apply { + var data bytes.Buffer + encoder := yaml.NewEncoder(&data) + encoder.SetIndent(2) + encoder.Encode(pkgInfo) + + fmt.Println(path.Join(dir, "pkg.info")) + err := os.WriteFile(path.Join(dir, "pkg.info"), data.Bytes(), 0644) + if err != nil { + log.Printf("Warning: could not write new version for package (%s) to file: %s", pkgInfo.Name, err) + } + } + continue }