commit 9e111e2e198b3193e6ba6ee05233427812784f76 from: Omar Polo date: Mon Jul 29 10:53:26 2024 UTC gotwebd: add support for an "owner" file Was requested in the IRC channel some time ago. The "owner" file is also supported by stagit. tweaks stsp and tracey, ok stsp commit - cbae186176b82efbf747a1486addb8b52c664651 commit + 9e111e2e198b3193e6ba6ee05233427812784f76 blob - 697dd605540a5b24fafb364efc2c1a3926bd22c8 blob + 542f0c0f02f83e44d87ede48a28af59748768530 --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -101,16 +101,11 @@ got_gotweb_dupfd(int *priv_fd, int *fd) const struct got_error * got_get_repo_owner(char **owner, struct request *c) { - struct server *srv = c->srv; struct transport *t = c->t; struct got_repository *repo = t->repo; const char *gitconfig_owner; *owner = NULL; - - if (srv->show_repo_owner == 0) - return NULL; - gitconfig_owner = got_repo_get_gitconfig_owner(repo); if (gitconfig_owner) { *owner = strdup(gitconfig_owner); blob - a7cce8ea218018fc1805b2e77685728952ffc4c4 blob + e8446a2194429a9db4ce01e2e0b35bb60a4745f4 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -88,6 +88,8 @@ static const struct got_error *gotweb_assign_querystri static int gotweb_render_index(struct template *); static const struct got_error *gotweb_load_got_path(struct repo_dir **, const char *, struct request *); +static const struct got_error *gotweb_load_file(char **, const char *, + const char *, int); static const struct got_error *gotweb_get_repo_description(char **, struct server *, const char *, int); static const struct got_error *gotweb_get_clone_url(char **, struct server *, @@ -1107,11 +1109,19 @@ gotweb_load_got_path(struct repo_dir **rp, const char goto err; error = gotweb_get_repo_description(&repo_dir->description, srv, repo_dir->path, dirfd(dt)); - if (error) - goto err; - error = got_get_repo_owner(&repo_dir->owner, c); if (error) goto err; + if (srv->show_repo_owner) { + error = gotweb_load_file(&repo_dir->owner, repo_dir->path, + "owner", dirfd(dt)); + if (error) + goto err; + if (repo_dir->owner == NULL) { + error = got_get_repo_owner(&repo_dir->owner, c); + if (error) + goto err; + } + } if (srv->show_repo_age) { error = got_get_repo_age(&repo_dir->age, c, NULL); if (error) blob - 315e1a87fcdabc08e120a04b1e4668398440e3ce blob + 107ee3f149a19d1adc3b1944da2664b7b30b8526 --- gotwebd/gotwebd.conf.5 +++ gotwebd/gotwebd.conf.5 @@ -161,16 +161,24 @@ file in the repository should be updated with an appro .It Ic show_repo_owner Ar on | off Set whether to display the repository owner. Enabled by default. -Displaying the owner requires owner information to be added to the +This requires the creation of an +.Pa owner +file in the repository or adding an +.Sq owner +field under the [gotweb] or [gitweb] section in the .Pa config -file in the repository. -.Xr gotwebd 8 -will parse owner information from either a [gotweb] or a [gitweb] section. +file inside the repository. For example: .Bd -literal -offset indent [gotweb] owner = "Your Name" .Ed +.Pp +The +.Pa owner +file has priority over the +.Pa config +if present. .It Ic site_link Ar string Set the displayed site link name for the index page. Defaults to