File size: 2,699 Bytes
fc5ac33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# deploy.sh - Deploy to HuggingFace Spaces with meaningful commit messages
#
# Usage:
#   ./deploy.sh "Your commit message"
#   ./deploy.sh  (prompts for message if not provided)

set -e  # Exit on error

# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

# Check if we're in a git repo
if ! git rev-parse --git-dir > /dev/null 2>&1; then
    echo -e "${RED}Error: Not in a git repository${NC}"
    exit 1
fi

# Check for uncommitted changes
if ! git diff-index --quiet HEAD --; then
    echo -e "${YELLOW}You have uncommitted changes:${NC}"
    git status --short
    echo ""
    read -p "Stage and commit all changes? (y/n) " -n 1 -r
    echo
    if [[ ! $REPLY =~ ^[Yy]$ ]]; then
        echo -e "${RED}Aborted${NC}"
        exit 1
    fi
    git add -A
fi

# Get commit message
if [ -z "$1" ]; then
    echo -e "${YELLOW}Enter commit message:${NC}"
    read -r COMMIT_MSG
    if [ -z "$COMMIT_MSG" ]; then
        echo -e "${RED}Error: Commit message cannot be empty${NC}"
        exit 1
    fi
else
    COMMIT_MSG="$1"
fi

# Validate commit message isn't generic
if [[ "$COMMIT_MSG" =~ ^(Upload|update|Update|fix|Fix)$ ]]; then
    echo -e "${YELLOW}Warning: Commit message is too generic: '$COMMIT_MSG'${NC}"
    read -p "Continue anyway? (y/n) " -n 1 -r
    echo
    if [[ ! $REPLY =~ ^[Yy]$ ]]; then
        echo -e "${RED}Aborted${NC}"
        exit 1
    fi
fi

# Create commit if there are staged changes
if ! git diff-index --quiet --cached HEAD --; then
    echo -e "${GREEN}Creating commit...${NC}"
    git commit -m "$COMMIT_MSG"
else
    echo -e "${YELLOW}No staged changes to commit${NC}"
fi

# Show what will be pushed
echo -e "\n${YELLOW}Commits to be pushed:${NC}"
git log origin/main..HEAD --oneline --decorate

# Confirm push
echo ""
read -p "Push to HuggingFace Spaces? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    echo -e "${RED}Aborted${NC}"
    exit 1
fi

# Push to HuggingFace
echo -e "${GREEN}Pushing to HuggingFace Spaces...${NC}"
git push origin main

echo -e "${GREEN}✓ Deployment complete!${NC}"
echo -e "View at: ${GREEN}https://huggingface.co/spaces/Luigi/tiny-scribe${NC}"

# Verify commit message was preserved
echo -e "\n${YELLOW}Verifying commit on remote...${NC}"
git fetch origin -q
REMOTE_MSG=$(git log origin/main -1 --pretty=format:"%s")
echo -e "Latest remote commit: ${GREEN}$REMOTE_MSG${NC}"

if [[ "$REMOTE_MSG" == *"huggingface_hub"* ]]; then
    echo -e "${RED}⚠ WARNING: Remote commit has generic message!${NC}"
    echo -e "${YELLOW}This means you may have edited files via HF web UI.${NC}"
    echo -e "${YELLOW}Always use 'git push' instead of the web interface!${NC}"
fi