From 9fee86d56895dd88223ee47843cded398dbf230b Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Fri, 21 Jul 2023 13:52:24 -0400 Subject: [PATCH] feat: allows pull request title to be configurable Signed-off-by: Jennifer Power --- action.yml | 4 ++++ entrypoint.sh | 1 + trestlebot/bot.py | 7 ++++++- trestlebot/cli.py | 8 ++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 5741ec77..83a312dd 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,10 @@ inputs: description: Commit message required: false default: "Sync automatic updates" + pull_request_title: + description: Custom pull request title + required: false + default: "Automatic updates from trestlebot" branch: description: Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event. required: false diff --git a/entrypoint.sh b/entrypoint.sh index 66a16dc5..585edde2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,6 +25,7 @@ command="python3.8 -m trestlebot \ --oscal-model=\"${INPUT_OSCAL_MODEL}\" \ --ssp-index-path=\"${INPUT_SSP_INDEX_PATH}\" \ --commit-message=\"${INPUT_COMMIT_MESSAGE}\" \ + --pull-request-title=\"${INPUT_PULL_REQUEST_TITLE}\" \ --branch=\"${INPUT_BRANCH}\" \ --file-patterns=\"${INPUT_FILE_PATTERN}\" \ --committer-name=\"${INPUT_COMMIT_USER_NAME}\" \ diff --git a/trestlebot/bot.py b/trestlebot/bot.py index b7c802dd..b13f63fa 100644 --- a/trestlebot/bot.py +++ b/trestlebot/bot.py @@ -91,6 +91,7 @@ def run( git_provider: Optional[GitProvider] = None, pre_tasks: Optional[List[TaskBase]] = None, target_branch: str = "", + pull_request_title: str = "Automatic updates from bot", check_only: bool = False, dry_run: bool = False, ) -> str: @@ -101,11 +102,15 @@ def run( branch: Branch to put updates to commit_name: Name of the user for commit creation commit_email: Email of the user for commit creation + commit_message: Customized commit message author_name: Name of the commit author author_email: Email of the commit author patterns: List of file patterns for `git add` git_provider: Optional configured git provider for interacting with the API pre_tasks: Optional task list to executing before updating the workspace + target_branch: Optional target or base branch for submitted pull request + pull_request_title: Optional customized pull request title + check_only: Optional heck if the repo is dirty. Fail if true. dry_run: Only complete local work. Do not push. Returns: @@ -173,7 +178,7 @@ def run( repo_name=repo_name, head_branch=branch, base_branch=target_branch, - title="Automatic updates from trestlebot", + title=pull_request_title, body="", ) diff --git a/trestlebot/cli.py b/trestlebot/cli.py index f019d533..feaefd0d 100644 --- a/trestlebot/cli.py +++ b/trestlebot/cli.py @@ -101,6 +101,13 @@ def _parse_cli_arguments() -> argparse.Namespace: default="chore: automatic updates", help="Commit message for automated updates", ) + parser.add_argument( + "--pull-request-title", + type=str, + required=False, + default="Automatic updates from trestlebot", + help="Customized title for submitted pull requests", + ) parser.add_argument( "--committer-name", type=str, @@ -253,6 +260,7 @@ def run() -> None: patterns=comma_sep_to_list(args.file_patterns), git_provider=git_provider, target_branch=args.target_branch, + pull_request_title=args.pull_request_title, check_only=args.check_only, )