diff --git a/website/camweb.go b/website/camweb.go index 3e325eb5d..60040cf78 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -495,7 +495,6 @@ func setProdFlags() { "camlistore/git", "git", "clone", - "--depth=1", "https://camlistore.googlesource.com/camlistore", prodSrcDir).CombinedOutput() if err != nil { diff --git a/website/email.go b/website/email.go index ef4409adf..b92a9f7ec 100644 --- a/website/email.go +++ b/website/email.go @@ -180,7 +180,7 @@ func execGit(workdir string, mounts map[string]string, gitArgs ...string) *exec. "--rm", } for host, container := range mounts { - args = append(args, "-v", host+":"+container) + args = append(args, "-v", host+":"+container+":ro") } args = append(args, []string{ "-v", workdir + ":" + workdir, @@ -203,13 +203,13 @@ type GitCommit struct { } func pollCommits(dir string) { - cmd := execGit(dir, nil, "fetch", "origin") + cmd := execGit(dir, nil, "pull", "origin") out, err := cmd.CombinedOutput() if err != nil { - log.Printf("Error running git fetch origin master in %s: %v\n%s", dir, err, out) + log.Printf("Error running git pull origin master in %s: %v\n%s", dir, err, out) return } - log.Printf("Ran git fetch.") + log.Printf("Ran git pull.") // TODO: see if .git/refs/remotes/origin/master // changed. (quicker than running recentCommits each time) @@ -248,9 +248,7 @@ func pollCommits(dir string) { } if githubSSHKey != "" { if err := syncToGithub(dir, hashes[0]); err != nil { - log.Printf("Failed to push to github: %v", err) - } else { - log.Printf("Successfully pushed commit %v to github", hashes[0]) + log.Printf("Failed to push commit %v to github: %v", hashes[0], err) } } } diff --git a/website/github.go b/website/github.go index 0ee6eb548..abb4e6b86 100644 --- a/website/github.go +++ b/website/github.go @@ -65,18 +65,19 @@ func initGithubSyncing() error { if err := os.MkdirAll(sshDir, 0700); err != nil { return fmt.Errorf("failed to create ssh config dir %v: %v", sshDir, err) } - keyFile := filepath.Join(sshDir, "id_github_camlistorebot_push") + keyFileName := filepath.Base(githubSSHKeyGCS) + keyFile := filepath.Join(sshDir, keyFileName) if err := ioutil.WriteFile(keyFile, keyData, 0600); err != nil { - return fmt.Errorf("failed to create temp github SSH key: %v", err) + return fmt.Errorf("failed to create temp github SSH key %v: %v", keyFile, err) } if err := ioutil.WriteFile( filepath.Join(sshDir, "config"), - []byte(githubSSHConfig(keyFile)), + []byte(githubSSHConfig(keyFileName)), 0600); err != nil { return fmt.Errorf("failed to create github SSH config: %v", err) } hostSSHDir = sshDir - githubSSHKey = filepath.Base(keyFile) + githubSSHKey = keyFileName return nil } @@ -115,16 +116,18 @@ func syncToGithub(dir, gerritHEAD string) error { if err != nil { return fmt.Errorf("error looking up the github HEAD commit: %v", err) } + log.Printf("HEAD commits: on github=%v, on gerrit=%v", gh, gerritHEAD) if gh == gerritHEAD { return nil } mounts := map[string]string{ - hostSSHDir: filepath.Join("/root", ".ssh"), + hostSSHDir: "/root/.ssh", } cmd := execGit(dir, mounts, "push", "git@github.com:camlistore/camlistore.git", "master:master") out, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("error running git push to github: %v\n%s", err, out) } + log.Printf("Successfully pushed commit %v to github", gerritHEAD) return nil }