From 3be17b195e11ec22ceb234c6cc40c55fae484bdd Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 15 Feb 2021 09:09:24 -0700 Subject: [PATCH] Girocco/Notify.pm: add a few fields to JSON repository hash We do have some additional information that does correspond to information being provided by the originator of the specification we're attempting to emulate. Add the few extra fields that we have in case they prove useful to JSON POST clients. Signed-off-by: Kyle J. McKay --- Girocco/Notify.pm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Girocco/Notify.pm b/Girocco/Notify.pm index 9d3b785..3c46fe9 100644 --- a/Girocco/Notify.pm +++ b/Girocco/Notify.pm @@ -90,19 +90,34 @@ sub _jsonagent { ")"; } +sub _projurl { + my ($base, $suffix) = @_; + defined($base) && $base ne "" or return undef; + defined($suffix) && $suffix ne "" or return undef; + return $base.'/'.$suffix.'.git'; +} + sub _jsonrepo { my $proj = shift; return { "name" => $proj->{name}, + "default_branch" => $proj->{HEAD}, + "master_branch" => $proj->{HEAD}, + "description" => $proj->{desc}, # Girocco extension: full_name is full project name, # equivalent to GitHub's "owner[name]/name". "full_name" => $proj->{name}.".git", - "url" => $Girocco::Config::gitweburl.'/'.$proj->{name}.".git", - # Girocco extension: Pull URL. - "pull_url" => $Girocco::Config::gitpullurl.'/'.$proj->{name}.".git", + "url" => _projurl($Girocco::Config::gitweburl,$proj->{name}), + "html_url" => _projurl($Girocco::Config::gitweburl,$proj->{name}), + "clone_url" => _projurl($Girocco::Config::httppullurl,$proj->{name}), + "git_url" => _projurl($Girocco::Config::gitpullurl,$proj->{name}), + "ssh_url" => _projurl($Girocco::Config::pushurl,$proj->{name}), + "mirror_url" => $proj->{url}, + # Girocco extension: Git Pull URL. + "pull_url" => _projurl($Girocco::Config::gitpullurl,$proj->{name}), - "owner" => { "name" => "", "email" => $proj->{email} } + "owner" => { "email" => $proj->{email} } }; } -- 2.11.4.GIT