gitoria
All repositories: gitoria
2.3 KB
#!/bin/sh# The forced command of every key: `gitoria-shell <user id>`. What the client asked is in SSH_ORIGINAL_COMMAND and may only be# git-upload-pack (clone, fetch) or git-receive-pack (push) of ONE repository '<slug>.git'; the app decides who may push.user=$1cmd=${SSH_ORIGINAL_COMMAND:-}refuse() { echo "gitoria: $1" >&2; exit 1; }case "$cmd" in"git-upload-pack "*) service=git-upload-pack; write=0 ;;"git-receive-pack "*) service=git-receive-pack; write=1 ;;*) refuse "only git clone, fetch and push work over ssh (no shell)" ;;esacarg=${cmd#* }arg=${arg#\'}; arg=${arg%\'}; arg=${arg#/}slug=${arg%.git}[ "$arg" = "$slug.git" ] || refuse "no such repository"# <name> or <org>/<name> (an organization's repo, GO34): each part a-z 0-9 and hyphens, 2-40 characterscase "$slug" in*/*/*) refuse "no such repository" ;;esacfor part in $(echo "$slug" | tr '/' ' '); docase "$part" in""|*[!a-z0-9-]*|-*|*-) refuse "no such repository" ;;esac[ ${#part} -ge 2 ] && [ ${#part} -le 40 ] || refuse "no such repository"donestatus=$(curl -sS --max-time 10 -G -o /tmp/gitoria-access.$$ -w '%{http_code}' -H "X-Gitoria-Secret: $(cat /run/gitoria-secret)" \--data-urlencode "user=$user" --data-urlencode "slug=$slug" --data-urlencode "write=$write" "$(cat /run/gitoria-url)/__git/access") || status=000msg=$(cat /tmp/gitoria-access.$$ 2>/dev/null); rm -f /tmp/gitoria-access.$$[ "$status" = 200 ] || refuse "${msg:-the server did not answer}"# the app answers "ok <real name>": a moved repo is served from its new placereal=${msg#ok }; real=$(echo "$real" | tr -d '\n')case "$real" in""|*[!a-z0-9/-]*|*..*|/*|*/) real=$slug ;;esac# refs/pull/* is gitoria's (pull request heads): the push is refused for it, as over HTTPS (git >= 2.31 reads these variables)export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=receive.hideRefs GIT_CONFIG_VALUE_0=refs/pull# a push: the app numbers the repo's pull requests before, and compares them with git after (notifyPush, syncPulls). A failure of that call never fails the push.pushed() { curl -sS --max-time 10 -G -o /dev/null -H "X-Gitoria-Secret: $(cat /run/gitoria-secret)" \--data-urlencode "user=$user" --data-urlencode "slug=$real" --data-urlencode "phase=$1" "$(cat /run/gitoria-url)/__git/pushed" >/dev/null 2>&1 || true; }[ "$write" = 1 ] && pushed before"$service" "/repos/$real.git"rc=$?[ "$write" = 1 ] && [ "$rc" = 0 ] && pushed afterexit $rc
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- ac5ba6a4log: W60, #25 measuredmre
- 452f6a1amission W60: logic clean-upsmre
- 1448c899log: cleanup, #49 GPTBot, tracker mentions on #36mre
- fcf95936log: v1.5.1 provenmre
- 22105420log: W51b livemre
- 7e8aabeareport: W51b pull source verificationmre
- 6c18de76fix: preserve pull sources across containing branchesmre
- fc36fa2elog: W51b pull source bugmre
- 56bc1220log: v1.5.1 livemre
- 845fc0aareport: W51mre
- 83127391fix: return v1.5.1 app and merge error detailsmre
- b07d0e97log: W51 v1.5.1 startedmre
- 0b417d06docs: apps-api v1.5 user tokens (#48, W49)mre
- d046940alog: vinzenz contract note sentmre
- db443456log: vinzenz note retry 2mre
- 802f229alog: kunibert repo ping provenmre
- 2d2eaa92log: Kunibert connected to kunibert repomre
- 65d5f80alogmre
- dab74b0dW49 report, logmre
- fd4fc028Exercise member status reads with a populated check statemre