diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-13 23:01:47 -0800 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-13 23:01:47 -0800 |
| commit | 0101bc9f0e2a2910c17e4c6f9f3aa95679009ccc (patch) | |
| tree | bf72836f86771390adff125fedb1402e7cc1a1ef /roles/obsd_git/templates/git-shell-commands | |
| parent | Add support for httpd prefork configuration (diff) | |
| download | site-configs-0101bc9f0e2a2910c17e4c6f9f3aa95679009ccc.zip | |
Set go import header to make go install work
Diffstat (limited to 'roles/obsd_git/templates/git-shell-commands')
| -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 "$@" |