aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorJohn Keeping2018-03-31 14:20:01 +0100
committerJason A. Donenfeld2018-06-27 18:11:19 +0200
commitc1572bb5ec4540b5008490cf471cc4a5e65ef728 (patch)
tree5f31bf0e4ca63ab94b74a85897d37481474c92a0 /ui-shared.c
parentd85e8a9810cbfbe5cfe80509a7b47cb39483e6ac (diff)
downloadcgit-c1572bb5ec4540b5008490cf471cc4a5e65ef728.tar.gz
cgit-c1572bb5ec4540b5008490cf471cc4a5e65ef728.tar.bz2
cgit-c1572bb5ec4540b5008490cf471cc4a5e65ef728.zip
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>
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c
index e719c1b..d857873 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -152,6 +152,14 @@ const char *cgit_repobasename(const char *reponame)
152 return rvbuf; 152 return rvbuf;
153} 153}
154 154
155const char *cgit_snapshot_prefix(const struct cgit_repo *repo)
156{
157 if (repo->snapshot_prefix)
158 return repo->snapshot_prefix;
159
160 return cgit_repobasename(repo->url);
161}
162
155static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root) 163static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root)
156{ 164{
157 char *delim = "?"; 165 char *delim = "?";
@@ -1110,7 +1118,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *head,
1110 struct strbuf filename = STRBUF_INIT; 1118 struct strbuf filename = STRBUF_INIT;
1111 size_t prefixlen; 1119 size_t prefixlen;
1112 1120
1113 cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo->url), hex); 1121 cgit_compose_snapshot_prefix(&filename, cgit_snapshot_prefix(repo), hex);
1114 prefixlen = filename.len; 1122 prefixlen = filename.len;
1115 for (f = cgit_snapshot_formats; f->suffix; f++) { 1123 for (f = cgit_snapshot_formats; f->suffix; f++) {
1116 if (!(repo->snapshots & f->bit)) 1124 if (!(repo->snapshots & f->bit))