@@ -19,22 +19,7 @@ def __init__(self, repo_path: str, api_client: APIClient, llm_client=None, jira_
1919 self .jira_client : JiraClient = jira_client # Add JIRA client as an optional parameter
2020
2121 def get_summary (self , instruction : str , generate_description : bool ) -> dict :
22- """Generate a summary for the commit based on the staged changes.
23-
24- This function retrieves the differences of the staged changes in the repository
25- and generates a commit summary using the provided instruction. If there are no
26- changes staged for commit, an exception is raised. If a JIRA client is
27- connected, it will attempt to extract issue keys from the current branch and
28- use them to fetch context. The summary can be generated either with a Language
29- Model (LLM) client or through the API client.
30-
31- Args:
32- instruction (str): A string containing instructions for generating the commit summary.
33- generate_description (bool): Whether to include detailed descriptions in the summary.
34-
35- Raises:
36- ValueError: If there are no changes staged for commit.
37- """
22+ """Generate a summary for the commit based on the staged changes."""
3823 diff = self .repo .git .diff ('--cached' )
3924 if not diff :
4025 raise ValueError ("No changes to commit" )
@@ -64,20 +49,8 @@ def get_summary(self, instruction: str, generate_description: bool) -> dict:
6449
6550
6651 def run (self , msg : Optional [str ], edit_commit_message : bool , generate_description : bool ):
67- """Run the post-commit hook.
68-
69- This method processes the modified files from the last commit, stages them, and
70- creates an auto-commit with an optional message. It also handles JIRA
71- integration if available. If there is an error generating the commit summary,
72- an exception is raised.
73-
74- Args:
75- msg (Optional[str]): An optional message to include in the commit.
76- edit_commit_message (bool): A flag indicating whether to open the git commit
77- edit terminal after committing.
78- generate_description (bool): A flag indicating whether to include a description
79- in the commit message.
80- """
52+ """Run the post-commit hook and create an auto-commit with optional JIRA
53+ integration."""
8154 summary : dict = self .get_summary (msg , True )
8255 if not summary :
8356 raise Exception ("Error generating commit summary" )
@@ -102,23 +75,7 @@ def run(self, msg: Optional[str], edit_commit_message: bool, generate_descriptio
10275
10376 def process_jira_integration (self , title : str , description : str , msg : str ) -> tuple :
10477 # Look for JIRA issue keys in commit message, title, description and user message
105- """Process JIRA integration by extracting issue keys from commit message
106- components and branch name.
107-
108- This function looks for JIRA issue keys in the provided commit title,
109- description, original user message, and the active branch name. It uses these
110- keys to update the commit message with JIRA information and adds comments to
111- the corresponding JIRA issues. If no keys are found, it logs a warning.
112-
113- Args:
114- title (str): The generated commit title.
115- description (str): The generated commit description.
116- msg (str): The original user message that might contain JIRA references.
117-
118- Returns:
119- tuple: A tuple containing the updated commit title and description with included JIRA
120- information.
121- """
78+ """Process JIRA integration to update commit message with issue keys."""
12279 issue_keys = []
12380 if self .jira_client :
12481 # Extract from message content
@@ -156,7 +113,7 @@ def process_jira_integration(self, title: str, description: str, msg: str) -> tu
156113 return title , description
157114
158115 def _amend_commit (self ):
159- """Amends the last commit message in the repository ."""
116+ """Open the default git editor to amend the last commit message ."""
160117 try :
161118 # Change to the repository directory
162119 os .chdir (self .repo_path )
0 commit comments