Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions penify_hook/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import urllib.parse
from threading import Thread

from penify_hook.utils import find_git_parent

from .commit_analyzer import CommitDocGenHook
from .folder_analyzer import FolderAnalyzerGenHook
from .file_analyzer import FileAnalyzerGenHook
Expand Down Expand Up @@ -287,6 +289,7 @@ def main():
print("Error: API token is required. Please provide it using -t option, PENIFY_API_TOKEN environment variable, or log in first.")
sys.exit(1)
open_terminal = args.terminal.lower() == "true"
args.git_folder_path = find_git_parent(args.git_folder_path)
commit_code(args.git_folder_path, token, args.message, open_terminal)
elif args.subcommand == "login":
login()
Expand Down
14 changes: 14 additions & 0 deletions penify_hook/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

class GitRepoNotFoundError(Exception):
pass

def find_git_parent(path):
current_dir = os.path.abspath(path)

while current_dir != os.path.dirname(current_dir): # Traverse up to the root directory
if os.path.isdir(os.path.join(current_dir, ".git")):
return current_dir # Return the parent folder containing the .git directory
current_dir = os.path.dirname(current_dir)

raise GitRepoNotFoundError(f"No Git repository found in the path or any of its parent directories: {path}")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="penify-cli",
version="0.1.4", # Increment the version number
version="0.1.5", # Increment the version number
packages=['penify_hook'], # Explicitly include the penify_hook package
install_requires=[
"requests",
Expand Down