@@ -16,16 +16,20 @@ def __init__(self, repo_path: str, api_client: APIClient):
1616 self .repo_details = self .get_repo_details ()
1717
1818 def get_repo_details (self ):
19- """
20- Get the details of the repository, including the hosting service (e.g., GitHub, Azure DevOps),
19+ """Get the details of the repository, including the hosting service,
2120 organization name, and repository name.
2221
23- This method checks the remote URL of the repository to determine whether it is hosted on
24- GitHub, Azure DevOps, or another service. It also extracts the organization (or user) name
25- and the repository name from the URL.
22+ This method checks the remote URL of the repository to determine whether
23+ it is hosted on GitHub, Azure DevOps, Bitbucket, GitLab, or another
24+ service. It extracts the organization (or user) name and the repository
25+ name from the URL. If the hosting service is not recognized, it will
26+ return "Unknown Hosting Service". The method handles potential errors
27+ during the extraction process and returns a dictionary with the relevant
28+ details.
2629
2730 Returns:
28- dict: A dictionary containing the hosting service, organization name, repository name, and remote URL.
31+ dict: A dictionary containing the organization name, repository name, and
32+ hosting service.
2933 """
3034 remote_url = None
3135 hosting_service = "Unknown"
@@ -75,6 +79,24 @@ def get_repo_details(self):
7579 }
7680
7781 def get_summary (self , instruction : str ):
82+ """Generate a summary for the commit based on the staged changes.
83+
84+ This function retrieves the differences of the staged changes in the
85+ repository and generates a commit summary using the provided
86+ instruction. If there are no changes staged for commit, an exception is
87+ raised.
88+
89+ Args:
90+ instruction (str): A string containing instructions for generating the commit summary.
91+
92+ Returns:
93+ str: The generated commit summary based on the staged changes and provided
94+ instruction.
95+
96+ Raises:
97+ Exception: If there are no changes staged for commit.
98+ """
99+
78100 diff = self .repo .git .diff ('--cached' )
79101 if not diff :
80102 raise Exception ("No changes to commit" )
@@ -88,7 +110,16 @@ def run(self, msg: Optional[str], edit_commit_message: bool):
88110 and processes each file. It stages any files that have been modified
89111 during processing and creates an auto-commit if changes were made. A
90112 progress bar is displayed to indicate the processing status of each
91- file.
113+ file. If there is an error generating the commit summary, an exception
114+ is raised.
115+
116+ Args:
117+ msg (Optional[str]): An optional message to include in the commit.
118+ edit_commit_message (bool): A flag indicating whether to open the
119+ git commit edit terminal after committing.
120+
121+ Raises:
122+ Exception: If there is an error generating the commit summary.
92123 """
93124 summary : dict = self .get_summary (msg )
94125 if not summary :
@@ -106,11 +137,12 @@ def run(self, msg: Optional[str], edit_commit_message: bool):
106137
107138
108139 def _amend_commit (self ):
109- """
110- Open the default git editor for editing the commit message.
111-
112- Args:
113- initial_message (str): The initial commit message to populate the editor with.
140+ """Open the default git editor for editing the commit message.
141+
142+ This function changes the current working directory to the repository
143+ path, runs the git command to amend the last commit, and opens the
144+ default editor for the user to modify the commit message. After the
145+ operation, it returns to the original directory.
114146 """
115147 try :
116148 # Change to the repository directory
0 commit comments