about: allow to give head from query

Reading the README from repository used to be limited to default
branch or a branch given in configuration. Let's allow a branch
from query if not specified explicitly.

Signed-off-by: Christian Hesse <mail@eworm.de>
master
Christian Hesse 2 years ago committed by Jason A. Donenfeld
parent ce2062d9e2
commit a0f6669bdb

@ -507,9 +507,11 @@ static inline void parse_readme(const char *readme, char **filename, char **ref,
/* Check if the readme is tracked in the git repo. */ /* Check if the readme is tracked in the git repo. */
colon = strchr(readme, ':'); colon = strchr(readme, ':');
if (colon && strlen(colon) > 1) { if (colon && strlen(colon) > 1) {
/* If it starts with a colon, we want to use /* If it starts with a colon, we want to use head given
* the default branch */ * from query or the default branch */
if (colon == readme && repo->defbranch) if (colon == readme && ctx.qry.head)
*ref = xstrdup(ctx.qry.head);
else if (colon == readme && repo->defbranch)
*ref = xstrdup(repo->defbranch); *ref = xstrdup(repo->defbranch);
else else
*ref = xstrndup(readme, colon - readme); *ref = xstrndup(readme, colon - readme);

@ -579,11 +579,11 @@ repo.readme::
verbatim as the "About" page for this repo. You may also specify a verbatim as the "About" page for this repo. You may also specify a
git refspec by head or by hash by prepending the refspec followed by git refspec by head or by hash by prepending the refspec followed by
a colon. For example, "master:docs/readme.mkd". If the value begins a colon. For example, "master:docs/readme.mkd". If the value begins
with a colon, i.e. ":docs/readme.rst", the default branch of the with a colon, i.e. ":docs/readme.rst", the head giving in query or
repository will be used. Sharing any file will expose that entire the default branch of the repository will be used. Sharing any file
directory tree to the "/about/PATH" endpoints, so be sure that there will expose that entire directory tree to the "/about/PATH" endpoints,
are no non-public files located in the same directory as the readme so be sure that there are no non-public files located in the same
file. Default value: <readme>. directory as the readme file. Default value: <readme>.
repo.section:: repo.section::
Override the current section name for this repository. Default value: Override the current section name for this repository. Default value:

Loading…
Cancel
Save