diff options
| -rw-r--r-- | cgit.c | 2 | ||||
| -rw-r--r-- | cgit.h | 1 | ||||
| -rw-r--r-- | cgitrc.5.txt | 7 | ||||
| -rw-r--r-- | ui-refs.c | 2 | ||||
| -rw-r--r-- | ui-shared.c | 10 | ||||
| -rw-r--r-- | ui-shared.h | 1 | ||||
| -rw-r--r-- | ui-snapshot.c | 4 | 
7 files changed, 23 insertions, 4 deletions
| @@ -79,6 +79,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va | |||
| 79 | item->util = xstrdup(value); | 79 | item->util = xstrdup(value); | 
| 80 | } else if (!strcmp(name, "section")) | 80 | } else if (!strcmp(name, "section")) | 
| 81 | repo->section = xstrdup(value); | 81 | repo->section = xstrdup(value); | 
| 82 | else if (!strcmp(name, "snapshot-prefix")) | ||
| 83 | repo->snapshot_prefix = xstrdup(value); | ||
| 82 | else if (!strcmp(name, "readme") && value != NULL) { | 84 | else if (!strcmp(name, "readme") && value != NULL) { | 
| 83 | if (repo->readme.items == ctx.cfg.readme.items) | 85 | if (repo->readme.items == ctx.cfg.readme.items) | 
| 84 | memset(&repo->readme, 0, sizeof(repo->readme)); | 86 | memset(&repo->readme, 0, sizeof(repo->readme)); | 
| @@ -88,6 +88,7 @@ struct cgit_repo { | |||
| 88 | char *clone_url; | 88 | char *clone_url; | 
| 89 | char *logo; | 89 | char *logo; | 
| 90 | char *logo_link; | 90 | char *logo_link; | 
| 91 | char *snapshot_prefix; | ||
| 91 | int snapshots; | 92 | int snapshots; | 
| 92 | int enable_commit_graph; | 93 | int enable_commit_graph; | 
| 93 | int enable_log_filecount; | 94 | int enable_log_filecount; | 
| diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 4da166c..a9d3d0a 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
| @@ -599,6 +599,13 @@ repo.snapshots:: | |||
| 599 | restricted by the global "snapshots" setting. Default value: | 599 | restricted by the global "snapshots" setting. Default value: | 
| 600 | <snapshots>. | 600 | <snapshots>. | 
| 601 | 601 | ||
| 602 | repo.snapshot-prefix:: | ||
| 603 | Prefix to use for snapshot links instead of the repository basename. | ||
| 604 | For example, the "linux-stable" repository may wish to set this to | ||
| 605 | "linux" so that snapshots are in the format "linux-3.15.4" instead | ||
| 606 | of "linux-stable-3.15.4". Default value: <empty> meaning to use | ||
| 607 | the repository basename. | ||
| 608 | |||
| 602 | repo.section:: | 609 | repo.section:: | 
| 603 | Override the current section name for this repository. Default value: | 610 | Override the current section name for this repository. Default value: | 
| 604 | none. | 611 | none. | 
| @@ -100,7 +100,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) | |||
| 100 | if (!ref || strlen(ref) < 1) | 100 | if (!ref || strlen(ref) < 1) | 
| 101 | return; | 101 | return; | 
| 102 | 102 | ||
| 103 | basename = cgit_repobasename(repo->url); | 103 | basename = cgit_snapshot_prefix(repo); | 
| 104 | if (starts_with(ref, basename)) | 104 | if (starts_with(ref, basename)) | 
| 105 | strbuf_addstr(&filename, ref); | 105 | strbuf_addstr(&filename, ref); | 
| 106 | else | 106 | else | 
| 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 | ||
| 155 | const 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 | |||
| 155 | static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root) | 163 | static 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)) | 
| diff --git a/ui-shared.h b/ui-shared.h index b3eb8c5..92a1755 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
| @@ -78,6 +78,7 @@ extern void cgit_compose_snapshot_prefix(struct strbuf *filename, | |||
| 78 | const char *base, const char *ref); | 78 | const char *base, const char *ref); | 
| 79 | extern void cgit_print_snapshot_links(const struct cgit_repo *repo, | 79 | extern void cgit_print_snapshot_links(const struct cgit_repo *repo, | 
| 80 | const char *head, const char *hex); | 80 | const char *head, const char *hex); | 
| 81 | extern const char *cgit_snapshot_prefix(const struct cgit_repo *repo); | ||
| 81 | extern void cgit_add_hidden_formfields(int incl_head, int incl_search, | 82 | extern void cgit_add_hidden_formfields(int incl_head, int incl_search, | 
| 82 | const char *page); | 83 | const char *page); | 
| 83 | 84 | ||
| diff --git a/ui-snapshot.c b/ui-snapshot.c index 237a75f..b9e2a36 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c | |||
| @@ -154,7 +154,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, | |||
| 154 | if (get_oid(snapshot.buf, &oid) == 0) | 154 | if (get_oid(snapshot.buf, &oid) == 0) | 
| 155 | goto out; | 155 | goto out; | 
| 156 | 156 | ||
| 157 | reponame = cgit_repobasename(repo->url); | 157 | reponame = cgit_snapshot_prefix(repo); | 
| 158 | if (starts_with(snapshot.buf, reponame)) { | 158 | if (starts_with(snapshot.buf, reponame)) { | 
| 159 | const char *new_start = snapshot.buf; | 159 | const char *new_start = snapshot.buf; | 
| 160 | new_start += strlen(reponame); | 160 | new_start += strlen(reponame); | 
| @@ -214,7 +214,7 @@ void cgit_print_snapshot(const char *head, const char *hex, | |||
| 214 | hex = head; | 214 | hex = head; | 
| 215 | 215 | ||
| 216 | if (!prefix) | 216 | if (!prefix) | 
| 217 | prefix = xstrdup(cgit_repobasename(ctx.repo->url)); | 217 | prefix = xstrdup(cgit_snapshot_prefix(ctx.repo)); | 
| 218 | 218 | ||
| 219 | make_snapshot(f, hex, prefix, filename); | 219 | make_snapshot(f, hex, prefix, filename); | 
| 220 | free(prefix); | 220 | free(prefix); | 
