redo doPull()

This commit is contained in:
Jeff Carr 2025-09-08 00:03:54 -05:00
parent 99de9e31bc
commit 2c7d1de637
3 changed files with 62 additions and 68 deletions

View File

@ -4,24 +4,22 @@
package main package main
import ( import (
"time"
"go.wit.com/lib/gui/shell"
"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"
) )
// is every repo on the devel branch? // is every repo on the devel branch?
func doGitPull() error { func doPull() error {
if me.forge.Config.Mode != forgepb.ForgeMode_MASTER { if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL {
if argv.Force == true { log.Info("you must check out the devel or master branches")
log.Info("okay. you have forced the issue") return nil
} else { }
log.Info("forge requres being on the master branch") if argv.Force == true {
log.Info("you must run:") log.Info("okay. you have forced the issue")
log.Info("")
log.Info("forge checkout master")
log.Info("")
return nil
}
} }
// stats := me.forge.RillFuncError(rillPull) // stats := me.forge.RillFuncError(rillPull)
@ -39,3 +37,54 @@ func doGitPull() error {
return nil return nil
} }
func rillPull(repo *gitpb.Repo) error {
if repo.IsDirty() {
// never do dirty repos
return nil
}
t, _ := repo.LastGitPull()
if time.Since(t) < time.Minute*10 && !argv.Force {
if argv.Verbose {
log.Info(repo.GetFullPath(), "git pulled too recently", shell.FormatDuration(time.Since(t)))
}
return nil
}
cur := repo.GetCurrentBranchName()
if !repo.IsBranchRemote(cur) {
if argv.Verbose {
log.Info(repo.GetFullPath(), "branch is not remote", cur)
}
return nil
}
var cmd []string
cmd = append(cmd, "git", "pull")
err := repo.RunVerbose(cmd)
if err != nil {
log.Info(repo.GetFullPath(), "git pull err:", err)
}
return nil
}
/*
// git fetch origin master:master
func rillFetchMaster(repo *gitpb.Repo) error {
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
// only fetch when branch is on the user branch
return nil
}
branch := repo.GetMasterBranchName()
cmd := []string{"git", "fetch", "origin", branch + ":" + branch}
err := repo.RunVerbose(cmd)
return err
}
func doGitFetch() {
me.forge.RillFuncError(rillFetchMaster)
count := me.forge.RillReload()
if count != 0 {
me.forge.ConfigSave()
}
}
*/

View File

@ -1,55 +0,0 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
/*
func rillPull(repo *gitpb.Repo) error {
if repo.IsDirty() {
// never do dirty repos
return nil
}
t, _ := repo.LastGitPull()
if time.Since(t) < time.Minute*10 && !argv.Force {
if argv.Verbose {
log.Info(repo.GetFullPath(), "git pulled too recently", shell.FormatDuration(time.Since(t)))
}
return nil
}
cur := repo.GetCurrentBranchName()
if !repo.IsBranchRemote(cur) {
if argv.Verbose {
log.Info(repo.GetFullPath(), "branch is not remote", cur)
}
return nil
}
var cmd []string
cmd = append(cmd, "git", "pull")
err := repo.RunVerbose(cmd)
if err != nil {
log.Info(repo.GetFullPath(), "git pull err:", err)
}
return nil
}
// git fetch origin master:master
func rillFetchMaster(repo *gitpb.Repo) error {
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
// only fetch when branch is on the user branch
return nil
}
branch := repo.GetMasterBranchName()
cmd := []string{"git", "fetch", "origin", branch + ":" + branch}
err := repo.RunVerbose(cmd)
return err
}
func doGitFetch() {
me.forge.RillFuncError(rillFetchMaster)
count := me.forge.RillReload()
if count != 0 {
me.forge.ConfigSave()
}
}
*/

View File

@ -212,7 +212,7 @@ func main() {
} }
if argv.Pull != nil { if argv.Pull != nil {
doGitPull() doPull()
okExit("") okExit("")
} }