From b847d9aa6ca4ee1b60687643cd04c9e6f46ad310 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 3 Sep 2025 19:39:02 -0500 Subject: [PATCH] remove old code --- Makefile | 6 ++ argv.go | 10 +--- argvAutoshell.go | 8 +-- doPull.go | 29 +-------- doSync.go | 10 +--- doc.go | 16 ++--- gitconfig_parser.go | 143 -------------------------------------------- main.go | 9 +-- 8 files changed, 22 insertions(+), 209 deletions(-) delete mode 100644 gitconfig_parser.go diff --git a/Makefile b/Makefile index fabc4c6..7165515 100644 --- a/Makefile +++ b/Makefile @@ -75,3 +75,9 @@ submit: commit: FORGE_URL="https://forge.grid.wit.com/" forge commit --all + +doc: + echo "/*" > doc.go + forge -h >> doc.go + echo "*/" >> doc.go + echo "package main" >> doc.go diff --git a/argv.go b/argv.go index e1f855d..2479510 100644 --- a/argv.go +++ b/argv.go @@ -23,8 +23,8 @@ type args struct { Dirty *DirtyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"` List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"` - Normal *EmptyCmd `arg:"subcommand:normal" help:"set every repo to the default state for software development"` Merge *MergeCmd `arg:"subcommand:merge" help:"merge branches"` + Normal *EmptyCmd `arg:"subcommand:normal" help:"set every repo to the default state for software development"` Patch *PatchCmd `arg:"subcommand:patch" help:"make patchsets"` Pull *PullCmd `arg:"subcommand:pull" help:"run 'git pull'"` URL string `arg:"--connect" help:"forge url"` @@ -76,7 +76,6 @@ type PullCmd struct { Check *EmptyCmd `arg:"subcommand:check" help:"check repo versions"` Dirty *EmptyCmd `arg:"subcommand:dirty" help:"only check dirty repos"` Patches *EmptyCmd `arg:"subcommand:patches" help:"only check repos with patches"` - Sync *SyncCmd `arg:"subcommand:sync" help:"sync repos with upstream"` } type ConfigAddCmd struct { @@ -118,11 +117,6 @@ type MergeCmd struct { Publish *EmptyCmd `arg:"subcommand:publish" help:"increment versions and publish master branch"` } -type SyncCmd struct { - Clean *EmptyCmd `arg:"subcommand:clean" help:"sync everything to upstream master"` - User *EmptyCmd `arg:"subcommand:user" help:"sync everything to user"` -} - type DirtyCmd struct { } @@ -146,7 +140,7 @@ func (a args) Description() string { forge -- a tool to manage lots of git repos. forge includes a GUI and TUI. forge only executes the 'git' command. Everything it does, you can run by hand with 'git'. - ` +` } func (args) doBashHelpDebug() { diff --git a/argvAutoshell.go b/argvAutoshell.go index 75e53bb..54b4e88 100644 --- a/argvAutoshell.go +++ b/argvAutoshell.go @@ -24,7 +24,7 @@ func (args) doBashAuto() { argv.doBashHelp() switch argv.BashAuto[0] { case "checkout": - fmt.Println("user devel master ") + fmt.Println("devel master user") case "clean": // me.pp.WriteHelp(os.Stderr) // me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...) @@ -48,17 +48,13 @@ func (args) doBashAuto() { case "merge": fmt.Println("devel master") case "pull": - fmt.Println("dirty clean list patches sync --force") - case "--find": - fmt.Println("foo bar") + fmt.Println("dirty clean list patches --force") case "patch": fmt.Println("get list submit show") case "user": fmt.Println("--force") case "devel": fmt.Println("--force") - case "sync": - fmt.Println("clean user --force") case "master": fmt.Println("") case "verify": diff --git a/doPull.go b/doPull.go index 098bd31..a3ce6d6 100644 --- a/doPull.go +++ b/doPull.go @@ -43,7 +43,7 @@ func rillPull(repo *gitpb.Repo) error { // is every repo on the devel branch? -func doGitPullNew() error { +func doGitPull() error { if argv.Pull == nil { return fmt.Errorf("not really 'fetch pull'") } @@ -138,33 +138,6 @@ func doGitPullNew() error { } -/* -func doGitPull() { - allerr := me.found.RillGitPull(40, 5) - - all := me.found.SortByFullPath() - for all.Scan() { - repo := all.Next() - result := allerr[repo] - if result.Error == gitpb.ErrorGitPullOnDirty { - log.Info("skip git pull. repo is dirty", repo.GetGoPath()) - continue - } - if result.Error == gitpb.ErrorGitPullOnLocal { - log.Info("skip git pull. local branch ", repo.GetGoPath()) - continue - } - if result.Exit == 0 { - continue - } - - log.Info("git pull error:", repo.GetGoPath(), result.Error) - log.Info("git pull error:", repo.GetGoPath(), result.Stdout) - } - -} -*/ - // git fetch origin master:master func rillFetchMaster(repo *gitpb.Repo) error { if repo.GetCurrentBranchName() != repo.GetUserBranchName() { diff --git a/doSync.go b/doSync.go index 5ddd11d..02fa8b0 100644 --- a/doSync.go +++ b/doSync.go @@ -3,16 +3,9 @@ package main -import ( - "fmt" - "path/filepath" - - "go.wit.com/lib/protobuf/gitpb" - "go.wit.com/log" -) - // trys to figure out if there is still something to update +/* func doSync() error { if argv.Pull.Sync.Clean != nil { return doSyncClean() @@ -83,3 +76,4 @@ func syncDevelBranches() error { } return nil } +*/ diff --git a/doc.go b/doc.go index 725de11..ab1cce7 100644 --- a/doc.go +++ b/doc.go @@ -1,13 +1,10 @@ /* -forge -- a tool to git repos at go.wit.com +forge -- a tool to manage lots of git repos. forge includes a GUI and TUI. - but you can probably use it for other things + forge only executes the 'git' command. Everything it does, you can run by hand with 'git'. -A video demonstration of the terminal UI is available at: -https://mirrors.wit.com/guidemo/forge-gocui-demo.webm - -forge v0.22.124-2-g8c25ed1 Built on 2025.07.21_1348 -Usage: forge [--debugger] [--logger] [--no-gui] [--gui GUI] [--gui-file GUI-FILE] [--gui-test GUI-TEST] [--gui-verbose] [--connect CONNECT] [--all] [--build BUILD] [--install INSTALL] [--forge-rebuild] [--force] [--verbose] [--bash] [--auto-complete AUTO-COMPLETE] [] +forge v0.22.138-6-gaea7f16 Built on 2025.09.03_1935 +Usage: forge [--debugger] [--logger] [--no-gui] [--gui GUI] [--gui-file GUI-FILE] [--gui-build] [--gui-verbose] [--gui-check-plugin GUI-CHECK-PLUGIN] [--connect CONNECT] [--all] [--build BUILD] [--install INSTALL] [--forge-rebuild] [--force] [--verbose] [--bash] [--auto-complete AUTO-COMPLETE] [] Options: @@ -16,8 +13,10 @@ Options: --no-gui ignore all these gui problems --gui GUI Use this gui toolkit [andlabs,gocui,nocui,stdin] --gui-file GUI-FILE Use a specific plugin.so file - --gui-test GUI-TEST test a specific plugin.so will load + --gui-build attempt to build the GUI plugins --gui-verbose enable all logging + --gui-check-plugin GUI-CHECK-PLUGIN + hack to verify GO plugins load --connect CONNECT forge url --all git commit --all --build BUILD build a repo @@ -42,6 +41,7 @@ Commands: fetch run 'git fetch master' list print a table of the current repos merge merge branches + normal set every repo to the default state for software development patch make patchsets pull run 'git pull' */ diff --git a/gitconfig_parser.go b/gitconfig_parser.go deleted file mode 100644 index edab556..0000000 --- a/gitconfig_parser.go +++ /dev/null @@ -1,143 +0,0 @@ -package main - -// playing with gemini to do simple tasks. it kicked this out - -import ( - "bufio" - "errors" - "fmt" - "os" - "path/filepath" - "strings" -) - -// ParsedGitConfig represents the structure of a .gitconfig file, -// which is a map of section names to a map of their key-value pairs. -// For example: -// -// { -// "user": { -// "name": "John Doe", -// "email": "john.doe@example.com", -// }, -// "core": { -// "editor": "vim", -// }, -// } -type ParsedGitConfig map[string]map[string]string - -// ParseGlobalGitConfig finds and parses the global .gitconfig file for the current user. -// It is platform-agnostic and works on Windows, macOS, and Linux. -// It returns the parsed configuration or an error if the file cannot be found or read. -func ParseGlobalGitConfig() (ParsedGitConfig, error) { - // os.UserHomeDir() is the platform-agnostic way to get the user's home directory. - homeDir, err := os.UserHomeDir() - if err != nil { - return nil, fmt.Errorf("could not get user home directory: %w", err) - } - - // filepath.Join correctly constructs the path for the current OS. - gitConfigPath := filepath.Join(homeDir, ".gitconfig") - - file, err := os.Open(gitConfigPath) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - return nil, fmt.Errorf(".gitconfig file not found at %s", gitConfigPath) - } - return nil, fmt.Errorf("could not open .gitconfig file: %w", err) - } - defer file.Close() - - config := make(ParsedGitConfig) - var currentSection string - scanner := bufio.NewScanner(file) - - for scanner.Scan() { - line := strings.TrimSpace(scanner.Text()) - - // Ignore empty lines and comments - if line == "" || line[0] == '#' || line[0] == ';' { - continue - } - - // Check for a new section - if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") { - sectionName := line[1 : len(line)-1] - // Handle subsections like [remote "origin"] by splitting them. - // For simplicity, we'll just use the full string as the key. - // A more complex parser might create nested maps. - currentSection = strings.TrimSpace(sectionName) - if _, exists := config[currentSection]; !exists { - config[currentSection] = make(map[string]string) - } - continue - } - - // Parse key-value pairs within a section - if currentSection != "" { - // Split by "=". Use SplitN to handle values that might contain "=". - parts := strings.SplitN(line, "=", 2) - if len(parts) == 2 { - key := strings.TrimSpace(parts[0]) - value := strings.TrimSpace(parts[1]) - config[currentSection][key] = value - } - } - } - - if err := scanner.Err(); err != nil { - return nil, fmt.Errorf("error reading .gitconfig file: %w", err) - } - - return config, nil -} - -// GetValue retrieves a specific value from the parsed git config. -// It takes the section and key as input (e.g., "user", "name"). -// It returns the value and a boolean indicating if the key was found. -func (c ParsedGitConfig) GetValue(section, key string) (string, bool) { - if sectionMap, ok := c[section]; ok { - if value, ok := sectionMap[key]; ok { - return value, true - } - } - return "", false -} - -/* -// main function to demonstrate the usage of ParseGlobalGitConfig. -func main() { - config, err := ParseGlobalGitConfig() - if err != nil { - fmt.Fprintf(os.Stderr, "Error: %v\n", err) - os.Exit(1) - } - - fmt.Println("Successfully parsed global .gitconfig file.") - fmt.Println("-----------------------------------------") - - // Example of using GetValue to retrieve the user's name and email. - userName, found := config.GetValue("user", "name") - if found { - fmt.Printf("User Name: %s\n", userName) - } else { - fmt.Println("User name not found.") - } - - userEmail, found := config.GetValue("user", "email") - if found { - fmt.Printf("User Email: %s\n", userEmail) - } else { - fmt.Println("User email not found.") - } - - fmt.Println("\nFull configuration:") - // Print out the full parsed configuration - for section, keys := range config { - fmt.Printf("[%s]\n", section) - for key, value := range keys { - fmt.Printf(" %s = %s\n", key, value) - } - } -} -*/ diff --git a/main.go b/main.go index c5ecf39..a4ab11b 100644 --- a/main.go +++ b/main.go @@ -165,14 +165,7 @@ func main() { } if argv.Pull != nil { - if argv.Pull.Sync != nil { - if err := doSync(); err != nil { - badExit(err) - } - okExit("") - } - - doGitPullNew() + doGitPull() okExit("") }