summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go1
-rw-r--r--doPull.go46
-rw-r--r--main.go5
3 files changed, 41 insertions, 11 deletions
diff --git a/argv.go b/argv.go
index 324855c..a6b609f 100644
--- a/argv.go
+++ b/argv.go
@@ -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 {
diff --git a/doPull.go b/doPull.go
index ad9d3ef..3892b00 100644
--- a/doPull.go
+++ b/doPull.go
@@ -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
diff --git a/main.go b/main.go
index bcb464c..c050541 100644
--- a/main.go
+++ b/main.go
@@ -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 {