try to fix weird things with doClean()

This commit is contained in:
Jeff Carr 2025-09-25 15:02:36 -05:00
parent a377c2ed27
commit a8184b8c9e
2 changed files with 45 additions and 29 deletions

View File

@ -84,7 +84,7 @@ type DevCmd struct {
} }
type CleanCmd struct { type CleanCmd struct {
Verify *EmptyCmd `arg:"subcommand:fix" help:"try to fix problems"` Fix *EmptyCmd `arg:"subcommand:fix" help:"try to fix problems"`
Repo string `arg:"--repo" help:"which repo to look at"` Repo string `arg:"--repo" help:"which repo to look at"`
} }
@ -151,7 +151,7 @@ type ConfigAddCmd struct {
Directory bool `arg:"--directory" help:"repo is a directory to match against"` Directory bool `arg:"--directory" help:"repo is a directory to match against"`
ReadOnly bool `arg:"--readonly" help:"repo is readonly"` ReadOnly bool `arg:"--readonly" help:"repo is readonly"`
Writable bool `arg:"--writable" help:"repo is writable"` Writable bool `arg:"--writable" help:"repo is writable"`
Favorite bool `arg:"--favorite" default:"false" help:"forge will always go-clone or git clone this"` Favorite bool `arg:"--favorite" help:"forge will always go-clone or git clone this" default:"false"`
Private bool `arg:"--private" default:"false" help:"repo can not be published"` Private bool `arg:"--private" default:"false" help:"repo can not be published"`
Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"` Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"`
DebName string `arg:"--debname" help:"the name of the debian package (or rpm, etc)"` DebName string `arg:"--debname" help:"the name of the debian package (or rpm, etc)"`

View File

@ -4,9 +4,11 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"path/filepath" "path/filepath"
"go.wit.com/lib/fhelp"
"go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb" "go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log" "go.wit.com/log"
@ -97,8 +99,17 @@ func doClean() error {
// try to delete user // try to delete user
if err := doRepoCleanUser(repo); err != nil { if err := doRepoCleanUser(repo); err != nil {
if err == ErrorBranchUnique {
bname := repo.GetUserBranchName()
s := fmt.Sprintf("delete this odd user %bname branch %s?", bname, repo.FullPath)
if fhelp.QuestionUser(s) {
repo.RunVerbose([]string{"git", "branch", "-D", bname})
// repo.RunVerbose([]string{"git", "checkout", bname})
}
} else {
log.Info(repo.GetGoPath(), err) log.Info(repo.GetGoPath(), err)
} }
}
// try to delete devel // try to delete devel
doRepoCleanDevel(repo) doRepoCleanDevel(repo)
@ -232,9 +243,14 @@ func doRepoCleanUser(repo *gitpb.Repo) error {
} }
} }
return fmt.Errorf("%s branch has unique commits", bruser) if argv.Clean.Fix != nil {
} }
return ErrorBranchUnique
}
var ErrorBranchUnique error = errors.New("branch has unique commits")
// if you call this, there is no going back. no checks anymore. nothing // if you call this, there is no going back. no checks anymore. nothing
// it deletes the 'devel' branch. git branch -D "devel". END OF STORY // it deletes the 'devel' branch. git branch -D "devel". END OF STORY
func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error { func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error {