callbacked commited on
Commit
dc165b8
·
verified ·
1 Parent(s): a0905ec

Delete update_hf_space.sh

Browse files
Files changed (1) hide show
  1. update_hf_space.sh +0 -93
update_hf_space.sh DELETED
@@ -1,93 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Script to update Hugging Face Space, ensuring Git LFS is handled correctly.
4
-
5
- # --- Configuration ---
6
- # Add file patterns that should be tracked by Git LFS to this array
7
- # Example: LFS_PATTERNS=("*.wasm" "*.png" "*.model")
8
- LFS_PATTERNS=("*.wasm" "*.png")
9
- DEFAULT_COMMIT_MESSAGE="chore: Update space"
10
- # --- End Configuration ---
11
-
12
- echo "=== Starting Hugging Face Space Update ==="
13
-
14
- # It's good practice to ensure you are in the main branch and it's up-to-date before running the rest of the script.
15
- # However, since we just manually rebased, we'll skip these for this specific run.
16
- # echo -e "\n>>> Ensuring main branch is up-to-date..."
17
- # git checkout main # Or your default branch
18
- # git fetch origin
19
- # git rebase origin/main # Or use merge: git merge origin/main
20
- # if [ $? -ne 0 ]; then
21
- # echo "Error: Failed to update main branch. Please resolve conflicts manually and try again."
22
- # exit 1
23
- # fi
24
-
25
- # 1. Track specified file patterns with Git LFS
26
- echo -e "\n>>> Step 1: Tracking LFS file patterns..."
27
- for pattern in "${LFS_PATTERNS[@]}"; do
28
- echo "Ensuring LFS tracking for: $pattern"
29
- git lfs track "$pattern"
30
- done
31
-
32
- # 2. Add .gitattributes and commit if it changed
33
- echo -e "\n>>> Step 2: Handling .gitattributes..."
34
- ATTRIBUTES_MODIFIED=false
35
- git add .gitattributes # Stage it to check for diffs against HEAD
36
- # Check if .gitattributes has uncommitted changes relevant to LFS tracking
37
- if ! git diff --staged --quiet .gitattributes; then
38
- echo ".gitattributes modified by LFS tracking, committing changes."
39
- git commit -m "chore: Update .gitattributes for LFS tracking"
40
- ATTRIBUTES_MODIFIED=true
41
- else
42
- echo ".gitattributes unchanged or already reflects LFS patterns."
43
- fi
44
-
45
- # 3. Add all other changes
46
- echo -e "\n>>> Step 3: Staging all other changes..."
47
- git add .
48
-
49
- # 4. Commit changes
50
- echo -e "\n>>> Step 4: Committing changes..."
51
- # Check if there are any changes to commit (excluding the .gitattributes commit we might have just made)
52
- if git diff --staged --quiet && [ "$ATTRIBUTES_MODIFIED" = false ]; then
53
- # If .gitattributes was the *only* thing changed and committed, we might have nothing else to commit.
54
- # We need to check if there was anything staged *before* 'git add .'
55
- # This logic can get complex. A simpler check is if `git status --porcelain` is empty after .gitattributes handling.
56
- # For now, we proceed if anything is staged.
57
- if git diff --staged --quiet; then
58
- echo "No new changes to commit."
59
- else
60
- read -p "Enter commit message (default: '$DEFAULT_COMMIT_MESSAGE'): " COMMIT_MESSAGE
61
- if [ -z "$COMMIT_MESSAGE" ]; then
62
- COMMIT_MESSAGE="$DEFAULT_COMMIT_MESSAGE"
63
- fi
64
- git commit -m "$COMMIT_MESSAGE"
65
- fi
66
- else # This 'else' pairs with 'if git diff --staged --quiet && [ "$ATTRIBUTES_MODIFIED" = false ]'
67
- # This means there are staged changes OR .gitattributes was modified and we need a commit message for other files.
68
- read -p "Enter commit message (default: '$DEFAULT_COMMIT_MESSAGE'): " COMMIT_MESSAGE
69
- if [ -z "$COMMIT_MESSAGE" ]; then
70
- COMMIT_MESSAGE="$DEFAULT_COMMIT_MESSAGE"
71
- fi
72
- git commit -m "$COMMIT_MESSAGE"
73
- fi
74
-
75
-
76
- # 5. Migrate files to LFS (important for ensuring history is clean)
77
- echo -e "\n>>> Step 5: Migrating repository to LFS (if necessary)..."
78
- INCLUDE_PATTERNS=$(IFS=,; echo "${LFS_PATTERNS[*]}")
79
- echo "Running git lfs migrate import --include=\"$INCLUDE_PATTERNS\" --everything --yes"
80
- git lfs migrate import --include="$INCLUDE_PATTERNS" --everything --yes
81
-
82
- # 6. Push to Hugging Face (force push due to potential history rewrite by migrate)
83
- echo -e "\n>>> Step 6: Pushing to Hugging Face..."
84
- echo "Attempting git push --force"
85
- git push --force
86
-
87
- if [ $? -eq 0 ]; then
88
- echo -e "\n=== Hugging Face Space Update Complete ==="
89
- else
90
- echo -e "\n=== Hugging Face Space Update FAILED ==="
91
- echo "Push command failed. Please review the error messages above."
92
- echo "You might need to manually resolve issues (e.g., fetch, rebase/merge) and then try pushing again."
93
- fi