59 lines
2.0 KiB
Bash
Executable File
59 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Zero-Ambiguity Git Commit & GitHub PR Submission Script for malonehunter/hyperdope-gematria
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_DIR="${1:-/workspace/hyperdope-gematria}"
|
|
BRANCH="feat/ingglish-aq-corpus"
|
|
BASE_BRANCH="master"
|
|
UPSTREAM_REPO="malonehunter/hyperdope-gematria"
|
|
|
|
if [ ! -d "$REPO_DIR/.git" ]; then
|
|
echo "Error: Target git repository not found at $REPO_DIR" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
# Ensure feature branch exists and is checked out
|
|
CURRENT_BRANCH="$(git branch --show-current)"
|
|
if [ "$CURRENT_BRANCH" != "$BRANCH" ]; then
|
|
git checkout -B "$BRANCH"
|
|
fi
|
|
|
|
# Stage only deterministic target files
|
|
git add db.txt tools/normalize_caps.py config.default.js
|
|
[ -f docs/ONBOARDING-INGGLISH-AQ.md ] && git add docs/ONBOARDING-INGGLISH-AQ.md
|
|
[ -f tools/classify_candidates.py ] && git add tools/classify_candidates.py
|
|
|
|
# Create commit if staged changes exist
|
|
if ! git diff --cached --quiet; then
|
|
git commit -F "$SCRIPT_DIR/commit-message.txt"
|
|
fi
|
|
|
|
echo "Committed on branch $BRANCH: $(git rev-parse --short HEAD)"
|
|
|
|
# Submit PR if push/remote credentials are configured
|
|
if [ "${SUBMIT_REMOTE:-0}" = "1" ]; then
|
|
git push -u origin "$BRANCH"
|
|
if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
|
|
gh pr create \
|
|
--repo "$UPSTREAM_REPO" \
|
|
--base "$BASE_BRANCH" \
|
|
--head "$BRANCH" \
|
|
--title "feat(db): provision verified Ingglish phonetic lexicon and AQ attractor corpus" \
|
|
--body-file "$SCRIPT_DIR/pr-body.md"
|
|
elif [ -n "${GITHUB_TOKEN:-}" ]; then
|
|
curl -sS -X POST \
|
|
-H "Authorization: token $GITHUB_TOKEN" \
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
"https://api.github.com/repos/$UPSTREAM_REPO/pulls" \
|
|
-d @"$SCRIPT_DIR/pr-payload.json"
|
|
else
|
|
echo "Error: Neither 'gh auth' nor GITHUB_TOKEN is active for remote PR creation." >&2
|
|
exit 2
|
|
fi
|
|
else
|
|
echo "Local commit ready. Set SUBMIT_REMOTE=1 to push and open the GitHub PR."
|
|
fi
|