Download scripts/push_to_hf.sh from dn-scribe/attstore: direct link, hf CLI and curl.
- Browser
- Download file 2.6 kB
-
https://huggingface.co/spaces/dn-scribe/attstore/resolve/main/scripts/push_to_hf.sh
- Command line
-
hf download hf://spaces/dn-scribe/attstore/scripts/push_to_hf.sh
-
curl -L -o push_to_hf.sh https://huggingface.co/spaces/dn-scribe/attstore/resolve/main/scripts/push_to_hf.sh
2.6 kB
| set -e | |
| # Ensure we are in the attstore repo base folder | |
| if [ ! -d .git ]; then | |
| echo "Error: This script must be run from the base folder of a git repository." | |
| exit 1 | |
| fi | |
| # Ensure HF_TOKEN is set | |
| if [ -z "$HF_TOKEN" ]; then | |
| echo "HF_TOKEN is not set. Please export HF_TOKEN in your environment." | |
| exit 1 | |
| fi | |
| # Hugging Face repo URL | |
| HF_REPO="https://dn-scrib:$HF_TOKEN@huggingface.co/spaces/dn-scribe/attstore" | |
| # Save the original directory | |
| ORIG_DIR=$(pwd) | |
| # Create a temp directory for the push | |
| TMPDIR=$(mktemp -d) | |
| echo "Copying working tree to $TMPDIR..." | |
| # Use git to create an archive of the working tree (respects .gitignore) | |
| # This includes uncommitted changes but excludes ignored files | |
| echo "Archiving tracked files..." | |
| git ls-files -z | xargs -0 tar -czf "$TMPDIR/repo.tar.gz" | |
| echo "Adding untracked files (if any)..." | |
| UNTRACKED=$(git ls-files --others --exclude-standard) | |
| if [ -n "$UNTRACKED" ]; then | |
| echo "Found untracked files:" | |
| echo "$UNTRACKED" | |
| git ls-files -z --others --exclude-standard | xargs -0 tar -rzf "$TMPDIR/repo.tar.gz" 2>/dev/null || true | |
| else | |
| echo "No untracked files found" | |
| fi | |
| # Extract to temp directory | |
| mkdir -p "$TMPDIR/attstore-hf" | |
| tar -xzf "$TMPDIR/repo.tar.gz" -C "$TMPDIR/attstore-hf" | |
| rm "$TMPDIR/repo.tar.gz" | |
| # Show what was copied | |
| echo "Files copied to temp directory:" | |
| ls -la "$TMPDIR/attstore-hf" | head -20 | |
| # Copy the .git directory | |
| cp -R "$ORIG_DIR/.git" "$TMPDIR/attstore-hf/" | |
| cd "$TMPDIR/attstore-hf" | |
| git lfs install | |
| # Ensure all files are tracked | |
| git add -A | |
| # Add LFS tracking for binary files (only in temp clone) | |
| echo -e "*.png filter=lfs diff=lfs merge=lfs -text\n*.jpg filter=lfs diff=lfs merge=lfs -text\n*.jpeg filter=lfs diff=lfs merge=lfs -text\n*.gif filter=lfs diff=lfs merge=lfs -text\n*.pdf filter=lfs diff=lfs merge=lfs -text\n*.db filter=lfs diff=lfs merge=lfs -text\n*.db.bak filter=lfs diff=lfs merge=lfs -text" > .gitattributes | |
| git add .gitattributes | |
| git add -A | |
| git commit -m "Temp: Push working tree to Hugging Face" || true | |
| echo "Removing large files from history..." | |
| git filter-branch --force --index-filter \ | |
| "git rm --cached --ignore-unmatch -r instance/attestation_store.db.bak docs/" \ | |
| --prune-empty --tag-name-filter cat -- --all || true | |
| echo "Migrate existing binary files to LFS..." | |
| git lfs migrate import --include="*.png,*.jpg,*.jpeg,*.gif,*.pdf,*.db,*.db.bak" --everything --yes || true | |
| echo "Pushing to Hugging Face Spaces..." | |
| git push "$HF_REPO" HEAD:main --force | |
| echo "Done! Local repo and GitHub remote are unchanged." | |
| # Cleanup temp folder | |
| cd "$ORIG_DIR" | |
| rm -rf "$TMPDIR" | |