-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_to_github.py
More file actions
147 lines (124 loc) Β· 5.84 KB
/
Copy pathupload_to_github.py
File metadata and controls
147 lines (124 loc) Β· 5.84 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python3
"""
Upload GitFlow AI to GitHub Repository
Automated script to initialize Git and push to GitHub
"""
import subprocess
import sys
import os
def run_command(command, description):
"""Run a shell command and handle errors"""
print(f"π {description}...")
try:
result = subprocess.run(command, shell=True, capture_output=True, text=True)
if result.returncode == 0:
print(f"β
{description} completed")
if result.stdout.strip():
print(f" Output: {result.stdout.strip()}")
return True
else:
print(f"β {description} failed")
print(f" Error: {result.stderr.strip()}")
return False
except Exception as e:
print(f"β {description} error: {e}")
return False
def setup_git_repository():
"""Initialize Git repository and upload to GitHub"""
print("π GitFlow AI - GitHub Upload Script")
print("=" * 50)
# Check if we're already in a Git repository
if os.path.exists('.git'):
print("π Git repository already exists")
else:
# Initialize Git repository
if not run_command("git init", "Initializing Git repository"):
return False
# Configure Git user (if not already configured)
print("\nπ§ Configuring Git user...")
run_command('git config user.name "Manav Sutar"', "Setting Git username")
run_command('git config user.email "sutarmanav557@gmail.com"', "Setting Git email")
# Add all files
if not run_command("git add .", "Adding all files to Git"):
return False
# Create initial commit
commit_message = "π Initial commit: GitFlow AI - Intelligent Git Workflow Assistant\n\nβ¨ Features:\n- AI-Powered Git Conversations\n- Natural Language Interface\n- Smart Command Suggestions\n- Safety Validations\n- Web Interface\n- CLI Tool\n\nBuilt for OpenAI Hackathon π"
if not run_command(f'git commit -m "{commit_message}"', "Creating initial commit"):
return False
# Add GitHub remote
github_url = "https://github.com/TheCoder2010-create/gitflow-ai-.git"
if not run_command(f"git remote add origin {github_url}", "Adding GitHub remote"):
# Remote might already exist, try to set URL
run_command(f"git remote set-url origin {github_url}", "Setting GitHub remote URL")
# Create main branch and push
run_command("git branch -M main", "Setting main branch")
print("\nπ Ready to push to GitHub!")
print("π Repository: https://github.com/TheCoder2010-create/gitflow-ai")
print("\nβ οΈ IMPORTANT: You'll need to authenticate with GitHub")
print(" Option 1: Use GitHub CLI (gh auth login)")
print(" Option 2: Use Personal Access Token")
print(" Option 3: Use SSH key")
# Ask user if they want to push now
response = input("\nβ Do you want to push to GitHub now? (y/n): ").lower().strip()
if response in ['y', 'yes']:
print("\nπ Pushing to GitHub...")
if run_command("git push -u origin main", "Pushing to GitHub"):
print("\nπ SUCCESS! GitFlow AI uploaded to GitHub!")
print(f"π Repository URL: {github_url}")
print("\nπ Next steps:")
print("1. β
Repository created and uploaded")
print("2. π Set up GitHub Pages (optional)")
print("3. π Deploy to Vercel/Netlify (optional)")
print("4. π Update repository description on GitHub")
print("5. π·οΈ Add topics: ai, git, assistant, openai, hackathon")
return True
else:
print("\nβ Push failed. Please check your GitHub authentication.")
print("\nπ§ Troubleshooting:")
print("1. Make sure the repository exists on GitHub")
print("2. Check your GitHub authentication")
print("3. Try: gh auth login (if using GitHub CLI)")
print("4. Or manually push: git push -u origin main")
return False
else:
print("\nβΈοΈ Upload paused. To push later, run:")
print(" git push -u origin main")
return True
def create_github_repository():
"""Instructions for creating GitHub repository"""
print("\nπ GitHub Repository Setup Instructions:")
print("=" * 50)
print("1. Go to https://github.com/new")
print("2. Repository name: gitflow-ai")
print("3. Description: π€ AI-Powered Git Workflow Assistant - Natural Language Git Interface")
print("4. Make it Public (for hackathon visibility)")
print("5. Don't initialize with README (we have one)")
print("6. Click 'Create repository'")
print("\nπ·οΈ Recommended topics to add:")
print(" ai, git, assistant, openai, hackathon, python, flask, gpt, workflow")
def main():
"""Main function"""
print("π€ GitFlow AI - GitHub Upload Automation")
print("π¨βπ» Author: Manav Sutar (sutarmanav557@gmail.com)")
print("π Built for OpenAI Hackathon")
print()
# Check if Git is installed
if not run_command("git --version", "Checking Git installation"):
print("β Git is not installed. Please install Git first.")
return False
# Show repository creation instructions
create_github_repository()
# Ask if repository is created
response = input("\nβ Have you created the GitHub repository? (y/n): ").lower().strip()
if response not in ['y', 'yes']:
print("βΈοΈ Please create the GitHub repository first, then run this script again.")
return False
# Set up and upload
success = setup_git_repository()
if success:
print("\nπ GitFlow AI is now on GitHub!")
print("π Don't forget to star your own repository! β")
return success
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)