diff --git a/src/application.cpp b/src/application.cpp index 4738c64..8e39241 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -163,6 +163,7 @@ void GitApp::tree(std::string name, std::string path) { // their source so it can be shown below the preview. c.text = is_binary ? "" : text; c.size = text.size(); + c.tags = repo->tags_for_commit(commit); render(SKIN, "file_view", c); return; } @@ -176,6 +177,7 @@ void GitApp::tree(std::string name, std::string path) { c.is_root = clean.empty(); c.parent_path = util::parent_path(clean); c.entries = repo->list_tree(commit, clean); + c.tags = repo->tags_for_commit(commit); render(SKIN, "tree_view", c); } catch (const GitError &e) { show_error(404, e.what()); diff --git a/src/content.h b/src/content.h index 4b227ee..0fbdcf2 100644 --- a/src/content.h +++ b/src/content.h @@ -39,6 +39,7 @@ struct tree_view : public master { std::string parent_path; // for the ".." link bool is_root = true; std::vector entries; + std::vector tags; // tags pointing at commit_oid }; struct file_view : public master { @@ -50,6 +51,7 @@ struct file_view : public master { bool is_markdown = false; bool is_image = false; uint64_t size = 0; + std::vector tags; // tags pointing at commit_oid }; struct blame_view : public master { diff --git a/src/git_repo.cpp b/src/git_repo.cpp index 8163583..4230eeb 100644 --- a/src/git_repo.cpp +++ b/src/git_repo.cpp @@ -446,6 +446,15 @@ std::vector GitRepo::tags() const { return result; } +std::vector GitRepo::tags_for_commit(const std::string &commit_oid) const { + std::vector result; + for (const TagInfo &tag : tags()) { + if (tag.target_oid == commit_oid) + result.push_back(tag.name); + } + return result; +} + TagDetail GitRepo::tag_detail(const std::string &name) const { TagDetail detail; detail.name = name; diff --git a/src/git_repo.h b/src/git_repo.h index acba856..42e30be 100644 --- a/src/git_repo.h +++ b/src/git_repo.h @@ -137,6 +137,9 @@ public: // All tags, sorted by name. std::vector tags() const; + // Names of tags whose target commit is `commit_oid`, sorted by name. + std::vector tags_for_commit(const std::string &commit_oid) const; + // Details of a single tag by short name (e.g. "v1.0"). TagDetail tag_detail(const std::string &name) const; diff --git a/static/style.css b/static/style.css index 8b59db0..af201b1 100644 --- a/static/style.css +++ b/static/style.css @@ -35,8 +35,9 @@ a:hover { text-decoration: underline; } main { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1.25rem; } h1 { font-size: 1.4rem; word-break: break-all; } -.meta, .actions { color: var(--muted); font-size: 0.9rem; } +.meta, .actions, .tags { color: var(--muted); font-size: 0.9rem; } .actions a { font-size: 0.9rem; } +.tags a { display: inline-block; padding: 0 0.4rem; border: 1px solid var(--muted); border-radius: 3px; } .repo-list { list-style: none; padding: 0; } .repo-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); } diff --git a/templates/skin.tmpl b/templates/skin.tmpl index e5dfd08..6ecc5e5 100644 --- a/templates/skin.tmpl +++ b/templates/skin.tmpl @@ -77,6 +77,9 @@ <% view tree_view uses content::tree_view extends master %> <% template content_body() %>

<%= repo %><% if (content.path.length() > 0) %>/<%= path %><% end %>

+<% if (content.tags.size() > 0) %> +

tags: <% foreach t in tags %><% item %><%= t %> <% end item %><% end foreach %>

+<% end %> <% if (not content.is_root) %> @@ -106,6 +109,9 @@ <% view file_view uses content::file_view extends master %> <% template content_body() %>

<%= path %>

+<% if (content.tags.size() > 0) %> +

tags: <% foreach t in tags %><% item %><%= t %> <% end item %><% end foreach %>

+<% end %>

raw · blame · @@ -197,6 +203,7 @@

+ <% end item %><% empty %> @@ -213,6 +220,7 @@ <% if tag.annotated %>annotated<% else %>lightweight<% end %> · points to <%= tag.short_oid %> · <% c++ out() << util::format_time(content.tag.time); %> +· browse files <% if (content.tag.tagger_name.length() > 0) %>
tagger: <%= tag.tagger_name %><% end %>

<% if (content.tag.message.length() > 0) %>
..
<%= t.short_oid %> <%= t.name %>browse files <% c++ out() << util::format_time(t.time); %>