From cd545c7c9f9ffe2159a4b6faa5b6451ffb9b4d02 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 23 Sep 2025 13:25:32 -0500 Subject: [PATCH] add doClean() --- Makefile | 2 +- argv.go | 1 + doList.go | 8 +++++++- main.go | 8 ++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b533cd5..d9ddf76 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ VERSION = $(shell git describe --tags) BUILDTIME = $(shell date +%s) all: build - ./forged --version + FORGE_VERBOSE=true ./forged clean # FORGE_VERBOSE=true ./forged list build: goimports diff --git a/argv.go b/argv.go index 7baf9c8..5a73c26 100644 --- a/argv.go +++ b/argv.go @@ -21,6 +21,7 @@ var argv args type args struct { Pull *EmptyCmd `arg:"subcommand:pull" help:"'git pull' on the repos"` List *EmptyCmd `arg:"subcommand:list" help:"list the repos"` + Clean *EmptyCmd `arg:"subcommand:clean" help:"clean the repos"` Gui *EmptyCmd `arg:"subcommand:gui" help:"show gui"` Merge *EmptyCmd `arg:"subcommand:merge" help:"merge in new patchsets"` Init *EmptyCmd `arg:"subcommand:init" help:"init the repo list"` diff --git a/doList.go b/doList.go index beb6187..d6ff5f4 100644 --- a/doList.go +++ b/doList.go @@ -18,9 +18,15 @@ func doClean() error { // show all the patchsets with Names for pset := range me.forge.Patchsets.IterAll() { for patch := range pset.Patches.IterAll() { - log.Info("\t", patch.CommitHash, patch.PatchId, patch.Namespace) + if patch.PatchId == "" { + log.Info("Delete", patch.CommitHash, patch.PatchId, patch.Namespace) + pset.Patches.Delete(patch) + } else { + log.Info("\t", patch.CommitHash, patch.PatchId, patch.Namespace) + } } } + me.forge.SavePatchsets() return nil } diff --git a/main.go b/main.go index 760914a..a92e365 100644 --- a/main.go +++ b/main.go @@ -44,6 +44,14 @@ func main() { okExit("") } + if argv.Clean != nil { + log.Printf("forge.Init() %s len()=%d\n", me.forge.Config.Filename, me.forge.Repos.Len()) + fhelp.DumpENV("finit:") + me.forge.Config.DumpENV() + doClean() + okExit("") + } + if argv.Merge != nil { if err := doMerge(); err != nil { badExit(err)