aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lars Hjemli <hjemli@gmail.com>2009-08-01 00:42:57 (JST)
committerGravatar Lars Hjemli <hjemli@gmail.com>2009-08-01 00:42:57 (JST)
commitf35db1cd2b75aac6952aa07713e44ca01fd89727 (patch)
treeaffc8325bf67ae51044c809c0b693cbe55dd097a
parent46b7abed99e957008c01c02cf612aa526ba92f04 (diff)
downloadcgit-f35db1cd2b75aac6952aa07713e44ca01fd89727.zip
cgit-f35db1cd2b75aac6952aa07713e44ca01fd89727.tar.gz
ui-commit: add support for 'commit-filter' option
This new option specifies a filter which is executed on the commit message, i.e. the commit message is written to the filters STDIN and the filters STDOUT is included verbatim as the commit message. This can be used to implement commit linking by creating a simple shell script in e.g. /usr/bin/cgit-commit-filter.sh like this: #/bin/sh sed -re 's|\b([0-9a-fA-F]{6,40})\b|<a href="./?id=\1">\1</a>|g' Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r--cgit.c2
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt6
-rw-r--r--ui-commit.c8
4 files changed, 17 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index eb7b45d..2cda554 100644
--- a/cgit.c
+++ b/cgit.c
@@ -90,6 +90,8 @@ void config_cb(const char *name, const char *value)
90 ctx.cfg.cache_static_ttl = atoi(value); 90 ctx.cfg.cache_static_ttl = atoi(value);
91 else if (!strcmp(name, "cache-dynamic-ttl")) 91 else if (!strcmp(name, "cache-dynamic-ttl"))
92 ctx.cfg.cache_dynamic_ttl = atoi(value); 92 ctx.cfg.cache_dynamic_ttl = atoi(value);
93 else if (!strcmp(name, "commit-filter"))
94 ctx.cfg.commit_filter = new_filter(value, 0);
93 else if (!strcmp(name, "embedded")) 95 else if (!strcmp(name, "embedded"))
94 ctx.cfg.embedded = atoi(value); 96 ctx.cfg.embedded = atoi(value);
95 else if (!strcmp(name, "max-message-length")) 97 else if (!strcmp(name, "max-message-length"))
diff --git a/cgit.h b/cgit.h
index f9cf0df..438301d 100644
--- a/cgit.h
+++ b/cgit.h
@@ -183,6 +183,7 @@ struct cgit_config {
183 int summary_branches; 183 int summary_branches;
184 int summary_log; 184 int summary_log;
185 int summary_tags; 185 int summary_tags;
186 struct cgit_filter *commit_filter;
186 struct cgit_filter *source_filter; 187 struct cgit_filter *source_filter;
187}; 188};
188 189
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index d420ad4..2efd6aa 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -55,6 +55,12 @@ clone-prefix::
55 setting is only used if `repo.clone-url` is unspecified. Default value: 55 setting is only used if `repo.clone-url` is unspecified. Default value:
56 none. 56 none.
57 57
58commit-filter::
59 Specifies a command which will be invoked to format commit messages.
60 The command will get the message on its STDIN, and the STDOUT from the
61 command will be included verbatim as the commit message, i.e. this can
62 be used to implement bugtracker integration. Default value: none.
63
58css:: 64css::
59 Url which specifies the css document to include in all cgit pages. 65 Url which specifies the css document to include in all cgit pages.
60 Default value: "/cgit.css". 66 Default value: "/cgit.css".
diff --git a/ui-commit.c b/ui-commit.c
index 41ce70e..ee0e139 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -89,11 +89,19 @@ void cgit_print_commit(char *hex)
89 } 89 }
90 html("</table>\n"); 90 html("</table>\n");
91 html("<div class='commit-subject'>"); 91 html("<div class='commit-subject'>");
92 if (ctx.cfg.commit_filter)
93 cgit_open_filter(ctx.cfg.commit_filter);
92 html_txt(info->subject); 94 html_txt(info->subject);
95 if (ctx.cfg.commit_filter)
96 cgit_close_filter(ctx.cfg.commit_filter);
93 show_commit_decorations(commit); 97 show_commit_decorations(commit);
94 html("</div>"); 98 html("</div>");
95 html("<div class='commit-msg'>"); 99 html("<div class='commit-msg'>");
100 if (ctx.cfg.commit_filter)
101 cgit_open_filter(ctx.cfg.commit_filter);
96 html_txt(info->msg); 102 html_txt(info->msg);
103 if (ctx.cfg.commit_filter)
104 cgit_close_filter(ctx.cfg.commit_filter);
97 html("</div>"); 105 html("</div>");
98 if (parents < 3) { 106 if (parents < 3) {
99 if (parents) 107 if (parents)