add 'forge commit' so I don't commit on the wrong branch
This commit is contained in:
parent
abdcd1fc62
commit
4546d067dd
2
argv.go
2
argv.go
|
@ -21,7 +21,9 @@ type args struct {
|
|||
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
|
||||
Rescan *EmptyCmd `arg:"subcommand:rescan" help:"recreate the git protobuf repos.pb file"`
|
||||
Delete *EmptyCmd `arg:"subcommand:delete" help:"untrack a repo"`
|
||||
Commit *EmptyCmd `arg:"subcommand:commit" help:"smart 'git commit'"`
|
||||
URL string `arg:"--connect" help:"gowebd url"`
|
||||
All bool `arg:"--all" help:"git commit --all"`
|
||||
Show string `arg:"--show" help:"show a repo"`
|
||||
Bash bool `arg:"--bash" help:"generate bash completion"`
|
||||
BashAuto []string `arg:"--auto-complete" help:"does the actual autocompletion"`
|
||||
|
|
|
@ -21,6 +21,8 @@ func (args) doBashAuto() {
|
|||
switch argv.BashAuto[0] {
|
||||
case "checkout":
|
||||
fmt.Println("user devel master")
|
||||
case "commit":
|
||||
fmt.Println("--all")
|
||||
case "config":
|
||||
fmt.Println("add fix list delete")
|
||||
case "list":
|
||||
|
@ -41,7 +43,7 @@ func (args) doBashAuto() {
|
|||
default:
|
||||
if argv.BashAuto[0] == ARGNAME {
|
||||
// list the subcommands here
|
||||
fmt.Println("--bash --show checkout config dirty delete hard-reset list patch pull rescan")
|
||||
fmt.Println("--bash --show checkout commit config dirty delete hard-reset list patch pull rescan")
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
|
|
21
main.go
21
main.go
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
|
@ -60,6 +61,26 @@ func main() {
|
|||
okExit("")
|
||||
}
|
||||
|
||||
if argv.Commit != nil {
|
||||
pwd, _ := os.Getwd()
|
||||
repo := me.forge.Repos.FindByFullPath(pwd)
|
||||
if repo == nil {
|
||||
log.Info("what branch are you on?: todo: examine this")
|
||||
okExit("")
|
||||
}
|
||||
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
|
||||
me.found.Append(repo)
|
||||
me.forge.PrintHumanTable(me.found)
|
||||
log.Info("")
|
||||
log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName())
|
||||
log.Info("")
|
||||
okExit("")
|
||||
}
|
||||
shell.Exec([]string{"git", "diff"})
|
||||
shell.Exec([]string{"git", "commit", "--all"})
|
||||
okExit("forge done")
|
||||
}
|
||||
|
||||
if argv.Checkout != nil {
|
||||
if argv.Checkout.User != nil {
|
||||
if argv.Force {
|
||||
|
|
Loading…
Reference in New Issue