git_infra

Git infra scripts for git.bracken.jp
git clone https://git.bracken.jp/git_infra.git
Log | Files | Refs | LICENSE

commit f0a517dcdb858ee678dff9f48dcf8f7c101fae87
parent 5954c9cf28aae78c4177699d7f69fccf067769c2
Author: Chris Bracken <chris@bracken.jp>
Date:   Mon, 13 Sep 2021 16:56:54 +0000

Don't index private repos

Makes two changes:
1. Sets stagit-no-index on private repos.
2. Prevents indexing or even creating the output directory for any repo
   with stagit-no-index set.

Diffstat:
Mgrm | 2+-
Mpost-receive.d/stagit | 54+++++++++++++++++++++++++++---------------------------
2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/grm b/grm @@ -103,7 +103,7 @@ ${BLUE}enter index [default: ${GREEN}1${BLUE}]${RESET}" case $visibility in 1|public) exported=1 ;; - 2|private) ;; + 2|private) hidden=1 ;; 3|unlisted) exported=1; hidden=1 ;; *) printf "%b\n" "${YELLOW}visibility defaults to ${GREEN}public${RESET}" exported=1 ;; diff --git a/post-receive.d/stagit b/post-receive.d/stagit @@ -34,11 +34,6 @@ while read -r old new _; do fi done -# Change to the directory where we will output HTML pages. -repo_web_dir="${www_root}/${repo_name}" -mkdir -p "$repo_web_dir" -cd "$repo_web_dir" || exit 1 - # If there was a --force push, delete all existing pages. The lack of a cache # file will trigger a full rebuild below. if [ "$force" = "1" ]; then @@ -46,31 +41,36 @@ if [ "$force" = "1" ]; then rm -rf "commit" "file" fi -# Generate the index page. -# Any repo containing a stagit-no-index file will be skipped. -echo "[stagit] Building repo index" -find "${repos_root}/." -maxdepth 1 \ - -type d \ - -name "*.git" \ - -exec test -e "{}/git-daemon-export-ok" \; \ - -exec test ! -e "{}/stagit-no-index" \; \ - -print \ - | sort -f \ - | sed -e 's/"/"\\""/g' -e 's/.*/"&"/' \ - | xargs stagit-index \ - > "${www_root}/index.html" - # Build the pages. If $cachefile is not present, a full rebuild is performed. -if [ ! -e stagit-no-index ]; then +if [ ! -e "${repo_dir}/stagit-no-index" ]; then + # Change to the directory where we will output HTML pages. + repo_web_dir="${www_root}/${repo_name}" + mkdir -p "$repo_web_dir" + cd "$repo_web_dir" || exit 1 + + # Generate the index page. + # Any repo containing a stagit-no-index file will be skipped. + echo "[stagit] Building repo index" + find "${repos_root}/." -maxdepth 1 \ + -type d \ + -name "*.git" \ + -exec test -e "{}/git-daemon-export-ok" \; \ + -exec test ! -e "{}/stagit-no-index" \; \ + -print \ + | sort -f \ + | sed -e 's/"/"\\""/g' -e 's/.*/"&"/' \ + | xargs stagit-index \ + > "${www_root}/index.html" + echo "[stagit] Building pages" stagit -c "$cachefile" "$repo_dir" + + # use log as index page + echo "[stagit] Linking assets" + ln -sf log.html index.html + ln -sf ../style.css style.css + ln -sf ../logo.png logo.png + ln -sf ../favicon.png favicon.png else echo "[stagit] Not building pages: private repo" fi - -# use log as index page -echo "[stagit] Linking assets" -ln -sf log.html index.html -ln -sf ../style.css style.css -ln -sf ../logo.png logo.png -ln -sf ../favicon.png favicon.png