X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/bd1b281478c8d8ab45f723ac5818d58da4a64dd1..71d14d9c98c39a6683780060f84429a3a7e5b348:/ui-shared.c diff --git a/ui-shared.c b/ui-shared.c index e719c1b..9d7ee3d 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -152,6 +152,14 @@ const char *cgit_repobasename(const char *reponame) return rvbuf; } +const char *cgit_snapshot_prefix(const struct cgit_repo *repo) +{ + if (repo->snapshot_prefix) + return repo->snapshot_prefix; + + return cgit_repobasename(repo->url); +} + static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root) { char *delim = "?"; @@ -1103,14 +1111,20 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base, strbuf_addf(filename, "%s-%s", base, ref); } -void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *head, - const char *hex) +void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, + const char *separator) { const struct cgit_snapshot_format* f; struct strbuf filename = STRBUF_INIT; + const char *basename; size_t prefixlen; - cgit_compose_snapshot_prefix(&filename, cgit_repobasename(repo->url), hex); + basename = cgit_snapshot_prefix(repo); + if (starts_with(ref, basename)) + strbuf_addstr(&filename, ref); + else + cgit_compose_snapshot_prefix(&filename, basename, ref); + prefixlen = filename.len; for (f = cgit_snapshot_formats; f->suffix; f++) { if (!(repo->snapshots & f->bit)) @@ -1119,7 +1133,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *head, strbuf_addstr(&filename, f->suffix); cgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL, filename.buf); - html("
"); + html(separator); } strbuf_release(&filename); }