Add "snapshot-prefix" repo configuration Allow using a user-specified value for the prefix in snapshot files instead of the repository basename. For example, files downloaded from the linux-stable.git repository should be named linux-$VERSION and not linux-stable-$VERSION, which can be achieved by setting: repo.snapshot-prefix=linux Signed-off-by: John Keeping <john@keeping.me.uk> Reviewed-by: Christian Hesse <mail@eworm.de>
John Keeping john@keeping.me.uk
Sat, 31 Mar 2018 14:20:01 +0100
7 files changed,
23 insertions(+),
4 deletions(-)
M
cgit.c
→
cgit.c
@@ -79,6 +79,8 @@ item = string_list_append(&repo->submodules, xstrdup(path));
item->util = xstrdup(value); } else if (!strcmp(name, "section")) repo->section = xstrdup(value); + else if (!strcmp(name, "snapshot-prefix")) + repo->snapshot_prefix = xstrdup(value); else if (!strcmp(name, "readme") && value != NULL) { if (repo->readme.items == ctx.cfg.readme.items) memset(&repo->readme, 0, sizeof(repo->readme));
M
cgitrc.5.txt
→
cgitrc.5.txt
@@ -599,6 +599,13 @@ A mask of snapshot formats for this repo that cgit generates links for,
restricted by the global "snapshots" setting. Default value: <snapshots>. +repo.snapshot-prefix:: + Prefix to use for snapshot links instead of the repository basename. + For example, the "linux-stable" repository may wish to set this to + "linux" so that snapshots are in the format "linux-3.15.4" instead + of "linux-stable-3.15.4". Default value: <empty> meaning to use + the repository basename. + repo.section:: Override the current section name for this repository. Default value: none.
M
ui-snapshot.c
→
ui-snapshot.c
@@ -154,7 +154,7 @@
if (get_oid(snapshot.buf, &oid) == 0) goto out; - reponame = cgit_repobasename(repo->url); + reponame = cgit_snapshot_prefix(repo); if (starts_with(snapshot.buf, reponame)) { const char *new_start = snapshot.buf; new_start += strlen(reponame);@@ -214,7 +214,7 @@ if (!hex)
hex = head; if (!prefix) - prefix = xstrdup(cgit_repobasename(ctx.repo->url)); + prefix = xstrdup(cgit_snapshot_prefix(ctx.repo)); make_snapshot(f, hex, prefix, filename); free(prefix);