Skip to content

Commit 0ea86f6

Browse files
author
edgar-zorrilla-smartports
committed
feat(core): Update core
feat: Update core This commit introduces a new feature that leverages AI to enhance the core functionality of the smart-git-commit library. The update aims to improve the library's responsiveness and provide more intelligent suggestions. Affected files: - M setup.py - M smart_git_commit.py
1 parent 27c5faa commit 0ea86f6

File tree

2 files changed

+47
-17
lines changed

2 files changed

+47
-17
lines changed

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
setup(
1515
name="smart-git-commit",
16-
version="0.1.0",
16+
version="0.1.3",
1717
description="AI-powered Git commit workflow tool",
1818
long_description=long_description,
1919
long_description_content_type="text/markdown",
20-
author="Your Name",
21-
author_email="your.email@example.com",
22-
url="https://github.com/yourusername/smart-git-commit",
20+
author="Edgar Zorrilla",
21+
author_email="edgar@izignamx.com",
22+
url="https://github.com/CripterHack/smart-git-commit",
2323
packages=find_packages(),
2424
py_modules=["smart_git_commit"],
2525
install_requires=[

smart_git_commit.py

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import http.client
2222
import urllib.request
2323
import urllib.parse
24+
import socket
2425

2526
# Set up logging
2627
logging.basicConfig(
@@ -109,6 +110,24 @@ def component(self) -> str:
109110
# Default to the first directory name
110111
return parts[0]
111112

113+
@property
114+
def is_formatting_change(self) -> bool:
115+
"""Determine if this change is likely just formatting."""
116+
if not self.content_diff:
117+
return False
118+
119+
# Simple heuristics to detect formatting changes
120+
formatting_indicators = [
121+
# Only whitespace changes
122+
self.content_diff.strip().startswith('diff') and all(line.startswith(('+', '-', ' ')) and line.strip() in ('', '+', '-') for line in self.content_diff.splitlines()[1:] if line and not line.startswith(('---', '+++', 'diff', 'index', '@@'))),
123+
# Common formatter markers
124+
'import format' in self.content_diff.lower(),
125+
'prettier' in self.content_diff.lower(),
126+
'fmt' in self.content_diff.lower() and len(self.content_diff) < 500
127+
]
128+
129+
return any(formatting_indicators)
130+
112131

113132
@dataclass
114133
class CommitGroup:
@@ -207,19 +226,30 @@ def __init__(self, host: str = "http://localhost:11434", model: Optional[str] =
207226

208227
def _get_host_connection(self) -> Tuple[str, int]:
209228
"""Parse host string and return connection parameters."""
210-
if self.host.startswith("http://"):
211-
parsed_url = urllib.parse.urlparse(self.host)
212-
host = parsed_url.netloc
213-
port = parsed_url.port or 11434
214-
elif self.host.startswith("https://"):
215-
parsed_url = urllib.parse.urlparse(self.host)
216-
host = parsed_url.netloc
217-
port = parsed_url.port or 443
218-
else:
219-
host = self.host
220-
port = 11434
229+
try:
230+
if self.host.startswith("http://"):
231+
parsed_url = urllib.parse.urlparse(self.host)
232+
host = parsed_url.netloc.split(':')[0] # Extract only hostname part
233+
port = parsed_url.port or 11434
234+
elif self.host.startswith("https://"):
235+
parsed_url = urllib.parse.urlparse(self.host)
236+
host = parsed_url.netloc.split(':')[0] # Extract only hostname part
237+
port = parsed_url.port or 443
238+
else:
239+
host = self.host.split(':')[0] # Handle case if port is included
240+
port = 11434
221241

222-
return host, port
242+
# Test connection before returning
243+
socket.getaddrinfo(host, port)
244+
return host, port
245+
except Exception as e:
246+
logger.warning(f"Connection error to {self.host}: {str(e)}")
247+
# Fall back to localhost if specified host fails
248+
if self.host != "localhost" and self.host != "http://localhost:11434":
249+
logger.info("Trying localhost as fallback")
250+
self.host = "http://localhost:11434"
251+
return "localhost", 11434
252+
raise
223253

224254
def _get_available_models(self) -> List[str]:
225255
"""Get a list of available models from Ollama."""
@@ -600,7 +630,7 @@ def _ai_subdivide_changes(self, component: str, changes: List[GitChange]) -> Lis
600630
4. The criteria for which files should be included
601631
602632
Format each group as JSON:
603-
{"type": "...", "name": "...", "description": "...", "criteria": "..."}
633+
{{"type": "...", "name": "...", "description": "...", "criteria": "..."}}
604634
605635
Separate each group with ---
606636
"""

0 commit comments

Comments
 (0)