use RillRepo()
This commit is contained in:
parent
52c9fece43
commit
ef6da4aa17
57
doSync.go
57
doSync.go
|
@ -5,10 +5,12 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"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/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,12 +41,15 @@ func doSyncClean() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// force everything
|
||||||
|
argv.Force = true
|
||||||
|
|
||||||
if err := doCleanUser(); err != nil {
|
if err := doCleanUser(); err != nil {
|
||||||
badExit(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := doCleanDevel(); err != nil {
|
if err := doCleanDevel(); err != nil {
|
||||||
badExit(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
@ -55,19 +60,65 @@ func doSyncClean() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
total, count, nope, _ := IsEverythingOnMaster()
|
total, count, nope, _ := IsEverythingOnMaster()
|
||||||
log.Printf("Master branch check. %d total repos. (%d git pulled) (%d not on master branch) (%s) git pull total=%d\n", total, count, nope, shell.FormatDuration(time.Since(now)), pullcount)
|
log.Printf("doSyncClean() ok. %d total repos. (%d git pulled) (%d not on master branch) (%s) git pull total=%d\n", total, count, nope, shell.FormatDuration(time.Since(now)), pullcount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func doSyncUser() error {
|
func doSyncUser() error {
|
||||||
|
if count, err := me.forge.RillRepo(10, 20, syncDevelBranch); err != nil {
|
||||||
|
log.Info("RillFunc() failed", err)
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
log.Info("Rill syncDevelBranch() ok count =", count)
|
||||||
|
}
|
||||||
|
|
||||||
me.argvCheckoutUser = true
|
me.argvCheckoutUser = true
|
||||||
me.forge.Config.Mode = forgepb.ForgeMode_USER
|
me.forge.Config.Mode = forgepb.ForgeMode_USER
|
||||||
me.forge.Config.ConfigSave()
|
me.forge.Config.ConfigSave()
|
||||||
|
|
||||||
|
argv.Force = true
|
||||||
if err := doCheckoutShared(); err != nil {
|
if err := doCheckoutShared(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func syncDevelBranch(repo *gitpb.Repo) error {
|
||||||
|
branch := repo.GetDevelBranchName()
|
||||||
|
if repo.Exists(filepath.Join(".git/refs/heads", branch)) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if repo.Exists(filepath.Join(".git/refs/remotes/origin", branch)) {
|
||||||
|
cmd := []string{"git", "checkout", branch}
|
||||||
|
err := repo.RunVerbose(cmd)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd := []string{"git", "branch", branch}
|
||||||
|
repo.RunVerbose(cmd)
|
||||||
|
cmd = []string{"git", "checkout", branch}
|
||||||
|
err := repo.RunVerbose(cmd)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func syncDevelBranches() error {
|
||||||
|
all := me.forge.Repos.SortByFullPath()
|
||||||
|
for all.Scan() {
|
||||||
|
repo := all.Next()
|
||||||
|
branch := repo.GetDevelBranchName()
|
||||||
|
if repo.Exists(filepath.Join(".git/refs/heads", branch)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.Exists(filepath.Join(".git/refs/remotes/origin", branch)) {
|
||||||
|
cmd := []string{"git", "checkout", branch}
|
||||||
|
repo.RunVerbose(cmd)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cmd := []string{"git", "branch", branch}
|
||||||
|
repo.RunVerbose(cmd)
|
||||||
|
cmd = []string{"git", "checkout", branch}
|
||||||
|
repo.RunVerbose(cmd)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue