remove old code
This commit is contained in:
parent
aea7f16891
commit
b847d9aa6c
6
Makefile
6
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
|
||||
|
|
10
argv.go
10
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() {
|
||||
|
|
|
@ -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":
|
||||
|
|
29
doPull.go
29
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() {
|
||||
|
|
10
doSync.go
10
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
|
||||
}
|
||||
*/
|
||||
|
|
16
doc.go
16
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] <command> [<args>]
|
||||
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] <command> [<args>]
|
||||
|
||||
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'
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
Loading…
Reference in New Issue