update auto complete. merge is smarter
This commit is contained in:
parent
684c5b1dad
commit
86ac85dd5b
|
@ -20,12 +20,12 @@ import (
|
|||
func (args) doBashAuto() {
|
||||
argv.doBashHelp()
|
||||
switch argv.BashAuto[0] {
|
||||
case "list":
|
||||
fmt.Println("--terminals")
|
||||
case "merge":
|
||||
fmt.Println("--force")
|
||||
default:
|
||||
if argv.BashAuto[0] == ARGNAME {
|
||||
// list the subcommands here
|
||||
fmt.Println("--pull list")
|
||||
fmt.Println("list merge")
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
|
|
31
doList.go
31
doList.go
|
@ -1,7 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
|
@ -14,21 +15,37 @@ func doList() error {
|
|||
badExit(err)
|
||||
}
|
||||
|
||||
// first show the general patchset protobuf
|
||||
for pb := range me.all.IterAll() {
|
||||
if pb.Name == "forge auto commit" {
|
||||
showPatchsets(pb)
|
||||
}
|
||||
}
|
||||
|
||||
// show all the patchsets with Names
|
||||
for pset := range me.all.IterAll() {
|
||||
if pset.Name == "forge auto commit" {
|
||||
continue
|
||||
}
|
||||
showPatchsets(pset)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func cleanSubject(line string) string {
|
||||
// Regular expression to remove "Subject:" and "[PATCH...]" patterns
|
||||
re := regexp.MustCompile(`(?i)^Subject:\s*(\[\s*PATCH[^\]]*\]\s*)?`)
|
||||
cleaned := re.ReplaceAllString(line, "")
|
||||
return strings.TrimSpace(cleaned)
|
||||
}
|
||||
|
||||
func showPatchsets(pb *forgepb.Patchset) error {
|
||||
author := "Author: " + pb.GitAuthorName
|
||||
author += " <" + pb.GitAuthorEmail + ">"
|
||||
|
||||
// author := "Author: " + os.Getenv("GIT_AUTHOR_NAME")
|
||||
// author += " <" + os.Getenv("GIT_AUTHOR_EMAIL") + ">"
|
||||
fmt.Println(pb.Name, pb.Comment, author)
|
||||
for i, patches := range pb.Patches.Patches {
|
||||
log.Info("\tnew patches:", i, patches.CommitHash, patches.Namespace)
|
||||
log.Printf("%-16s %s %s %s\n", string(pb.Uuid)[0:8], pb.Name, pb.Comment, author)
|
||||
for _, patch := range pb.Patches.Patches {
|
||||
comment := cleanSubject(patch.Comment)
|
||||
log.Printf("\t%-8s %-50s %-50s\n", string(patch.CommitHash)[0:8], patch.Namespace, comment)
|
||||
}
|
||||
/*
|
||||
for patch := range pb.IterAll() {
|
||||
|
|
42
doMerge.go
42
doMerge.go
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
@ -12,8 +13,12 @@ import (
|
|||
|
||||
func doMerge() error {
|
||||
if err := loadConfigfile(); err != nil {
|
||||
if argv.Force == true {
|
||||
me.all = forgepb.NewPatchsets()
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
mergePatchsets()
|
||||
|
||||
|
@ -24,30 +29,39 @@ func doMerge() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func findAutoPatchset() *forgepb.Patchset {
|
||||
|
||||
for pset := range me.all.IterAll() {
|
||||
if pset.Name == "forge auto commit" {
|
||||
return pset
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var fauto *forgepb.Patchset
|
||||
log.Warn("findAutoPatchset() had to create 'forge auto commit'")
|
||||
if fauto == nil {
|
||||
fauto = new(forgepb.Patchset)
|
||||
fauto.Name = "forge auto commit"
|
||||
fauto.Patches = forgepb.NewPatches()
|
||||
fauto.Uuid = uuid.New().String()
|
||||
me.all.Patchsets = append(me.all.Patchsets, fauto)
|
||||
}
|
||||
return fauto
|
||||
}
|
||||
|
||||
// adds submitted patches not specifically assigned to a patchset
|
||||
// to the generic patchset called "forge auto commit"
|
||||
func addRandomPatch(patch *forgepb.Patch) error {
|
||||
var fauto *forgepb.Patchset
|
||||
|
||||
// ignore patch if it's already here
|
||||
if findPatch(patch) {
|
||||
log.Info("already found patch", patch.CommitHash, patch.Namespace)
|
||||
return nil
|
||||
}
|
||||
for pset := range me.all.IterAll() {
|
||||
if pset.Name == "forge auto commit" {
|
||||
fauto = pset
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
fauto := findAutoPatchset()
|
||||
if fauto == nil {
|
||||
fauto = new(forgepb.Patchset)
|
||||
fauto.Name = "forge auto commit"
|
||||
fauto.Patches = forgepb.NewPatches()
|
||||
me.all.Patchsets = append(me.all.Patchsets, fauto)
|
||||
log.Warn("had to create 'forge auto commit' patchset")
|
||||
// return log.Errorf("no default place yet")
|
||||
return log.Errorf("no default place yet")
|
||||
}
|
||||
newpb := proto.Clone(patch).(*forgepb.Patch)
|
||||
if newpb == nil {
|
||||
|
|
Loading…
Reference in New Issue