summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--handleRepos.go23
-rw-r--r--http.go7
2 files changed, 28 insertions, 2 deletions
diff --git a/handleRepos.go b/handleRepos.go
index 20cf66c..ac28c7f 100644
--- a/handleRepos.go
+++ b/handleRepos.go
@@ -69,6 +69,29 @@ func checkRequest(pb *gitpb.Repos, reqPB *httppb.HttpRequest) *gitpb.Repos {
// don't know about this
continue
}
+ if found.GetURL() != repo.GetURL() {
+ log.Infof("'%s' url %s mismatch %s\n", found.FullPath, found.GetURL(), repo.GetURL())
+ }
+ checkPB.Append(found)
+ }
+ return checkPB
+}
+
+func updateURLs(pb *gitpb.Repos, reqPB *httppb.HttpRequest) *gitpb.Repos {
+ checkPB := gitpb.NewRepos()
+ for repo := range pb.IterAll() {
+ found := me.forge.Repos.FindByNamespace(repo.Namespace)
+ if found == nil {
+ log.Infof("found == nil namespace=%s\n", repo.Namespace)
+ continue
+ }
+ if found.GetURL() != repo.GetURL() {
+ log.Infof("'%s' url %s mismatch %s\n", found.FullPath, found.GetURL(), repo.GetURL())
+ cmd := []string{"git", "remote", "set-url", "origin", repo.GetURL()}
+ found.RunVerbose(cmd)
+ } else {
+ // log.Infof("'%s' url %s == %s\n", found.FullPath, found.GetURL(), repo.GetURL())
+ }
checkPB.Append(found)
}
return checkPB
diff --git a/http.go b/http.go
index 22db236..ad1e2c0 100644
--- a/http.go
+++ b/http.go
@@ -38,7 +38,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(route, "/repos/") {
pb := gitpb.NewRepos()
if err := pb.Unmarshal(reqPB.ClientData); err == nil {
- reqPB.Logf("Repos Unmarshal() len=%d", pb.Len())
+ reqPB.Logf("http recieved %d repos", pb.Len())
} else {
reqPB.Logf("Repos Unmarshal() err=%v", err)
}
@@ -47,13 +47,16 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
case "/repos/check":
result = checkRequest(pb, reqPB)
reqPB.Logf("repos check result.Len()=%d pb.Len()=%d", result.Len(), pb.Len())
+ case "/repos/updateURL":
+ result = updateURLs(pb, reqPB)
+ reqPB.Logf("repo urls sent len=%d updated len=%d", result.Len(), pb.Len())
case "/repos/pull":
result = pullRequest(pb, reqPB)
case "/repos/add":
result = addRequest(pb, reqPB)
default:
reqPB.Logf("repos check result.Len()=%d pb.Len()=%d", result.Len(), pb.Len())
- log.Info("repos", route, "unknown")
+ log.Info("UNKNOWN ROUTE:", route)
}
if err := result.SendReply(w, reqPB); err != nil {
reqPB.Logf("Oh well, Send to client failed. err=%v", err)