gitpush-tool 0.1.4__tar.gz → 0.2.0__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.1.4/gitpush_tool.egg-info → gitpush_tool-0.2.0}/PKG-INFO +5 -3
- gitpush_tool-0.2.0/gitpush_tool/__init__.py +1 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/gitpush_tool/cli.py +134 -15
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0/gitpush_tool.egg-info}/PKG-INFO +5 -3
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/gitpush_tool.egg-info/SOURCES.txt +1 -0
- gitpush_tool-0.2.0/gitpush_tool.egg-info/requires.txt +1 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/setup.py +6 -4
- gitpush_tool-0.1.4/gitpush_tool/__init__.py +0 -1
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/LICENSE +0 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/MANIFEST.in +0 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/README.md +0 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/gitpush_tool.egg-info/dependency_links.txt +0 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/gitpush_tool.egg-info/entry_points.txt +0 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/gitpush_tool.egg-info/top_level.txt +0 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/pyproject.toml +0 -0
- {gitpush_tool-0.1.4 → gitpush_tool-0.2.0}/setup.cfg +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitpush-tool
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A CLI tool to simplify Git push operations with intelligent defaults and options.
|
|
5
|
-
Home-page: https://github.com/
|
|
5
|
+
Home-page: https://github.com/inevitablegs/gitpush
|
|
6
6
|
Author: Ganesh Sonawane
|
|
7
|
-
Author-email: sonawaneganu3101@
|
|
7
|
+
Author-email: sonawaneganu3101@gmail.com
|
|
8
8
|
License: MIT
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -12,6 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.6
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
+
Requires-Dist: requests>=2.25.0
|
|
15
16
|
Dynamic: author
|
|
16
17
|
Dynamic: author-email
|
|
17
18
|
Dynamic: classifier
|
|
@@ -20,6 +21,7 @@ Dynamic: description-content-type
|
|
|
20
21
|
Dynamic: home-page
|
|
21
22
|
Dynamic: license
|
|
22
23
|
Dynamic: license-file
|
|
24
|
+
Dynamic: requires-dist
|
|
23
25
|
Dynamic: requires-python
|
|
24
26
|
Dynamic: summary
|
|
25
27
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.0"
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
1
2
|
import os
|
|
2
3
|
import argparse
|
|
3
4
|
import sys
|
|
4
5
|
import requests
|
|
5
6
|
from getpass import getpass
|
|
6
7
|
import json
|
|
8
|
+
from datetime import datetime
|
|
7
9
|
|
|
8
10
|
def get_github_token():
|
|
9
11
|
"""Get GitHub token from various sources with priority order"""
|
|
@@ -25,6 +27,28 @@ def get_github_token():
|
|
|
25
27
|
|
|
26
28
|
return token
|
|
27
29
|
|
|
30
|
+
def get_github_username():
|
|
31
|
+
"""Get GitHub username from config or API"""
|
|
32
|
+
try:
|
|
33
|
+
# Try git config first
|
|
34
|
+
username = os.popen("git config github.user").read().strip()
|
|
35
|
+
if username:
|
|
36
|
+
return username
|
|
37
|
+
|
|
38
|
+
# Fallback to API if token exists
|
|
39
|
+
token = get_github_token()
|
|
40
|
+
if token:
|
|
41
|
+
headers = {
|
|
42
|
+
"Authorization": f"token {token}",
|
|
43
|
+
"Accept": "application/vnd.github+json"
|
|
44
|
+
}
|
|
45
|
+
response = requests.get("https://api.github.com/user", headers=headers)
|
|
46
|
+
if response.status_code == 200:
|
|
47
|
+
return response.json().get("login")
|
|
48
|
+
except:
|
|
49
|
+
pass
|
|
50
|
+
return None
|
|
51
|
+
|
|
28
52
|
def create_github_repo(repo_name, private=False, description=""):
|
|
29
53
|
"""Create a new GitHub repository using the GitHub API"""
|
|
30
54
|
token = get_github_token()
|
|
@@ -43,14 +67,18 @@ def create_github_repo(repo_name, private=False, description=""):
|
|
|
43
67
|
"name": repo_name,
|
|
44
68
|
"description": description,
|
|
45
69
|
"private": private,
|
|
46
|
-
"auto_init": False
|
|
70
|
+
"auto_init": False,
|
|
71
|
+
"has_issues": True,
|
|
72
|
+
"has_projects": False,
|
|
73
|
+
"has_wiki": False
|
|
47
74
|
}
|
|
48
75
|
|
|
49
76
|
try:
|
|
50
77
|
response = requests.post(
|
|
51
78
|
"https://api.github.com/user/repos",
|
|
52
79
|
headers=headers,
|
|
53
|
-
json=data
|
|
80
|
+
json=data,
|
|
81
|
+
timeout=10
|
|
54
82
|
)
|
|
55
83
|
|
|
56
84
|
# Detailed error handling
|
|
@@ -73,7 +101,7 @@ def create_github_repo(repo_name, private=False, description=""):
|
|
|
73
101
|
headers=headers
|
|
74
102
|
).json()
|
|
75
103
|
remaining = limits['resources']['core']['remaining']
|
|
76
|
-
reset_time = limits['resources']['core']['reset']
|
|
104
|
+
reset_time = datetime.fromtimestamp(limits['resources']['core']['reset']).strftime('%Y-%m-%d %H:%M:%S')
|
|
77
105
|
print(f"⏳ API calls remaining: {remaining}")
|
|
78
106
|
print(f"🔄 Rate limit resets at: {reset_time}")
|
|
79
107
|
except:
|
|
@@ -105,9 +133,79 @@ def create_github_repo(repo_name, private=False, description=""):
|
|
|
105
133
|
print("⚠️ Network connection problem detected")
|
|
106
134
|
return None
|
|
107
135
|
|
|
136
|
+
def create_with_gh_cli(repo_name, private=False, description=""):
|
|
137
|
+
"""Alternative using GitHub CLI if installed"""
|
|
138
|
+
try:
|
|
139
|
+
private_flag = "--private" if private else "--public"
|
|
140
|
+
cmd = f"gh repo create {repo_name} {private_flag} --source=. --remote=origin --push"
|
|
141
|
+
if description:
|
|
142
|
+
cmd += f" --description \"{description}\""
|
|
143
|
+
return os.system(cmd) == 0
|
|
144
|
+
except:
|
|
145
|
+
return False
|
|
146
|
+
|
|
147
|
+
def initialize_repository(remote_url=None):
|
|
148
|
+
"""Initialize git repository with sensible defaults"""
|
|
149
|
+
if not os.path.exists(".git"):
|
|
150
|
+
print("🛠 Initializing git repository")
|
|
151
|
+
os.system("git init")
|
|
152
|
+
os.system("git branch -M main")
|
|
153
|
+
|
|
154
|
+
if remote_url:
|
|
155
|
+
os.system(f"git remote add origin {remote_url}")
|
|
156
|
+
|
|
157
|
+
# Create basic .gitignore if doesn't exist
|
|
158
|
+
if not os.path.exists(".gitignore"):
|
|
159
|
+
with open(".gitignore", "w") as f:
|
|
160
|
+
f.write("""# Python
|
|
161
|
+
__pycache__/
|
|
162
|
+
*.py[cod]
|
|
163
|
+
*.so
|
|
164
|
+
.Python
|
|
165
|
+
env/
|
|
166
|
+
venv/
|
|
167
|
+
.env
|
|
168
|
+
|
|
169
|
+
# IDE
|
|
170
|
+
.vscode/
|
|
171
|
+
.idea/
|
|
172
|
+
*.swp
|
|
173
|
+
*.swo
|
|
174
|
+
|
|
175
|
+
# System
|
|
176
|
+
.DS_Store
|
|
177
|
+
Thumbs.db
|
|
178
|
+
|
|
179
|
+
# Project specific
|
|
180
|
+
*.log
|
|
181
|
+
*.tmp
|
|
182
|
+
*.bak
|
|
183
|
+
""")
|
|
184
|
+
print("📁 Created .gitignore file")
|
|
185
|
+
|
|
186
|
+
def check_for_updates():
|
|
187
|
+
"""Check for newer versions on PyPI"""
|
|
188
|
+
try:
|
|
189
|
+
current_version = "0.2.0" # Should match your setup.py
|
|
190
|
+
response = requests.get("https://pypi.org/pypi/gitpush-tool/json", timeout=2)
|
|
191
|
+
latest_version = response.json()["info"]["version"]
|
|
192
|
+
if latest_version != current_version:
|
|
193
|
+
print(f"ℹ️ New version available: {latest_version} (you have {current_version})")
|
|
194
|
+
print(" Run 'pip install --upgrade gitpush-tool' to update")
|
|
195
|
+
except:
|
|
196
|
+
pass
|
|
197
|
+
|
|
108
198
|
def run():
|
|
109
199
|
parser = argparse.ArgumentParser(
|
|
110
|
-
description="
|
|
200
|
+
description="🚀 Supercharged Git push tool with GitHub repo creation",
|
|
201
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
202
|
+
epilog="""Examples:
|
|
203
|
+
Basic push: gitpush_tool "Commit message"
|
|
204
|
+
Create new repo: gitpush_tool "Initial commit" --new-repo project-name
|
|
205
|
+
Private repository: gitpush_tool --new-repo private-project --private
|
|
206
|
+
Force push: gitpush_tool "Fix critical bug" --force
|
|
207
|
+
Push specific branch: gitpush_tool "Update feature" feature-branch upstream
|
|
208
|
+
"""
|
|
111
209
|
)
|
|
112
210
|
parser.add_argument("commit", nargs="?", help="Commit message")
|
|
113
211
|
parser.add_argument("branch", nargs="?", default="main", help="Branch name (default: main)")
|
|
@@ -129,28 +227,42 @@ def run():
|
|
|
129
227
|
description=args.description or ""
|
|
130
228
|
)
|
|
131
229
|
|
|
230
|
+
# Fallback to GitHub CLI if API fails
|
|
132
231
|
if not repo_url:
|
|
232
|
+
print("⚠️ Falling back to GitHub CLI...")
|
|
233
|
+
if create_with_gh_cli(args.new_repo, args.private, args.description):
|
|
234
|
+
username = get_github_username()
|
|
235
|
+
if username:
|
|
236
|
+
repo_url = f"https://github.com/{username}/{args.new_repo}.git"
|
|
237
|
+
else:
|
|
238
|
+
repo_url = None
|
|
239
|
+
else:
|
|
240
|
+
print("❌ Could not create repository. Please check your credentials.")
|
|
241
|
+
print("You can install GitHub CLI with: brew install gh (Mac) or winget install --id GitHub.cli (Windows)")
|
|
242
|
+
sys.exit(1)
|
|
243
|
+
|
|
244
|
+
if repo_url:
|
|
245
|
+
initialize_repository(repo_url)
|
|
246
|
+
args.init = False # Already initialized
|
|
247
|
+
else:
|
|
133
248
|
sys.exit(1)
|
|
134
|
-
|
|
135
|
-
# Initialize git if needed
|
|
136
|
-
if not os.path.exists(".git"):
|
|
137
|
-
args.init = True
|
|
138
|
-
|
|
139
|
-
# Set remote
|
|
140
|
-
os.system(f"git remote add {args.remote} {repo_url}")
|
|
141
249
|
|
|
142
250
|
if args.init:
|
|
143
|
-
|
|
144
|
-
os.system("git init")
|
|
251
|
+
initialize_repository()
|
|
145
252
|
|
|
253
|
+
# Stage all changes
|
|
146
254
|
os.system("git add .")
|
|
147
255
|
|
|
148
256
|
if args.commit:
|
|
149
257
|
print(f"📦 Committing: '{args.commit}'")
|
|
150
|
-
os.system(f'git commit -m "{args.commit}"')
|
|
258
|
+
commit_result = os.system(f'git commit -m "{args.commit}"')
|
|
259
|
+
if commit_result != 0:
|
|
260
|
+
print("❌ Commit failed")
|
|
261
|
+
sys.exit(1)
|
|
151
262
|
else:
|
|
152
263
|
print("⚠️ Skipping commit (no message provided)")
|
|
153
264
|
|
|
265
|
+
# Build push command
|
|
154
266
|
push_cmd = "git push"
|
|
155
267
|
if args.force:
|
|
156
268
|
push_cmd += " --force-with-lease"
|
|
@@ -160,7 +272,14 @@ def run():
|
|
|
160
272
|
push_cmd += f" {args.remote} {args.branch}"
|
|
161
273
|
|
|
162
274
|
print(f"🚀 Executing: {push_cmd}")
|
|
163
|
-
os.system(push_cmd)
|
|
275
|
+
push_result = os.system(push_cmd)
|
|
276
|
+
|
|
277
|
+
if push_result == 0:
|
|
278
|
+
print("✅ Successfully pushed changes")
|
|
279
|
+
else:
|
|
280
|
+
print("❌ Push failed")
|
|
281
|
+
sys.exit(1)
|
|
164
282
|
|
|
165
283
|
if __name__ == "__main__":
|
|
284
|
+
check_for_updates()
|
|
166
285
|
run()
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitpush-tool
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A CLI tool to simplify Git push operations with intelligent defaults and options.
|
|
5
|
-
Home-page: https://github.com/
|
|
5
|
+
Home-page: https://github.com/inevitablegs/gitpush
|
|
6
6
|
Author: Ganesh Sonawane
|
|
7
|
-
Author-email: sonawaneganu3101@
|
|
7
|
+
Author-email: sonawaneganu3101@gmail.com
|
|
8
8
|
License: MIT
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -12,6 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.6
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
+
Requires-Dist: requests>=2.25.0
|
|
15
16
|
Dynamic: author
|
|
16
17
|
Dynamic: author-email
|
|
17
18
|
Dynamic: classifier
|
|
@@ -20,6 +21,7 @@ Dynamic: description-content-type
|
|
|
20
21
|
Dynamic: home-page
|
|
21
22
|
Dynamic: license
|
|
22
23
|
Dynamic: license-file
|
|
24
|
+
Dynamic: requires-dist
|
|
23
25
|
Dynamic: requires-python
|
|
24
26
|
Dynamic: summary
|
|
25
27
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.25.0
|
|
@@ -3,20 +3,22 @@ from pathlib import Path
|
|
|
3
3
|
|
|
4
4
|
setup(
|
|
5
5
|
name="gitpush-tool",
|
|
6
|
-
version="0.
|
|
6
|
+
version="0.2.0",
|
|
7
7
|
packages=find_packages(),
|
|
8
|
-
install_requires=[
|
|
8
|
+
install_requires=[
|
|
9
|
+
'requests>=2.25.0',
|
|
10
|
+
],
|
|
9
11
|
entry_points={
|
|
10
12
|
"console_scripts": [
|
|
11
13
|
"gitpush_tool=gitpush_tool.cli:run"
|
|
12
14
|
],
|
|
13
15
|
},
|
|
14
16
|
author="Ganesh Sonawane",
|
|
15
|
-
author_email="sonawaneganu3101@
|
|
17
|
+
author_email="sonawaneganu3101@gmail.com",
|
|
16
18
|
description="A CLI tool to simplify Git push operations with intelligent defaults and options.",
|
|
17
19
|
long_description=Path("README.md").read_text(encoding="utf-8"),
|
|
18
20
|
long_description_content_type="text/markdown",
|
|
19
|
-
url="https://github.com/
|
|
21
|
+
url="https://github.com/inevitablegs/gitpush",
|
|
20
22
|
license="MIT",
|
|
21
23
|
classifiers=[
|
|
22
24
|
"Programming Language :: Python :: 3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|