99from git import GitCommandError , InvalidGitRepositoryError , Repo
1010
1111from osa_tool .analytics .metadata import (
12- RepositoryMetadata ,
1312 GitHubMetadataLoader ,
1413 GitLabMetadataLoader ,
1514 GitverseMetadataLoader ,
15+ RepositoryMetadata ,
1616)
1717from osa_tool .utils .logger import logger
1818from osa_tool .utils .utils import get_base_repo_url , parse_folder_name
@@ -25,7 +25,8 @@ class GitAgent(abc.ABC):
2525 commit and push changes, and create pull requests.
2626
2727 Attributes:
28- AGENT_SIGNATURE: A signature string appended to pull request descriptions.
28+ agent_signature: A signature string appended to a pull request descriptions.
29+ author: An author name that appended to a pull request description.
2930 repo_url: The URL of the Git repository.
3031 clone_dir: The directory where the repository will be cloned.
3132 branch_name: The name of the branch to be created.
@@ -37,20 +38,17 @@ class GitAgent(abc.ABC):
3738 pr_report_body: A formatted message for a pull request.
3839 """
3940
40- AGENT_SIGNATURE = (
41- "\n \n ---\n *This PR was created by [osa_tool](https://github.com/aimclub/OSA).*"
42- "\n _OSA just makes your open source project better!_"
43- )
44-
45- def __init__ (self , repo_url : str , repo_branch_name : str = None , branch_name : str = "osa_tool" ):
41+ def __init__ (self , repo_url : str , repo_branch_name : str = None , branch_name : str = "osa_tool" , author : str = None ):
4642 """Initializes the agent with repository info.
4743
4844 Args:
4945 repo_url: The URL of the GitHub repository.
5046 repo_branch_name: The name of the repository's branch to be checked out.
5147 branch_name: The name of the branch to be created. Defaults to "osa_tool".
48+ author: The name of the author of the pull request.
5249 """
5350 load_dotenv ()
51+ self .author = author
5452 self .repo_url = repo_url
5553 self .clone_dir = os .path .join (os .getcwd (), parse_folder_name (repo_url ))
5654 self .branch_name = branch_name
@@ -61,6 +59,17 @@ def __init__(self, repo_url: str, repo_branch_name: str = None, branch_name: str
6159 self .base_branch = repo_branch_name or self .metadata .default_branch
6260 self .pr_report_body = ""
6361
62+ @property
63+ def agent_signature (self ) -> str :
64+ signature = "\n \n ---"
65+ if self .author :
66+ signature += f"\n *Author: { self .author } .*"
67+ signature += (
68+ "\n *This PR was created by [osa_tool](https://github.com/aimclub/OSA).*"
69+ "\n _OSA just makes your open source project better!_"
70+ )
71+ return signature
72+
6473 @abc .abstractmethod
6574 def _get_token (self ) -> str :
6675 """Return platform-specific token from environment."""
@@ -438,7 +447,7 @@ def create_pull_request(self, title: str = None, body: str = None) -> None:
438447 pr_title = title if title else last_commit .message
439448 pr_body = body if body else last_commit .message
440449 pr_body += self .pr_report_body
441- pr_body += self .AGENT_SIGNATURE
450+ pr_body += self .agent_signature
442451 pr_data = {
443452 "title" : pr_title ,
444453 "head" : head_branch ,
@@ -648,7 +657,7 @@ def create_pull_request(self, title: str = None, body: str = None) -> None:
648657 mr_title = title if title else last_commit .message
649658 mr_body = body if body else last_commit .message
650659 mr_body += self .pr_report_body
651- mr_body += self .AGENT_SIGNATURE
660+ mr_body += self .agent_signature
652661
653662 mr_data = {
654663 "title" : mr_title ,
@@ -838,7 +847,7 @@ def create_pull_request(self, title: str = None, body: str = None) -> None:
838847 pr_title = title if title else last_commit .message
839848 pr_body = body if body else last_commit .message
840849 pr_body += self .pr_report_body
841- pr_body += self .AGENT_SIGNATURE
850+ pr_body += self .agent_signature
842851
843852 pr_data = {
844853 "title" : pr_title ,
0 commit comments