add tag action
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 668a3df..27dcfca 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -116,6 +116,7 @@ enum logs {
LOGTREE,
LOGDIFF,
LOGBLAME,
+ LOGTAG,
};
enum tags {
@@ -197,6 +198,7 @@ static const struct got_error* gw_raw(struct trans *);
static const struct got_error* gw_logbriefs(struct trans *);
static const struct got_error* gw_snapshot(struct trans *);
static const struct got_error* gw_summary(struct trans *);
+static const struct got_error* gw_tag(struct trans *);
static const struct got_error* gw_tree(struct trans *);
struct gw_query_action {
@@ -220,7 +222,8 @@ enum gw_query_actions {
GW_LOGBRIEFS,
GW_SNAPSHOT,
GW_SUMMARY,
- GW_TREE
+ GW_TAG,
+ GW_TREE,
};
static struct gw_query_action gw_query_funcs[] = {
@@ -237,6 +240,7 @@ static struct gw_query_action gw_query_funcs[] = {
{ GW_LOGBRIEFS, "logbriefs", gw_logbriefs, "gw_tmpl/index.tmpl" },
{ GW_SNAPSHOT, "snapshot", gw_snapshot, "gw_tmpl/index.tmpl" },
{ GW_SUMMARY, "summary", gw_summary, "gw_tmpl/index.tmpl" },
+ { GW_TAG, "tag", gw_tag, "gw_tmpl/index.tmpl" },
{ GW_TREE, "tree", gw_tree, "gw_tmpl/index.tmpl" },
};
@@ -643,6 +647,28 @@ gw_summary(struct trans *gw_trans)
}
static const struct got_error *
+gw_tag(struct trans *gw_trans)
+{
+ const struct got_error *error = NULL;
+ char *log, *log_html;
+
+ error = apply_unveil(gw_trans->gw_dir->path, NULL);
+ if (error)
+ return error;
+
+ log = gw_get_repo_log(gw_trans, NULL, gw_trans->commit, 1, LOGTAG);
+
+ if (log != NULL && strcmp(log, "") != 0) {
+ if ((asprintf(&log_html, log_tree, log)) == -1)
+ return got_error_from_errno("asprintf");
+ khttp_puts(gw_trans->gw_req, log_html);
+ free(log_html);
+ free(log);
+ }
+ return error;
+}
+
+static const struct got_error *
gw_tree(struct trans *gw_trans)
{
const struct got_error *error = NULL;
@@ -807,14 +833,14 @@ gw_parse_querystring(struct trans *gw_trans)
action = &gw_query_funcs[i];
if (action->func_name == NULL)
continue;
-
+khttp_puts(gw_trans->gw_req, p->parsed.s);
if (strcmp(action->func_name,
p->parsed.s) == 0) {
gw_trans->action = i;
if ((asprintf(&gw_trans->action_name,
"%s", action->func_name)) == -1)
return
- got_error_from_errno(
+ got_error_from_errno(
"asprintf");
break;
@@ -1647,6 +1673,17 @@ gw_get_repo_log(struct trans *gw_trans, const char *search_pattern,
free(logbriefs_navs_html);
logbriefs_navs_html = NULL;
break;
+ case (LOGTAG):
+ log_tree_html = strdup("tag log here");
+
+ if ((asprintf(&commit_row, log_tree_row,
+ gw_html_escape(commit_log), log_tree_html)) == -1) {
+ error = got_error_from_errno("asprintf");
+ goto done;
+ }
+
+ free(log_tree_html);
+ break;
case (LOGTREE):
log_tree_html = strdup("log tree here");
diff --git a/gotweb/gotweb_ui.h b/gotweb/gotweb_ui.h
index db8a01f..f6dde10 100644
--- a/gotweb/gotweb_ui.h
+++ b/gotweb/gotweb_ui.h
@@ -120,7 +120,7 @@ char *tags_row =
"<div id='dotted_line'></div>";
char *tags_navs =
- "<a href='?path=%s&action=tagt&commit=%s'>tag</a> | " \
+ "<a href='?path=%s&action=tag&commit=%s'>tag</a> | " \
"<a href='?path=%s&action=commit&commit=%s'>commit</a> | " \
"<a href='?path=%s&action=logbriefs&commit=%s'>log briefs</a> | " \
"<a href='?path=%s&action=log&commit=%s'>log</a>";