aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git_misc.go9
-rw-r--r--http_handle_repo_commit.go3
-rw-r--r--http_handle_repo_index.go3
-rw-r--r--http_handle_repo_log.go3
-rw-r--r--http_handle_repo_raw.go3
-rw-r--r--http_handle_repo_tree.go4
-rw-r--r--templates/repo_index.html.tmpl10
7 files changed, 26 insertions, 9 deletions
diff --git a/git_misc.go b/git_misc.go
index c153534..7b7febb 100644
--- a/git_misc.go
+++ b/git_misc.go
@@ -18,13 +18,14 @@ var (
err_getting_parent_commit_object = errors.New("Error getting parent commit object")
)
-func open_git_repo(ctx context.Context, group_name, repo_name string) (*git.Repository, error) {
+func open_git_repo(ctx context.Context, group_name, repo_name string) (repo *git.Repository, description string, err error) {
var fs_path string
- err := database.QueryRow(ctx, "SELECT r.filesystem_path FROM repos r JOIN groups g ON r.group_id = g.id WHERE g.name = $1 AND r.name = $2;", group_name, repo_name).Scan(&fs_path)
+ err = database.QueryRow(ctx, "SELECT r.filesystem_path, r.description FROM repos r JOIN groups g ON r.group_id = g.id WHERE g.name = $1 AND r.name = $2;", group_name, repo_name).Scan(&fs_path, &description)
if err != nil {
- return nil, err
+ return nil, "", err
}
- return git.PlainOpen(fs_path)
+ repo, err = git.PlainOpen(fs_path)
+ return
}
type display_git_tree_entry_t struct {
diff --git a/http_handle_repo_commit.go b/http_handle_repo_commit.go
index 1a84862..7469448 100644
--- a/http_handle_repo_commit.go
+++ b/http_handle_repo_commit.go
@@ -19,11 +19,12 @@ type usable_file_patch struct {
func handle_repo_commit(w http.ResponseWriter, r *http.Request, params map[string]any) {
group_name, repo_name, commit_id_specified_string := params["group_name"].(string), params["repo_name"].(string), params["commit_id"].(string)
- repo, err := open_git_repo(r.Context(), group_name, repo_name)
+ repo, description, err := open_git_repo(r.Context(), group_name, repo_name)
if err != nil {
fmt.Fprintln(w, "Error opening repo:", err.Error())
return
}
+ params["repo_description"] = description
commit_id_specified_string_without_suffix := strings.TrimSuffix(commit_id_specified_string, ".patch")
commit_id := plumbing.NewHash(commit_id_specified_string_without_suffix)
commit_object, err := repo.CommitObject(commit_id)
diff --git a/http_handle_repo_index.go b/http_handle_repo_index.go
index a3920b1..b010670 100644
--- a/http_handle_repo_index.go
+++ b/http_handle_repo_index.go
@@ -8,11 +8,12 @@ import (
func handle_repo_index(w http.ResponseWriter, r *http.Request, params map[string]any) {
group_name, repo_name := params["group_name"].(string), params["repo_name"].(string)
- repo, err := open_git_repo(r.Context(), group_name, repo_name)
+ repo, description, err := open_git_repo(r.Context(), group_name, repo_name)
if err != nil {
fmt.Fprintln(w, "Error opening repo:", err.Error())
return
}
+ params["repo_description"] = description
head, err := repo.Head()
if err != nil {
fmt.Fprintln(w, "Error getting repo HEAD:", err.Error())
diff --git a/http_handle_repo_log.go b/http_handle_repo_log.go
index 7ab1294..0f79ecb 100644
--- a/http_handle_repo_log.go
+++ b/http_handle_repo_log.go
@@ -10,11 +10,12 @@ import (
// TODO: I probably shouldn't include *all* commits here...
func handle_repo_log(w http.ResponseWriter, r *http.Request, params map[string]any) {
group_name, repo_name, ref_name := params["group_name"].(string), params["repo_name"].(string), params["ref"].(string)
- repo, err := open_git_repo(r.Context(), group_name, repo_name)
+ repo, description, err := open_git_repo(r.Context(), group_name, repo_name)
if err != nil {
fmt.Fprintln(w, "Error opening repo:", err.Error())
return
}
+ params["repo_description"] = description
ref, err := repo.Reference(plumbing.NewBranchReferenceName(ref_name), true)
if err != nil {
fmt.Fprintln(w, "Error getting repo reference:", err.Error())
diff --git a/http_handle_repo_raw.go b/http_handle_repo_raw.go
index 6544610..7d25071 100644
--- a/http_handle_repo_raw.go
+++ b/http_handle_repo_raw.go
@@ -26,11 +26,12 @@ func handle_repo_raw(w http.ResponseWriter, r *http.Request, params map[string]a
params["ref_type"], params["ref"], params["path_spec"] = ref_type, ref_name, path_spec
- repo, err := open_git_repo(r.Context(), group_name, repo_name)
+ repo, description, err := open_git_repo(r.Context(), group_name, repo_name)
if err != nil {
fmt.Fprintln(w, "Error opening repo:", err.Error())
return
}
+ params["repo_description"] = description
ref_hash, err := get_ref_hash_from_type_and_name(repo, ref_type, ref_name)
if err != nil {
diff --git a/http_handle_repo_tree.go b/http_handle_repo_tree.go
index acc03e4..b1a2d62 100644
--- a/http_handle_repo_tree.go
+++ b/http_handle_repo_tree.go
@@ -28,11 +28,13 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string]
}
}
params["ref_type"], params["ref"], params["path_spec"] = ref_type, ref_name, path_spec
- repo, err := open_git_repo(r.Context(), group_name, repo_name)
+ repo, description, err := open_git_repo(r.Context(), group_name, repo_name)
if err != nil {
fmt.Fprintln(w, "Error opening repo:", err.Error())
return
}
+ params["repo_description"] = description
+
ref_hash, err := get_ref_hash_from_type_and_name(repo, ref_type, ref_name)
if err != nil {
fmt.Fprintln(w, "Error getting ref hash:", err.Error())
diff --git a/templates/repo_index.html.tmpl b/templates/repo_index.html.tmpl
index 4b20c27..f6615d7 100644
--- a/templates/repo_index.html.tmpl
+++ b/templates/repo_index.html.tmpl
@@ -16,9 +16,19 @@
</thead>
<tbody>
<tr>
+ <th scope="row">Name</th>
+ <td>{{ .repo_name }}</td>
+ </tr>
+ <tr>
<th scope="row">Clone</th>
<td><code>git clone {{ .clone_url }}</code></td>
</tr>
+ {{ if .repo_description }}
+ <tr>
+ <th scope="row">Description</th>
+ <td>{{ .repo_description }}</td>
+ </tr>
+ {{ end }}
</tbody>
</table>
</div>