gitpush-tool 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gitpush_tool-0.2.2/gitpush_tool.egg-info → gitpush_tool-0.2.4}/PKG-INFO +1 -1
- gitpush_tool-0.2.4/gitpush_tool/__init__.py +1 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/gitpush_tool/cli.py +67 -69
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4/gitpush_tool.egg-info}/PKG-INFO +1 -1
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/setup.py +1 -1
- gitpush_tool-0.2.2/gitpush_tool/__init__.py +0 -1
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/LICENSE +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/MANIFEST.in +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/README.md +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/gitpush_tool.egg-info/SOURCES.txt +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/gitpush_tool.egg-info/dependency_links.txt +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/gitpush_tool.egg-info/entry_points.txt +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/gitpush_tool.egg-info/requires.txt +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/gitpush_tool.egg-info/top_level.txt +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/pyproject.toml +0 -0
- {gitpush_tool-0.2.2 → gitpush_tool-0.2.4}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.4"
|
|
@@ -4,7 +4,6 @@ import argparse
|
|
|
4
4
|
import sys
|
|
5
5
|
import subprocess
|
|
6
6
|
from datetime import datetime
|
|
7
|
-
import requests
|
|
8
7
|
|
|
9
8
|
def check_gh_installed():
|
|
10
9
|
"""Check if GitHub CLI is installed"""
|
|
@@ -42,13 +41,14 @@ def initialize_git_repository():
|
|
|
42
41
|
"""Initialize git repository if not already initialized"""
|
|
43
42
|
if not os.path.exists(".git"):
|
|
44
43
|
print("🛠 Initializing git repository")
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
try:
|
|
45
|
+
subprocess.run(["git", "init"], check=True)
|
|
46
|
+
subprocess.run(["git", "branch", "-M", "main"], check=True)
|
|
47
|
+
|
|
48
|
+
# Create basic .gitignore if doesn't exist
|
|
49
|
+
if not os.path.exists(".gitignore"):
|
|
50
|
+
with open(".gitignore", "w") as f:
|
|
51
|
+
f.write("""# Python
|
|
52
52
|
__pycache__/
|
|
53
53
|
*.py[cod]
|
|
54
54
|
*.so
|
|
@@ -72,8 +72,11 @@ Thumbs.db
|
|
|
72
72
|
*.tmp
|
|
73
73
|
*.bak
|
|
74
74
|
""")
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
print("📁 Created .gitignore file")
|
|
76
|
+
return True
|
|
77
|
+
except subprocess.CalledProcessError as e:
|
|
78
|
+
print(f"❌ Failed to initialize Git repository: {e}")
|
|
79
|
+
return False
|
|
77
80
|
return False
|
|
78
81
|
|
|
79
82
|
def create_initial_commit(commit_message="Initial commit"):
|
|
@@ -92,12 +95,22 @@ def create_initial_commit(commit_message="Initial commit"):
|
|
|
92
95
|
subprocess.run(["git", "commit", "-m", commit_message], check=True)
|
|
93
96
|
return True
|
|
94
97
|
return False
|
|
95
|
-
except subprocess.CalledProcessError:
|
|
98
|
+
except subprocess.CalledProcessError as e:
|
|
99
|
+
print(f"❌ Failed to create initial commit: {e}")
|
|
96
100
|
return False
|
|
97
101
|
|
|
98
102
|
def create_with_gh_cli(repo_name, private=False, description="", commit_message="Initial commit"):
|
|
99
103
|
"""Create and push to new repository using GitHub CLI"""
|
|
100
104
|
try:
|
|
105
|
+
# First ensure we have a Git repository
|
|
106
|
+
if not os.path.exists(".git"):
|
|
107
|
+
if not initialize_git_repository():
|
|
108
|
+
return False
|
|
109
|
+
|
|
110
|
+
# Create initial commit if needed
|
|
111
|
+
if not create_initial_commit(commit_message):
|
|
112
|
+
print("ℹ️ Using existing commits")
|
|
113
|
+
|
|
101
114
|
private_flag = "--private" if private else "--public"
|
|
102
115
|
cmd = [
|
|
103
116
|
"gh", "repo", "create", repo_name,
|
|
@@ -110,14 +123,7 @@ def create_with_gh_cli(repo_name, private=False, description="", commit_message=
|
|
|
110
123
|
if description:
|
|
111
124
|
cmd.extend(["--description", description])
|
|
112
125
|
|
|
113
|
-
|
|
114
|
-
needs_init = initialize_git_repository()
|
|
115
|
-
needs_commit = create_initial_commit(commit_message)
|
|
116
|
-
|
|
117
|
-
if needs_init or needs_commit:
|
|
118
|
-
print("⚡ Set up local Git repository with initial commit")
|
|
119
|
-
|
|
120
|
-
# Run the create command
|
|
126
|
+
print("🚀 Creating repository and pushing code...")
|
|
121
127
|
result = subprocess.run(cmd, check=True)
|
|
122
128
|
|
|
123
129
|
if result.returncode == 0:
|
|
@@ -135,29 +141,49 @@ def create_with_gh_cli(repo_name, private=False, description="", commit_message=
|
|
|
135
141
|
except subprocess.CalledProcessError as e:
|
|
136
142
|
print(f"❌ Failed to create repository: {e.stderr if e.stderr else 'Unknown error'}")
|
|
137
143
|
return False
|
|
144
|
+
except Exception as e:
|
|
145
|
+
print(f"❌ Unexpected error: {str(e)}")
|
|
146
|
+
return False
|
|
138
147
|
|
|
139
|
-
def
|
|
140
|
-
"""
|
|
148
|
+
def standard_git_push(commit_message, branch, remote, force=False, tags=False):
|
|
149
|
+
"""Handle standard git push operations"""
|
|
141
150
|
try:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if
|
|
146
|
-
|
|
147
|
-
print("
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
# Stage all changes
|
|
152
|
+
subprocess.run(["git", "add", "."], check=True)
|
|
153
|
+
|
|
154
|
+
# Commit if message provided
|
|
155
|
+
if commit_message:
|
|
156
|
+
print(f"📦 Committing: '{commit_message}'")
|
|
157
|
+
subprocess.run(["git", "commit", "-m", commit_message], check=True)
|
|
158
|
+
else:
|
|
159
|
+
print("ℹ️ No commit message provided - skipping commit")
|
|
160
|
+
|
|
161
|
+
# Build push command
|
|
162
|
+
push_cmd = ["git", "push"]
|
|
163
|
+
if force:
|
|
164
|
+
push_cmd.append("--force-with-lease")
|
|
165
|
+
if tags:
|
|
166
|
+
push_cmd.append("--tags")
|
|
167
|
+
if remote and branch:
|
|
168
|
+
push_cmd.extend([remote, branch])
|
|
169
|
+
|
|
170
|
+
print(f"🚀 Executing: {' '.join(push_cmd)}")
|
|
171
|
+
subprocess.run(push_cmd, check=True)
|
|
172
|
+
print("✅ Successfully pushed changes")
|
|
173
|
+
return True
|
|
174
|
+
except subprocess.CalledProcessError as e:
|
|
175
|
+
print(f"❌ Push failed: {e}")
|
|
176
|
+
return False
|
|
150
177
|
|
|
151
178
|
def run():
|
|
152
179
|
parser = argparse.ArgumentParser(
|
|
153
180
|
description="🚀 Supercharged Git push tool with GitHub repo creation",
|
|
154
181
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
155
182
|
epilog="""Examples:
|
|
156
|
-
|
|
183
|
+
Standard push: gitpush_tool "Commit message"
|
|
157
184
|
Create new repo: gitpush_tool "Initial commit" --new-repo project-name
|
|
158
185
|
Private repository: gitpush_tool --new-repo private-project --private
|
|
159
186
|
Force push: gitpush_tool "Fix critical bug" --force
|
|
160
|
-
Push specific branch: gitpush_tool "Update feature" feature-branch upstream
|
|
161
187
|
"""
|
|
162
188
|
)
|
|
163
189
|
parser.add_argument("commit", nargs="?", help="Commit message")
|
|
@@ -175,7 +201,6 @@ def run():
|
|
|
175
201
|
if args.new_repo:
|
|
176
202
|
print(f"🆕 Creating repository: {args.new_repo}")
|
|
177
203
|
|
|
178
|
-
# Check if GitHub CLI is installed
|
|
179
204
|
if not check_gh_installed():
|
|
180
205
|
print("❌ GitHub CLI (gh) is not installed")
|
|
181
206
|
print("Please install it first:")
|
|
@@ -184,12 +209,10 @@ def run():
|
|
|
184
209
|
print(" Linux: See https://github.com/cli/cli#installation")
|
|
185
210
|
sys.exit(1)
|
|
186
211
|
|
|
187
|
-
# Check if authenticated
|
|
188
212
|
if not gh_authenticated():
|
|
189
213
|
if not authenticate_with_gh():
|
|
190
214
|
sys.exit(1)
|
|
191
215
|
|
|
192
|
-
# Create repository with automatic initialization
|
|
193
216
|
commit_msg = args.commit if args.commit else "Initial commit"
|
|
194
217
|
if not create_with_gh_cli(
|
|
195
218
|
args.new_repo,
|
|
@@ -198,44 +221,19 @@ def run():
|
|
|
198
221
|
commit_message=commit_msg
|
|
199
222
|
):
|
|
200
223
|
sys.exit(1)
|
|
201
|
-
|
|
202
|
-
# Exit after creating new repo unless there are other operations
|
|
203
|
-
if not args.commit and not args.force and not args.tags:
|
|
204
|
-
sys.exit(0)
|
|
205
|
-
|
|
206
|
-
if args.init:
|
|
224
|
+
elif args.init:
|
|
207
225
|
if initialize_git_repository():
|
|
208
226
|
create_initial_commit(args.commit or "Initial commit")
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
except subprocess.CalledProcessError:
|
|
219
|
-
print("❌ Commit failed - no changes to commit?")
|
|
227
|
+
else:
|
|
228
|
+
# Standard git push operation
|
|
229
|
+
if not standard_git_push(
|
|
230
|
+
args.commit,
|
|
231
|
+
args.branch,
|
|
232
|
+
args.remote,
|
|
233
|
+
args.force,
|
|
234
|
+
args.tags
|
|
235
|
+
):
|
|
220
236
|
sys.exit(1)
|
|
221
237
|
|
|
222
|
-
# Build push command
|
|
223
|
-
push_cmd = ["git", "push"]
|
|
224
|
-
if args.force:
|
|
225
|
-
push_cmd.append("--force-with-lease")
|
|
226
|
-
if args.tags:
|
|
227
|
-
push_cmd.append("--tags")
|
|
228
|
-
if args.remote and args.branch:
|
|
229
|
-
push_cmd.extend([args.remote, args.branch])
|
|
230
|
-
|
|
231
|
-
print(f"🚀 Executing: {' '.join(push_cmd)}")
|
|
232
|
-
try:
|
|
233
|
-
subprocess.run(push_cmd, check=True)
|
|
234
|
-
print("✅ Successfully pushed changes")
|
|
235
|
-
except subprocess.CalledProcessError:
|
|
236
|
-
print("❌ Push failed")
|
|
237
|
-
sys.exit(1)
|
|
238
|
-
|
|
239
238
|
if __name__ == "__main__":
|
|
240
|
-
check_for_updates()
|
|
241
239
|
run()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|