WAGIT 0.1.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.
- wagit-0.1.0/PKG-INFO +51 -0
- wagit-0.1.0/README.md +36 -0
- wagit-0.1.0/WAGIT.egg-info/PKG-INFO +51 -0
- wagit-0.1.0/WAGIT.egg-info/SOURCES.txt +10 -0
- wagit-0.1.0/WAGIT.egg-info/dependency_links.txt +1 -0
- wagit-0.1.0/WAGIT.egg-info/entry_points.txt +2 -0
- wagit-0.1.0/WAGIT.egg-info/requires.txt +4 -0
- wagit-0.1.0/WAGIT.egg-info/top_level.txt +1 -0
- wagit-0.1.0/pyproject.toml +27 -0
- wagit-0.1.0/setup.cfg +4 -0
- wagit-0.1.0/wagit/__init__.py +1 -0
- wagit-0.1.0/wagit/cli.py +292 -0
wagit-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: WAGIT
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automatic Git Push CLI
|
|
5
|
+
Author-email: w4simg <w4simz@outlook.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: rich
|
|
12
|
+
Requires-Dist: questionary
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: groq
|
|
15
|
+
|
|
16
|
+
# WAGIT :rocket:
|
|
17
|
+
|
|
18
|
+
An automatic, interactive command-line tool to push your code to GitHub without having to remember or type out complex git commands.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install WAGIT
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **Automated Workflow**: Automatically initializes a git repository, detects current branches, and pushes your code.
|
|
29
|
+
- **Interactive File Staging**: Choose whether to stage all files or selectively pick which files you want to commit using a beautiful checkbox menu.
|
|
30
|
+
- **Changed Files Summary**: View a color-coded table of all Modified, Added, and Deleted files before you commit.
|
|
31
|
+
- **Smart Commit Messages with AI**: Powered by Groq AI! Select "Generate with AI" to have a fast LLM read your staged changes and write a clean, professional commit message for you automatically.
|
|
32
|
+
- **Automatic `.gitignore`**: If your project is missing one, `WAGIT` can instantly generate a `.gitignore` file for your specific programming language by fetching the official template from GitHub.
|
|
33
|
+
- **Undo Mistakes**: Safely revert your last local commit while preserving all your file changes with a single flag.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
Simply run the `WAGIT` command inside any directory you want to push to GitHub:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
WAGIT
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**To undo your last commit:**
|
|
44
|
+
```bash
|
|
45
|
+
WAGIT --undo
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**To get help:**
|
|
49
|
+
```bash
|
|
50
|
+
WAGIT --help
|
|
51
|
+
```
|
wagit-0.1.0/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# WAGIT :rocket:
|
|
2
|
+
|
|
3
|
+
An automatic, interactive command-line tool to push your code to GitHub without having to remember or type out complex git commands.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install WAGIT
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Automated Workflow**: Automatically initializes a git repository, detects current branches, and pushes your code.
|
|
14
|
+
- **Interactive File Staging**: Choose whether to stage all files or selectively pick which files you want to commit using a beautiful checkbox menu.
|
|
15
|
+
- **Changed Files Summary**: View a color-coded table of all Modified, Added, and Deleted files before you commit.
|
|
16
|
+
- **Smart Commit Messages with AI**: Powered by Groq AI! Select "Generate with AI" to have a fast LLM read your staged changes and write a clean, professional commit message for you automatically.
|
|
17
|
+
- **Automatic `.gitignore`**: If your project is missing one, `WAGIT` can instantly generate a `.gitignore` file for your specific programming language by fetching the official template from GitHub.
|
|
18
|
+
- **Undo Mistakes**: Safely revert your last local commit while preserving all your file changes with a single flag.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Simply run the `WAGIT` command inside any directory you want to push to GitHub:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
WAGIT
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**To undo your last commit:**
|
|
29
|
+
```bash
|
|
30
|
+
WAGIT --undo
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**To get help:**
|
|
34
|
+
```bash
|
|
35
|
+
WAGIT --help
|
|
36
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: WAGIT
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automatic Git Push CLI
|
|
5
|
+
Author-email: w4simg <w4simz@outlook.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: rich
|
|
12
|
+
Requires-Dist: questionary
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: groq
|
|
15
|
+
|
|
16
|
+
# WAGIT :rocket:
|
|
17
|
+
|
|
18
|
+
An automatic, interactive command-line tool to push your code to GitHub without having to remember or type out complex git commands.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install WAGIT
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **Automated Workflow**: Automatically initializes a git repository, detects current branches, and pushes your code.
|
|
29
|
+
- **Interactive File Staging**: Choose whether to stage all files or selectively pick which files you want to commit using a beautiful checkbox menu.
|
|
30
|
+
- **Changed Files Summary**: View a color-coded table of all Modified, Added, and Deleted files before you commit.
|
|
31
|
+
- **Smart Commit Messages with AI**: Powered by Groq AI! Select "Generate with AI" to have a fast LLM read your staged changes and write a clean, professional commit message for you automatically.
|
|
32
|
+
- **Automatic `.gitignore`**: If your project is missing one, `WAGIT` can instantly generate a `.gitignore` file for your specific programming language by fetching the official template from GitHub.
|
|
33
|
+
- **Undo Mistakes**: Safely revert your last local commit while preserving all your file changes with a single flag.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
Simply run the `WAGIT` command inside any directory you want to push to GitHub:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
WAGIT
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**To undo your last commit:**
|
|
44
|
+
```bash
|
|
45
|
+
WAGIT --undo
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**To get help:**
|
|
49
|
+
```bash
|
|
50
|
+
WAGIT --help
|
|
51
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wagit
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "WAGIT"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Automatic Git Push CLI"
|
|
9
|
+
authors = [
|
|
10
|
+
{ name="w4simg", email="w4simz@outlook.com" },
|
|
11
|
+
]
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.7"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"rich",
|
|
16
|
+
"questionary",
|
|
17
|
+
"requests",
|
|
18
|
+
"groq"
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
WAGIT = "wagit.cli:main"
|
wagit-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""WGIT package."""
|
wagit-0.1.0/wagit/cli.py
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
import datetime
|
|
4
|
+
import sys
|
|
5
|
+
import time
|
|
6
|
+
import argparse
|
|
7
|
+
import requests
|
|
8
|
+
import questionary
|
|
9
|
+
from rich.console import Console
|
|
10
|
+
from rich.prompt import Prompt, Confirm
|
|
11
|
+
from rich.table import Table
|
|
12
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, TaskProgressColumn
|
|
13
|
+
from rich.panel import Panel
|
|
14
|
+
from rich.align import Align
|
|
15
|
+
|
|
16
|
+
console = Console()
|
|
17
|
+
|
|
18
|
+
def run_cmd(cmd):
|
|
19
|
+
try:
|
|
20
|
+
subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
21
|
+
return True
|
|
22
|
+
except subprocess.CalledProcessError as e:
|
|
23
|
+
console.print(f"[bold red]Error executing {' '.join(cmd)}:[/bold red] {e.stderr}")
|
|
24
|
+
return False
|
|
25
|
+
|
|
26
|
+
def undo_last_commit():
|
|
27
|
+
try:
|
|
28
|
+
subprocess.run(["git", "rev-parse", "HEAD"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
29
|
+
except subprocess.CalledProcessError:
|
|
30
|
+
console.print("[bold red]No commits to undo.[/bold red]")
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
with console.status("[bold yellow]Undoing last commit...[/bold yellow]", spinner="dots"):
|
|
34
|
+
if run_cmd(["git", "reset", "--soft", "HEAD~1"]):
|
|
35
|
+
console.print("[bold green]✔ Last commit undone locally. File changes are preserved.[/bold green]")
|
|
36
|
+
|
|
37
|
+
def check_gitignore():
|
|
38
|
+
if not os.path.exists(".gitignore"):
|
|
39
|
+
create = Confirm.ask("[bold magenta]No .gitignore found. Do you want to generate one?[/bold magenta]")
|
|
40
|
+
if create:
|
|
41
|
+
lang = questionary.select(
|
|
42
|
+
"Select primary language/framework for .gitignore:",
|
|
43
|
+
choices=["Python", "Node", "Java", "C++", "Go", "Ruby", "Rust", "Other (Empty)"]
|
|
44
|
+
).ask()
|
|
45
|
+
|
|
46
|
+
if lang and lang != "Other (Empty)":
|
|
47
|
+
with console.status(f"[bold yellow]Fetching {lang} .gitignore...[/bold yellow]"):
|
|
48
|
+
try:
|
|
49
|
+
url = f"https://raw.githubusercontent.com/github/gitignore/main/{lang}.gitignore"
|
|
50
|
+
resp = requests.get(url)
|
|
51
|
+
if resp.status_code == 200:
|
|
52
|
+
with open(".gitignore", "w") as f:
|
|
53
|
+
f.write(resp.text)
|
|
54
|
+
console.print("[bold green]✔ .gitignore generated![/bold green]")
|
|
55
|
+
else:
|
|
56
|
+
console.print("[bold red]Failed to fetch template.[/bold red]")
|
|
57
|
+
except Exception as e:
|
|
58
|
+
console.print(f"[bold red]Error fetching template: {e}[/bold red]")
|
|
59
|
+
else:
|
|
60
|
+
open(".gitignore", "a").close()
|
|
61
|
+
console.print("[bold green]✔ Empty .gitignore created.[/bold green]")
|
|
62
|
+
|
|
63
|
+
def show_git_status():
|
|
64
|
+
try:
|
|
65
|
+
result = subprocess.run(["git", "status", "--porcelain"], stdout=subprocess.PIPE, text=True, check=True)
|
|
66
|
+
files = []
|
|
67
|
+
for line in result.stdout.splitlines():
|
|
68
|
+
if line:
|
|
69
|
+
status = line[:2]
|
|
70
|
+
path = line[3:]
|
|
71
|
+
files.append((status, path))
|
|
72
|
+
except subprocess.CalledProcessError:
|
|
73
|
+
return []
|
|
74
|
+
|
|
75
|
+
if not files:
|
|
76
|
+
console.print("[bold yellow]No changes detected in the repository to commit.[/bold yellow]")
|
|
77
|
+
return []
|
|
78
|
+
|
|
79
|
+
table = Table(title="Changed Files", show_header=True, header_style="bold magenta")
|
|
80
|
+
table.add_column("Status", style="cyan")
|
|
81
|
+
table.add_column("File Path", style="green")
|
|
82
|
+
|
|
83
|
+
for status, path in files:
|
|
84
|
+
s_text = "Modified" if "M" in status else "Added" if "A" in status or "??" in status else "Deleted" if "D" in status else status.strip()
|
|
85
|
+
color = "yellow" if "Modified" in s_text else "green" if "Added" in s_text else "red"
|
|
86
|
+
table.add_row(f"[{color}]{s_text}[/{color}]", path)
|
|
87
|
+
|
|
88
|
+
console.print(table)
|
|
89
|
+
return files
|
|
90
|
+
|
|
91
|
+
def get_groq_api_key():
|
|
92
|
+
config_file = os.path.expanduser("~/.wgit_config")
|
|
93
|
+
if os.path.exists(config_file):
|
|
94
|
+
with open(config_file, "r") as f:
|
|
95
|
+
for line in f:
|
|
96
|
+
if line.startswith("GROQ_API_KEY="):
|
|
97
|
+
return line.strip().split("=")[1]
|
|
98
|
+
|
|
99
|
+
console.print("[bold yellow]Groq API Key not found.[/bold yellow]")
|
|
100
|
+
console.print("[italic cyan]You can get a free API key here: https://console.groq.com/keys[/italic cyan]")
|
|
101
|
+
api_key = Prompt.ask("[bold magenta]Enter your Groq API Key (it will be saved securely)[/bold magenta]").strip()
|
|
102
|
+
if api_key:
|
|
103
|
+
with open(config_file, "a") as f:
|
|
104
|
+
f.write(f"GROQ_API_KEY={api_key}\n")
|
|
105
|
+
return api_key
|
|
106
|
+
return None
|
|
107
|
+
|
|
108
|
+
def generate_ai_commit():
|
|
109
|
+
api_key = get_groq_api_key()
|
|
110
|
+
if not api_key:
|
|
111
|
+
console.print("[bold red]API Key is required for AI commits.[/bold red]")
|
|
112
|
+
return None
|
|
113
|
+
|
|
114
|
+
try:
|
|
115
|
+
diff_result = subprocess.run(["git", "diff", "--staged"], stdout=subprocess.PIPE, text=True, check=True)
|
|
116
|
+
diff = diff_result.stdout.strip()
|
|
117
|
+
if not diff:
|
|
118
|
+
console.print("[bold red]No staged changes found to generate a commit message.[/bold red]")
|
|
119
|
+
return None
|
|
120
|
+
|
|
121
|
+
if len(diff) > 15000:
|
|
122
|
+
diff = diff[:15000] + "\n... (diff truncated)"
|
|
123
|
+
|
|
124
|
+
with console.status("[bold yellow]Generating smart commit message with Groq AI...[/bold yellow]", spinner="dots"):
|
|
125
|
+
from groq import Groq
|
|
126
|
+
client = Groq(api_key=api_key)
|
|
127
|
+
|
|
128
|
+
prompt = (
|
|
129
|
+
"You are an expert developer. Generate a concise, professional git commit message based on the following git diff. "
|
|
130
|
+
"Only output the commit message itself, nothing else. Do not wrap in quotes or code blocks.\n\n"
|
|
131
|
+
f"Diff:\n{diff}"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
completion = client.chat.completions.create(
|
|
135
|
+
model="llama-3.1-8b-instant",
|
|
136
|
+
messages=[{"role": "user", "content": prompt}],
|
|
137
|
+
temperature=0.3,
|
|
138
|
+
max_tokens=100
|
|
139
|
+
)
|
|
140
|
+
return completion.choices[0].message.content.strip()
|
|
141
|
+
except Exception as e:
|
|
142
|
+
console.print(f"[bold red]Error generating AI commit: {e}[/bold red]")
|
|
143
|
+
return None
|
|
144
|
+
|
|
145
|
+
def startup_animation():
|
|
146
|
+
with Progress(
|
|
147
|
+
SpinnerColumn(spinner_name="dots"),
|
|
148
|
+
TextColumn("[progress.description]{task.description}"),
|
|
149
|
+
BarColumn(style="magenta", complete_style="green"),
|
|
150
|
+
TaskProgressColumn(),
|
|
151
|
+
console=console,
|
|
152
|
+
transient=True,
|
|
153
|
+
) as progress:
|
|
154
|
+
task1 = progress.add_task("[cyan]Initializing environment...", total=100)
|
|
155
|
+
task2 = progress.add_task("[yellow]Loading modules...", total=100)
|
|
156
|
+
task3 = progress.add_task("[magenta]Checking git status...", total=100)
|
|
157
|
+
|
|
158
|
+
while not progress.finished:
|
|
159
|
+
progress.update(task1, advance=6)
|
|
160
|
+
progress.update(task2, advance=3)
|
|
161
|
+
progress.update(task3, advance=4.5)
|
|
162
|
+
time.sleep(0.02)
|
|
163
|
+
|
|
164
|
+
panel = Panel.fit(
|
|
165
|
+
"[bold cyan]W A G I T[/bold cyan]\n[italic green]Automatic Git Push CLI[/italic green]",
|
|
166
|
+
border_style="bold magenta",
|
|
167
|
+
padding=(1, 5)
|
|
168
|
+
)
|
|
169
|
+
console.print(Align.center(panel))
|
|
170
|
+
console.print()
|
|
171
|
+
|
|
172
|
+
def main():
|
|
173
|
+
parser = argparse.ArgumentParser(
|
|
174
|
+
description="WAGIT - Automatic Git Push CLI",
|
|
175
|
+
formatter_class=argparse.RawTextHelpFormatter,
|
|
176
|
+
epilog="""
|
|
177
|
+
Guides & Usage:
|
|
178
|
+
---------------
|
|
179
|
+
1. Run `WAGIT` in any directory to automatically:
|
|
180
|
+
- Initialize a git repository (if none exists)
|
|
181
|
+
- Add a remote origin (if none exists)
|
|
182
|
+
- Generate a .gitignore file (if none exists)
|
|
183
|
+
- Select files to stage
|
|
184
|
+
- Write a smart commit message using AI (Groq) or manually
|
|
185
|
+
- Push to GitHub
|
|
186
|
+
|
|
187
|
+
2. Run `WAGIT --undo` to safely undo your last local commit while keeping your file changes.
|
|
188
|
+
"""
|
|
189
|
+
)
|
|
190
|
+
parser.add_argument("--undo", action="store_true", help="Undo the last local commit")
|
|
191
|
+
args = parser.parse_args()
|
|
192
|
+
|
|
193
|
+
if args.undo:
|
|
194
|
+
undo_last_commit()
|
|
195
|
+
return
|
|
196
|
+
|
|
197
|
+
startup_animation()
|
|
198
|
+
|
|
199
|
+
if not os.path.exists(".git"):
|
|
200
|
+
with console.status("[bold yellow]Initializing git repository...[/bold yellow]", spinner="dots"):
|
|
201
|
+
if not run_cmd(["git", "init"]):
|
|
202
|
+
return
|
|
203
|
+
time.sleep(0.5)
|
|
204
|
+
console.print("[bold green]✔ Git repository initialized.[/bold green]")
|
|
205
|
+
|
|
206
|
+
check_gitignore()
|
|
207
|
+
|
|
208
|
+
repo_link = Prompt.ask("[bold magenta]Enter git repo link[/bold magenta]").strip()
|
|
209
|
+
if repo_link:
|
|
210
|
+
with console.status("[bold yellow]Fetching and setting up remote origin...[/bold yellow]", spinner="bouncingBar"):
|
|
211
|
+
subprocess.run(["git", "remote", "remove", "origin"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
212
|
+
if not run_cmd(["git", "remote", "add", "origin", repo_link]):
|
|
213
|
+
return
|
|
214
|
+
subprocess.run(["git", "fetch", "origin"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
215
|
+
time.sleep(0.5)
|
|
216
|
+
console.print("[bold green]✔ Fetched successfully![/bold green]")
|
|
217
|
+
else:
|
|
218
|
+
console.print("[bold red]Repo link cannot be empty.[/bold red]")
|
|
219
|
+
return
|
|
220
|
+
|
|
221
|
+
changed_files = show_git_status()
|
|
222
|
+
if not changed_files:
|
|
223
|
+
return
|
|
224
|
+
|
|
225
|
+
add_all = Confirm.ask("[bold magenta]Do you want to stage ALL changed files?[/bold magenta]", default=True)
|
|
226
|
+
if add_all:
|
|
227
|
+
with console.status("[bold yellow]Staging all files...[/bold yellow]", spinner="dots2"):
|
|
228
|
+
if not run_cmd(["git", "add", "."]):
|
|
229
|
+
return
|
|
230
|
+
else:
|
|
231
|
+
choices = [f"{path} ({status})" for status, path in changed_files]
|
|
232
|
+
selected = questionary.checkbox(
|
|
233
|
+
"Select files to stage:",
|
|
234
|
+
choices=choices
|
|
235
|
+
).ask()
|
|
236
|
+
|
|
237
|
+
if not selected:
|
|
238
|
+
console.print("[bold yellow]No files selected. Aborting.[/bold yellow]")
|
|
239
|
+
return
|
|
240
|
+
|
|
241
|
+
with console.status("[bold yellow]Staging selected files...[/bold yellow]", spinner="dots2"):
|
|
242
|
+
for item in selected:
|
|
243
|
+
path = item.split(" (")[0]
|
|
244
|
+
run_cmd(["git", "add", path])
|
|
245
|
+
|
|
246
|
+
add_comment = Confirm.ask("[bold magenta]Do you want to add a git commit comment?[/bold magenta]")
|
|
247
|
+
|
|
248
|
+
if add_comment:
|
|
249
|
+
use_ai = Confirm.ask("[bold magenta]Use Smart AI to generate the commit message?[/bold magenta]")
|
|
250
|
+
|
|
251
|
+
if use_ai:
|
|
252
|
+
ai_msg = generate_ai_commit()
|
|
253
|
+
if ai_msg:
|
|
254
|
+
comment = Prompt.ask("[bold magenta]Edit/Confirm commit message[/bold magenta]", default=ai_msg).strip()
|
|
255
|
+
else:
|
|
256
|
+
comment = Prompt.ask("[bold magenta]Enter commit comment manually[/bold magenta]").strip()
|
|
257
|
+
else:
|
|
258
|
+
comment = Prompt.ask("[bold magenta]Enter commit comment[/bold magenta]").strip()
|
|
259
|
+
if not comment:
|
|
260
|
+
comment = f"Auto commit: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
|
|
261
|
+
else:
|
|
262
|
+
comment = f"Auto commit: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
|
|
263
|
+
|
|
264
|
+
with console.status(f"[bold yellow]Committing with message: '{comment}'...[/bold yellow]", spinner="dots2"):
|
|
265
|
+
subprocess.run(["git", "commit", "-m", comment], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
266
|
+
time.sleep(0.3)
|
|
267
|
+
|
|
268
|
+
# Auto-detect branch
|
|
269
|
+
current_branch = ""
|
|
270
|
+
try:
|
|
271
|
+
result = subprocess.run(["git", "branch", "--show-current"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
|
|
272
|
+
current_branch = result.stdout.strip()
|
|
273
|
+
except subprocess.CalledProcessError:
|
|
274
|
+
pass
|
|
275
|
+
|
|
276
|
+
if current_branch:
|
|
277
|
+
branch = current_branch
|
|
278
|
+
console.print(f"[bold cyan]Current branch '{branch}' detected. Using it automatically.[/bold cyan]")
|
|
279
|
+
else:
|
|
280
|
+
branch = Prompt.ask("[bold magenta]Branch name[/bold magenta]", default="master").strip()
|
|
281
|
+
with console.status(f"[bold yellow]Preparing branch '{branch}'...[/bold yellow]", spinner="dots"):
|
|
282
|
+
subprocess.run(["git", "branch", "-M", branch], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
283
|
+
time.sleep(0.3)
|
|
284
|
+
|
|
285
|
+
with console.status(f"[bold yellow]Pushing to {branch}...[/bold yellow]", spinner="earth"):
|
|
286
|
+
if run_cmd(["git", "push", "-u", "origin", branch]):
|
|
287
|
+
console.print("[bold green]✔ Pushed successfully![/bold green] :tada:")
|
|
288
|
+
else:
|
|
289
|
+
console.print("[bold red]Failed to push. Please check your credentials, permissions, and repository link.[/bold red]")
|
|
290
|
+
|
|
291
|
+
if __name__ == "__main__":
|
|
292
|
+
main()
|