Changes
3 changed files (+19/-12)
-
-
@@ -127,29 +127,28 @@ func (g *GitRepo) LastCommit() (*object.Commit, error) {return c, nil } func (g *GitRepo) FileContent(path string) (string, error) { // FileContent returns the content of a file at the "path" and // whether the file is binary or not. func (g *GitRepo) FileContent(path string) (string, bool, error) { c, err := g.r.CommitObject(g.h) if err != nil { return "", fmt.Errorf("commit object: %w", err) return "", false, fmt.Errorf("commit object: %w", err) } tree, err := c.Tree() if err != nil { return "", fmt.Errorf("file tree: %w", err) return "", false, fmt.Errorf("file tree: %w", err) } file, err := tree.File(path) if err != nil { return "", err return "", false, err } isbin, _ := file.IsBinary() contents, err := file.Contents() if !isbin { return file.Contents() } else { return "Not displaying binary file", nil } return contents, isbin, err } func (g *GitRepo) Tags() ([]*TagReference, error) {
-
-
-
@@ -127,7 +127,11 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) {var readmeContent template.HTML for _, readme := range d.c.Repo.Readme { ext := filepath.Ext(readme) content, _ := gr.FileContent(readme) // Getting a binary here is unlikely and we can't guess the repo owner's // intention in that case. So we process the file with Markdown processor // anyway, even if that produces nonsential garbage. content, _, _ := gr.FileContent(readme) if len(content) > 0 { switch ext { case ".md", ".mkd", ".markdown":
-
@@ -305,7 +309,7 @@ func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) {return } contents, err := gr.FileContent(treePath) contents, isBinary, err := gr.FileContent(treePath) if err != nil { d.Write500(w) return
-
@@ -318,6 +322,10 @@ func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) {return } if isBinary { contents = "Not displaying binary file" } meta := repositoryMeta{ DisplayName: getDisplayName(name), DirName: name,
-
-
-
@@ -19,7 +19,7 @@ import () func isGoModule(gr *git.GitRepo) bool { _, err := gr.FileContent("go.mod") _, _, err := gr.FileContent("go.mod") return err == nil }
-