[CD] Fix gitiles error for ListFilesRecursiveAtRef

We're using a With2xxOnly client, but gitiles was redirecting us from
".../." to ".../" which caused an error.  The other solution would be to
pass in "" instead of "." but I preferred to make the API less error-
prone.

Change-Id: I25c8c0c7cba3981ba88cdebfe65cc64b79f0e563
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/605018
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
Auto-Submit: Eric Boren <borenet@google.com>
diff --git a/autoroll/go/autoroll-config-converter/main.go b/autoroll/go/autoroll-config-converter/main.go
index c2b7bb4..380e046 100644
--- a/autoroll/go/autoroll-config-converter/main.go
+++ b/autoroll/go/autoroll-config-converter/main.go
@@ -200,7 +200,7 @@
 				td.Fatalf(ctx, "failed to process template file %s: %s", srcFile, err)
 			}
 			for path, cfgBytes := range generatedConfigs {
-				if err := convertConfig(ctx, cfgBytes, path, generatedConfigs); err != nil {
+				if err := convertConfig(ctx, cfgBytes, path, generatedContents); err != nil {
 					td.Fatalf(ctx, "failed to convert config %s: %s", srcFile, err)
 				}
 			}
@@ -229,7 +229,7 @@
 	// Upload a CL.
 	if len(changes) > 0 {
 		commitSubject := "Update autoroll k8s configs"
-		if err := cd.UploadCL(ctx, changes, "k8s-config", dstBaseCommit, commitSubject, *srcRepo, *srcCommit, *louhiPubsubProject, *louhiExecutionID); err != nil {
+		if err := cd.UploadCL(ctx, changes, "https://skia.googlesource.com/k8s-config.git", dstBaseCommit, commitSubject, *srcRepo, *srcCommit, *louhiPubsubProject, *louhiExecutionID); err != nil {
 			td.Fatalf(ctx, "Failed to create CL: %s", err)
 		}
 	}
@@ -254,7 +254,7 @@
 	// Decode the config file.
 	var cfg config.Config
 	if err := prototext.Unmarshal(cfgBytes, &cfg); err != nil {
-		return skerr.Wrapf(err, "failed to parse roller config")
+		return skerr.Wrapf(err, "failed to parse roller config: %s", string(cfgBytes))
 	}
 	// Google3 uses a different type of backend.
 	if cfg.ParentDisplayName == google3ParentName {
diff --git a/go/gitiles/gitiles.go b/go/gitiles/gitiles.go
index 80f1b39..5bf464a 100644
--- a/go/gitiles/gitiles.go
+++ b/go/gitiles/gitiles.go
@@ -12,6 +12,7 @@
 	"net/http"
 	"net/url"
 	"os"
+	"path"
 	"sort"
 	"strconv"
 	"strings"
@@ -186,6 +187,9 @@
 // and FileInfo.
 func (r *Repo) ReadObject(ctx context.Context, path, ref string) (os.FileInfo, []byte, error) {
 	path = strings.TrimSuffix(path, "/")
+	if path == "." {
+		path = ""
+	}
 	resp, err := r.get(ctx, fmt.Sprintf(DownloadURL, r.url, ref, path))
 	if err != nil {
 		return nil, nil, skerr.Wrap(err)
@@ -288,12 +292,13 @@
 			return err
 		}
 		for _, fi := range infos {
+			fullPath := path.Join(dir, fi.Name())
 			if fi.IsDir() {
-				if err := helper(dir + "/" + fi.Name()); err != nil {
+				if err := helper(fullPath); err != nil {
 					return err
 				}
 			} else {
-				rv = append(rv, strings.TrimPrefix(dir+"/"+fi.Name(), topDir+"/"))
+				rv = append(rv, strings.TrimPrefix(fullPath, topDir+"/"))
 			}
 		}
 		return nil
diff --git a/go/gitiles/testutils/testutils.go b/go/gitiles/testutils/testutils.go
index c16622b..d45b032 100644
--- a/go/gitiles/testutils/testutils.go
+++ b/go/gitiles/testutils/testutils.go
@@ -53,7 +53,11 @@
 	require.NoError(mr.t, err)
 	body := make([]byte, base64.StdEncoding.EncodedLen(len(contents)))
 	base64.StdEncoding.Encode(body, contents)
-	url := fmt.Sprintf(gitiles.DownloadURL, mr.url, ref, srcPath)
+	mockURLPath := srcPath
+	if srcPath == "." {
+		mockURLPath = ""
+	}
+	url := fmt.Sprintf(gitiles.DownloadURL, mr.url, ref, mockURLPath)
 	md := mockhttpclient.MockGetDialogue(body)
 	typ := git.ObjectTypeBlob
 	if st.IsDir() {