diff options
| author | 2026-07-30 12:26:52 +0700 | |
|---|---|---|
| committer | 2026-07-30 12:26:52 +0700 | |
| commit | b4b4f2325db71041f38902143b28bae94762b111 (patch) | |
| tree | 8ad6f71551b249d7aa52fc864d586becd4ff34de /ui-shared.c | |
| parent | dbed2ecdf824d154f7d69a624013a02e6e0966be (diff) | |
| download | cgitext-b4b4f2325db71041f38902143b28bae94762b111.tar.gz cgitext-b4b4f2325db71041f38902143b28bae94762b111.zip | |
ui-ci: add a "ci" tab which redirects to an external ci system
Add a "ci" page which redirects to an external ci system for the ref
being viewed, along with a tab for it in the repository header.
The target is a url template, configurable globally or per repository,
with separate settings for branches and tags because pipelines for the
two commonly live at different locations: on a Jenkins multibranch
pipeline a branch is at job/<name>/job/<ref> while a tag is at
job/<name>/view/tags/job/<ref>. $ref, $repo and $slug are substituted,
$slug being the repository url with any ".git" suffix removed and slashes
replaced by dashes, which is the shape job names usually take.
An explicit repo.ci-url drops the branch and tag urls the repository
would otherwise inherit from the global settings, as it could never take
effect otherwise.
The expansion is written to the Location header verbatim rather than
through cgit_redirect(), which percent-encodes '?', '=' and '%' and would
corrupt any url carrying a query string. An expansion containing CR or LF
is refused so that it cannot smuggle in further headers.
Signed-off-by: Saya Andy <saya.andy@posteo.com>
Diffstat (limited to 'ui-shared.c')
| -rw-r--r-- | ui-shared.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index a6a828d..9a9d014 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -12,6 +12,7 @@ #include "ui-shared.h" #include "cmd.h" #include "html.h" +#include "ui-ci.h" #include "version.h" static const char cgit_doctype[] = @@ -342,6 +343,12 @@ void cgit_tag_link(const char *name, const char *title, const char *class, reporevlink("tag", name, title, class, tag, NULL, NULL); } +void cgit_ci_link(const char *name, const char *title, const char *class, + const char *head) +{ + reporevlink("ci", name, title, class, head, NULL, NULL); +} + void cgit_tree_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path) { @@ -1110,6 +1117,8 @@ void cgit_print_pageheader(void) if (ctx.repo->max_stats) cgit_stats_link("stats", NULL, hc("stats"), ctx.qry.head, ctx.qry.vpath); + if (cgit_ci_available()) + cgit_ci_link("ci", NULL, hc("ci"), ctx.qry.head); if (ctx.repo->homepage) { html("<a href='"); html_attr(ctx.repo->homepage); |