diff options
Diffstat (limited to 'roles/obsd_git/templates/git-shell-commands/create')
| -rw-r--r-- | roles/obsd_git/templates/git-shell-commands/create | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/roles/obsd_git/templates/git-shell-commands/create b/roles/obsd_git/templates/git-shell-commands/create index 53899eb..dcce463 100644 --- a/roles/obsd_git/templates/git-shell-commands/create +++ b/roles/obsd_git/templates/git-shell-commands/create @@ -16,17 +16,20 @@ main() { mkdir "$proj_dir" fi repo_path="$proj_dir/$repo_name.git" + repo_url_path="$PROJ/$repo_name" else repo_path="{{ obsd_git_home }}/$VISIBILITY/$repo_name.git" + repo_url_path="$repo_name" fi if [ ! -d "$repo_path" ]; then echo "Creating bare repository: $repo_name.git" git init --bare --initial-branch=main "$repo_path" - chown -R git:git "$repo_path" if [ -n "$DESC" ]; then echo "$DESC" >>"$repo_path/description" fi + cgit_config_extra_head_content_set_go_import "$repo_path" "$repo_url_path" + chown -R git:git "$repo_path" fi } @@ -68,4 +71,14 @@ usage() { exit 1 } +# Ensure cgit advertises a go-import meta tag so the repo can be used as a Go +# module at {{ obsd_git_domain }}/<path>. +# +# Requires enable-git-config=1 in cgitrc. +cgit_config_extra_head_content_set_go_import() { + module="{{ obsd_git_domain }}/$2" + git -C "$1" config cgit.extra-head-content \ + "<meta name=\"go-import\" content=\"$module git https://$module\">" +} + main "$@" |