GitLabAPIWrapper#
- class langchain_community.utilities.gitlab.GitLabAPIWrapper[source]#
Bases:
BaseModel
Wrapper for GitLab API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- param gitlab_base_branch: str | None = None#
The base branch in the GitLab repository, used for comparisons. Usually ‘main’ or ‘master’. Defaults to ‘main’.
- param gitlab_branch: str | None = None#
The specific branch in the GitLab repository where the bot will make its commits. Defaults to ‘main’.
- param gitlab_personal_access_token: str | None = None#
Personal access token for the GitLab service, used for authentication.
- param gitlab_repository: str | None = None#
The name of the GitLab repository, in the form {username}/{repo-name}.
- comment_on_issue(comment_query: str) str [source]#
Adds a comment to a gitlab issue Parameters:
comment_query(str): a string which contains the issue number, two newlines, and the comment. for example: “1
- Working on it now”
adds the comment “working on it now” to issue 1
- Returns:
str: A success or failure message
- Parameters:
comment_query (str)
- Return type:
str
- create_branch(proposed_branch_name: str) str [source]#
Create a new branch in the repository and set it as the active branch
- Parameters:
proposed_branch_name (str) – The name of the new branch to be created
- Returns:
A success or failure message
- Return type:
str
- create_file(file_query: str) str [source]#
Creates a new file on the gitlab repo Parameters:
file_query(str): a string which contains the file path and the file contents. The file path is the first line in the string, and the contents are the rest of the string. For example, “hello_world.md
- # Hello World!”
- Returns:
str: A success or failure message
- Parameters:
file_query (str)
- Return type:
str
- create_pull_request(pr_query: str) str [source]#
Makes a pull request from the bot’s branch to the base branch Parameters:
pr_query(str): a string which contains the PR title and the PR body. The title is the first line in the string, and the body are the rest of the string. For example, “Updated README
- made changes to add info”
- Returns:
str: A success or failure message
- Parameters:
pr_query (str)
- Return type:
str
- delete_file(file_path: str) str [source]#
Deletes a file from the repo :param file_path: Where the file is :type file_path: str
- Returns:
Success or failure message
- Return type:
str
- Parameters:
file_path (str)
- get_issue(issue_number: int) Dict[str, Any] [source]#
Fetches a specific issue and its first 10 comments :param issue_number: The number for the gitlab issue :type issue_number: int
- Returns:
A dictionary containing the issue’s title, body, and comments as a string
- Return type:
dict
- Parameters:
issue_number (int)
- get_issues() str [source]#
Fetches all open issues from the repo
- Returns:
A plaintext report containing the number of issues and each issue’s title and number.
- Return type:
str
- list_branches_in_repo() str [source]#
Get the list of branches in the repository
- Returns:
A plaintext report containing the number of branches and each branch name
- Return type:
str
- list_files_from_directory(path: str) str [source]#
Get the list of files in the active branch of the repository from a specific directory
- Returns:
A plaintext report containing the list of files in the repository in the active branch from the specified directory
- Return type:
str
- Parameters:
path (str)
- list_files_in_bot_branch() str [source]#
Get the list of files in the active branch of the repository
- Returns:
A plaintext report containing the list of files in the repository in the active branch
- Return type:
str
- list_files_in_main_branch() str [source]#
Get the list of files in the main branch of the repository
- Returns:
A plaintext report containing the list of files in the repository in the main branch
- Return type:
str
- parse_issues(issues: List[Issue]) List[dict] [source]#
Extracts title and number from each Issue and puts them in a dictionary :param issues: A list of gitlab Issue objects :type issues: List[Issue]
- Returns:
A dictionary of issue titles and numbers
- Return type:
List[dict]
- Parameters:
issues (List[Issue])
- read_file(file_path: str) str [source]#
Reads a file from the gitlab repo :param file_path: the file path :type file_path: str
- Returns:
The file decoded as a string
- Return type:
str
- Parameters:
file_path (str)
- set_active_branch(branch_name: str) str [source]#
Equivalent to git checkout branch_name for this Agent. Clones formatting from Gitlab.
Returns an Error (as a string) if branch doesn’t exist.
- Parameters:
branch_name (str)
- Return type:
str
- update_file(file_query: str) str [source]#
Updates a file with new content. :param file_query: Contains the file path and the file contents.
The old file contents is wrapped in OLD <<<< and >>>> OLD The new file contents is wrapped in NEW <<<< and >>>> NEW For example: test/hello.txt OLD <<<< Hello Earth! >>>> OLD NEW <<<< Hello Mars! >>>> NEW
- Returns:
A success or failure message
- Parameters:
file_query (str)
- Return type:
str
Examples using GitLabAPIWrapper