diff options
| -rw-r--r-- | argv.go | 1 | ||||
| -rw-r--r-- | doPull.go | 46 | ||||
| -rw-r--r-- | main.go | 5 |
3 files changed, 41 insertions, 11 deletions
@@ -51,6 +51,7 @@ type ShowCmd struct { Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` Repo *RepoCmd `arg:"subcommand:repos" help:"print a table of the current repos"` Tag *TagCmd `arg:"subcommand:tag" help:"show git tags"` + Urls *EmptyCmd `arg:"subcommand:urls" help:"show repo urls"` } func (ShowCmd) Examples() string { @@ -12,6 +12,21 @@ import ( "go.wit.com/log" ) +func updateURL(repo *gitpb.Repo) bool { + found := me.forge.Repos.FindByNamespace(repo.Namespace) + if found == nil { + return false + } + if repo.URL == found.URL { + return false + } + cmd := []string{"git", "remote", "set-url", "origin", repo.URL} + found.URL = repo.URL + log.Infof("%s update URL to %v\n", found.URL, cmd) + found.Run(cmd) + return true +} + // returns true if 'git pull' should be run func needToUpdateRepo(repo *gitpb.Repo) (*gitpb.Repo, error) { if repo.Tags == nil { @@ -83,19 +98,28 @@ func doPull() error { // log.Infof("pull check %s pb.Len()=%d client.Len()=%d server.Len()=%d err=%v\n", regPB.URL, updatepb.Len(), regPB.ClientDataLen, regPB.ServerDataLen, err) log.Infof("pull check pb.Len()=%d\n", updatepb.Len()) for repo := range updatepb.IterAll() { - found, _ := needToUpdateRepo(repo) - if found == nil { + if updateURL(repo) { + count += 1 continue } - // found.RunVerbose([]string{"git", "pull", "origin", found.GetMasterBranchName()}) - found.CheckoutMaster() - found.GitPull() - found.ReloadCheck() - found.GitPull() - if count > 10 { - break - } - count += 1 + /* + found, _ := needToUpdateRepo(repo) + if found == nil { + continue + } + if !argv.Force { + continue + } + // found.RunVerbose([]string{"git", "pull", "origin", found.GetMasterBranchName()}) + found.CheckoutMaster() + found.GitPull() + found.ReloadCheck() + found.GitPull() + if count > 10 { + break + } + count += 1 + */ } me.forge.SaveRepos() return nil @@ -162,6 +162,11 @@ func main() { doTag() okExit("") } + + if argv.Show.Urls != nil { + me.forge.PrintForgedTable(me.forge.Repos) + okExit("") + } found := findRepos() // print out the repos if argv.All { |
