"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: gotwebd: support "owner" file
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Fri, 26 Jul 2024 12:04:49 +0200

Download raw body.

Thread
On 2024/07/26 11:51:41 +0200, Omar Polo <op@omarpolo.com> wrote:
> This was requested some time ago on the IRC channel.  The idea is to
> load another special file to fill the "owner" field of the repository.
> I've choosen to give the priority to the file rather than what's in the
> git config.

now with the man bits.

> ok?

diffstat /home/op/w/got
 M  gotwebd/got_operations.c  |   0+  5-
 M  gotwebd/gotweb.c          |  13+  3-
 M  gotwebd/gotwebd.conf.5    |   6+  4-

3 files changed, 19 insertions(+), 12 deletions(-)

diff /home/op/w/got
commit - cbae186176b82efbf747a1486addb8b52c664651
path + /home/op/w/got
blob - 697dd605540a5b24fafb364efc2c1a3926bd22c8
file + gotwebd/got_operations.c
--- 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
file + gotwebd/gotweb.c
--- 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 *,
@@ -1109,9 +1111,17 @@ gotweb_load_got_path(struct repo_dir **rp, const char 
 	    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
file + gotwebd/gotwebd.conf.5
--- gotwebd/gotwebd.conf.5
+++ gotwebd/gotwebd.conf.5
@@ -161,11 +161,13 @@ 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 a
+.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]