Add GetCurrentBranch class for get_current_branch function with JSON definition

This commit is contained in:
2024-08-19 15:46:50 -05:00
parent bcea167299
commit 033a9e7fc6
@@ -0,0 +1,37 @@
import logging
class GetCurrentBranch:
def __init__(self, current_branch):
self.current_branch = current_branch
# Set up logging
self.logger = logging.getLogger(__name__)
self.logger.setLevel(logging.INFO)
# Create a file handler
file_handler = logging.FileHandler('get_current_branch.log')
file_handler.setLevel(logging.INFO)
# Create a console handler
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
# Create a formatting for the logs
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
file_handler.setFormatter(formatter)
console_handler.setFormatter(formatter)
# Add the handlers to the logger
self.logger.addHandler(file_handler)
self.logger.addHandler(console_handler)
def __call__(self):
self.logger.info(f"Getting current branch: {self.current_branch}")
return self.current_branch
# JSON definition for the get_current_branch function
get_current_branch_definition = {
"name": "get_current_branch",
"description": "Get the name of the current branch",
"parameters": {}
}