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
- fb9e7554gitoria#45: browser gate: a /pulls title links to the PR pagemre
- f7198131gitoria#45: tests/pr-page.mjs gatemre
- 483141d0gitoria#45: Settings shows the Apps heading only to the ownermre
- e2eff8f6gitoria#45: the PR page /pulls/N with reviews, threads, verdicts, conversation, comment, reply, resolve and Review againmre
- 7a602839gitoria#45: raiseEvent can send to one app only; people's comments, replies and resolving in reviews.hlmre
- 0a46bf7dgitoria#47: apps API contract v1.3 (status read route, statuses + required on the pull)mre
- 3373f7c3gitoria#38: push API contract v1.2.1, reviews, worker briefs and logmre
- 34143d2cgitoria#46: closing brace of appComments lost in the mergemre
- 54927c9cgitoria#46: PR statuses and required checks before merge (merge w46-status)mre
- 187e1871gitoria#46: badges without decorative bordersmre
- 6b022798gitoria#46: tests/status.mjs in GATESmre
- c6162f00gitoria#46: status badges on /pulls, Required before merge in Settingsmre
- e5a0b64egitoria#46: PUT statuses/<sha>, required contexts block the merge on the servermre
- 26a140e3gitoria#44: reviews, inline threads, replies, conversation for apps (merge w44-reviews)mre
- 888dbf87gitoria#44: unknown API paths answer the contract's JSON 404 and sit above the page routesmre
- ea587d90gitoria#44: reviews with inline threads, replies, resolve and the PR conversation for apps (lib/reviews.hl, tests/reviews.mjs)mre
- 49533a50gitoria#43: signed events to connected apps (merge w43-events)mre
- 1a1e87d5gitoria#43: the sender never writes the apps row; Settings shows the newest deliverymre
- cd442066gitoria#43: app-auth unit test reads the apps table from its new filemre
- 5dccbe38gitoria#43: in-flight rows are left alone by the other process; gate in deploy.sh; READMEmre