Download tasks/git-recovery/solution/solve.sh from noodcon/TerminalBench-DockerLess: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/noodcon/TerminalBench-DockerLess/resolve/main/tasks/git-recovery/solution/solve.sh
- Command line
-
hf download hf://datasets/noodcon/TerminalBench-DockerLess/tasks/git-recovery/solution/solve.sh
-
curl -L -o solve.sh https://huggingface.co/datasets/noodcon/TerminalBench-DockerLess/resolve/main/tasks/git-recovery/solution/solve.sh
1.04 kB
| # Oracle solution: find the lost commit through fsck, recover the file from the | |
| # right historical revision, tag, ignore and commit. | |
| set -euo pipefail | |
| cd "$TB_WORK" | |
| git config user.name "Release Bot" | |
| git config user.email "release@example.invalid" | |
| # 1. restore src/app.py from "Add config loader" | |
| loader_commit="$(git log --format='%H %s' main | awk '$0 ~ / Add config loader$/ {print $1}' | head -1)" | |
| test -n "$loader_commit" | |
| mkdir -p src | |
| git show "$loader_commit:src/app.py" > src/app.py | |
| # 4. ignore the junk | |
| cat > .gitignore <<'EOF' | |
| *.log | |
| build/ | |
| EOF | |
| git add -A | |
| git commit -qm "restore app.py" | |
| # 2. rescue the unreachable commit | |
| wip_commit="$(git fsck --unreachable --no-reflogs 2>/dev/null | awk '$2 == "commit" {print $3}' | while read -r sha; do | |
| if [ "$(git log -1 --format=%s "$sha" 2>/dev/null)" = "wip: plan" ]; then | |
| echo "$sha" | |
| break | |
| fi | |
| done)" | |
| test -n "$wip_commit" | |
| git branch recovered "$wip_commit" | |
| # 3. tag the release commit | |
| git tag v1.0 "$loader_commit" | |
| git status --porcelain | |