diff --git a/README.md b/README.md index 2c1f771..6793982 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ TARGET_DIR=~/work/rta-handbook \ ## Daily Flow ```sh +section0-docs doctor section0-docs pull # Edit Markdown files in your normal editor. @@ -60,6 +61,27 @@ After a push, ask the projection operator to pull and project. For now that is manual. The current operator command lives in `docs/projection-operations.md`. +## Contributor Setup + +Anonymous clone/read works on the lab mesh. Pushing requires a Gitea account or +token with write access to `section0/rta-handbook`. + +Run this once per checkout: + +```sh +section0-docs configure +``` + +Then prove write access without changing `main`: + +```sh +section0-docs push-test +``` + +`push-test` pushes the current commit to a temporary scratch branch and deletes +that branch immediately. If Git prompts for a password, use a Gitea access token +rather than your normal account password. + ## Source Models This repo is the Git-backed model: shared docs are canonical in Gitea. diff --git a/scripts/setup-section0-docs.sh b/scripts/setup-section0-docs.sh index 32c900d..521d8d2 100755 --- a/scripts/setup-section0-docs.sh +++ b/scripts/setup-section0-docs.sh @@ -43,16 +43,22 @@ usage() { section0-docs - helper for Section 0 Git Projection repos Commands: + configure set Git author name/email for this repo + doctor check clone, author, remote, and read access open print the repo path pull pull latest Markdown with --ff-only status show Git status commit commit all current changes with MESSAGE push push current branch + push-test prove write access with a temporary remote branch help show this help Examples: + section0-docs doctor + section0-docs configure section0-docs pull section0-docs status + section0-docs push-test MESSAGE="Update concept notes" section0-docs commit section0-docs push @@ -62,6 +68,42 @@ USAGE } case "\${1:-help}" in + configure) + current_name="\$(git -C "\$REPO_DIR" config user.name || true)" + current_email="\$(git -C "\$REPO_DIR" config user.email || true)" + printf "Git author name [%s]: " "\$current_name" + IFS= read -r author_name + printf "Git author email [%s]: " "\$current_email" + IFS= read -r author_email + if [ -n "\$author_name" ]; then + git -C "\$REPO_DIR" config user.name "\$author_name" + elif [ -z "\$current_name" ]; then + echo "Git author name is required" >&2 + exit 1 + fi + if [ -n "\$author_email" ]; then + git -C "\$REPO_DIR" config user.email "\$author_email" + elif [ -z "\$current_email" ]; then + echo "Git author email is required" >&2 + exit 1 + fi + ;; + doctor) + remote="\$(git -C "\$REPO_DIR" remote get-url origin)" + branch="\$(git -C "\$REPO_DIR" branch --show-current)" + author_name="\$(git -C "\$REPO_DIR" config user.name || true)" + author_email="\$(git -C "\$REPO_DIR" config user.email || true)" + echo "Repo: \$REPO_DIR" + echo "Remote: \$remote" + echo "Branch: \$branch" + if [ -n "\$author_name" ] && [ -n "\$author_email" ]; then + echo "Git author: \$author_name <\$author_email>" + else + echo "Git author: missing; run section0-docs configure" + fi + git -C "\$REPO_DIR" ls-remote --heads origin main >/dev/null + echo "Read access: ok" + ;; open) printf "%s\n" "\$REPO_DIR" ;; @@ -79,6 +121,12 @@ case "\${1:-help}" in push) git -C "\$REPO_DIR" push ;; + push-test) + branch="section0-smoke-\${USER:-user}-\$(date +%Y%m%d%H%M%S)" + git -C "\$REPO_DIR" push origin HEAD:refs/heads/"\$branch" + git -C "\$REPO_DIR" push origin :refs/heads/"\$branch" + echo "Write access: ok" + ;; help|--help|-h) usage ;; @@ -98,12 +146,17 @@ Remote: $REPO_URL Helper: $COMMAND_PATH Daily flow: + $COMMAND_NAME doctor $COMMAND_NAME pull # edit Markdown $COMMAND_NAME status MESSAGE="Update docs" $COMMAND_NAME commit $COMMAND_NAME push +Contributor setup: + $COMMAND_NAME configure + $COMMAND_NAME push-test + AFFiNE updates after the projection operator pulls and runs projection. If $COMMAND_DIR is not on PATH, add this to your shell profile: