2025-01-17 10:59:05 -06:00
package main
import (
2025-01-28 11:26:31 -06:00
"time"
"go.wit.com/lib/gui/shell"
2025-01-17 10:59:05 -06:00
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
2025-01-28 11:26:31 -06:00
func rillPull ( repo * gitpb . Repo ) error {
if repo . IsDirty ( ) {
// never do dirty repos
return nil
}
t , _ := repo . LastGitPull ( )
2025-01-28 21:50:07 -06:00
if time . Since ( t ) < time . Minute * 10 && ! argv . Force {
2025-01-28 11:26:31 -06:00
if argv . Verbose {
log . Info ( repo . GetFullPath ( ) , "git pulled too recently" , shell . FormatDuration ( time . Since ( t ) ) )
}
return nil
}
2025-01-28 21:50:07 -06:00
cur := repo . GetCurrentBranchName ( )
if ! repo . IsBranchRemote ( cur ) {
if argv . Verbose {
log . Info ( repo . GetFullPath ( ) , "branch is not remote" , cur )
}
return nil
}
2025-01-28 11:26:31 -06:00
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
}
// is every repo on the devel branch?
func doGitPullNew ( ) {
now := time . Now ( )
me . forge . RillFuncError ( rillPull )
count := me . forge . RillReload ( )
if count != 0 {
me . forge . ConfigSave ( )
}
total , count , nope , _ := IsEverythingOnMaster ( )
log . Printf ( "Master branch check. %d total repos. (%d git pulled) (%d not on master branch) (%s)\n" , total , count , nope , shell . FormatDuration ( time . Since ( now ) ) )
}
/ *
2025-01-17 10:59:05 -06:00
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 )
}
}
2025-01-28 11:26:31 -06:00
* /
2025-01-19 16:07:17 -06:00
// 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 ( )
}
}