gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitfb9e7554fb9e7554gitoria#45: browser gate: a /pulls title links to the PR pagemrefb9e7554/docker/sshd/gitoria-shell

2.3 KB

  1. #!/bin/sh
  2. # The forced command of every key: `gitoria-shell <user id>`. What the client asked is in SSH_ORIGINAL_COMMAND and may only be
  3. # git-upload-pack (clone, fetch) or git-receive-pack (push) of ONE repository '<slug>.git'; the app decides who may push.
  4. user=$1
  5. cmd=${SSH_ORIGINAL_COMMAND:-}
  6. refuse() { echo "gitoria: $1" >&2; exit 1; }
  7. case "$cmd" in
  8. "git-upload-pack "*) service=git-upload-pack; write=0 ;;
  9. "git-receive-pack "*) service=git-receive-pack; write=1 ;;
  10. *) refuse "only git clone, fetch and push work over ssh (no shell)" ;;
  11. esac
  12. arg=${cmd#* }
  13. arg=${arg#\'}; arg=${arg%\'}; arg=${arg#/}
  14. slug=${arg%.git}
  15. [ "$arg" = "$slug.git" ] || refuse "no such repository"
  16. # <name> or <org>/<name> (an organization's repo, GO34): each part a-z 0-9 and hyphens, 2-40 characters
  17. case "$slug" in
  18. */*/*) refuse "no such repository" ;;
  19. esac
  20. for part in $(echo "$slug" | tr '/' ' '); do
  21. case "$part" in
  22. ""|*[!a-z0-9-]*|-*|*-) refuse "no such repository" ;;
  23. esac
  24. [ ${#part} -ge 2 ] && [ ${#part} -le 40 ] || refuse "no such repository"
  25. done
  26. status=$(curl -sS --max-time 10 -G -o /tmp/gitoria-access.$$ -w '%{http_code}' -H "X-Gitoria-Secret: $(cat /run/gitoria-secret)" \
  27. --data-urlencode "user=$user" --data-urlencode "slug=$slug" --data-urlencode "write=$write" "$(cat /run/gitoria-url)/__git/access") || status=000
  28. msg=$(cat /tmp/gitoria-access.$$ 2>/dev/null); rm -f /tmp/gitoria-access.$$
  29. [ "$status" = 200 ] || refuse "${msg:-the server did not answer}"
  30. # the app answers "ok <real name>": a moved repo is served from its new place
  31. real=${msg#ok }; real=$(echo "$real" | tr -d '\n')
  32. case "$real" in
  33. ""|*[!a-z0-9/-]*|*..*|/*|*/) real=$slug ;;
  34. esac
  35. # refs/pull/* is gitoria's (pull request heads): the push is refused for it, as over HTTPS (git >= 2.31 reads these variables)
  36. export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=receive.hideRefs GIT_CONFIG_VALUE_0=refs/pull
  37. # 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.
  38. pushed() { curl -sS --max-time 10 -G -o /dev/null -H "X-Gitoria-Secret: $(cat /run/gitoria-secret)" \
  39. --data-urlencode "user=$user" --data-urlencode "slug=$real" --data-urlencode "phase=$1" "$(cat /run/gitoria-url)/__git/pushed" >/dev/null 2>&1 || true; }
  40. [ "$write" = 1 ] && pushed before
  41. "$service" "/repos/$real.git"
  42. rc=$?
  43. [ "$write" = 1 ] && [ "$rc" = 0 ] && pushed after
  44. exit $rc

Branches

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