#!/bin/bash set -e # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' RED='\033[0;31m' NC='\033[0m' # No Color # Check arguments if [ $# -lt 1 ]; then echo -e "${RED}Usage: ./create-pr.sh \"PR Title\" [\"Optional description\"]${NC}" echo "" echo "Example:" echo " ./create-pr.sh \"Fix authentication bug\" \"This fixes the dev mode auth issue\"" exit 1 fi TITLE="$1" DESCRIPTION="${2:-}" # Get current branch BRANCH=$(git rev-parse --abbrev-ref HEAD) if [ "$BRANCH" = "main" ]; then echo -e "${RED}Error: You're on the main branch. Please create a feature branch first.${NC}" exit 1 fi echo -e "${BLUE}Creating PR for branch: ${GREEN}$BRANCH${NC}" echo -e "${BLUE}Title: ${GREEN}$TITLE${NC}" # Get HF_TOKEN from .env if [ ! -f .env ]; then echo -e "${RED}Error: .env file not found${NC}" exit 1 fi HF_TOKEN=$(grep HF_TOKEN .env | cut -d '=' -f2) if [ -z "$HF_TOKEN" ]; then echo -e "${RED}Error: HF_TOKEN not found in .env${NC}" exit 1 fi # Get list of changed files echo -e "${BLUE}Detecting changed files...${NC}" CHANGED_FILES=$(git diff --name-only main.."$BRANCH") if [ -z "$CHANGED_FILES" ]; then echo -e "${RED}Error: No changes detected between main and $BRANCH${NC}" exit 1 fi echo -e "${BLUE}Changed files:${NC}" echo "$CHANGED_FILES" | while read -r file; do echo -e " ${GREEN}$file${NC}" done # Create PR using HuggingFace API with actual file operations echo -e "${BLUE}Creating pull request with file changes...${NC}" PR_URL=$(HF_TOKEN="$HF_TOKEN" uv run python - <