From 22a9b26619ebdc16bc5d2084d95c7f5adf202370 Mon Sep 17 00:00:00 2001 From: Updatebot Date: Mon, 26 Aug 2024 08:29:00 -0500 Subject: [PATCH] Support alternate target branch The `repo.branch` configuration setting controls the branch of the repote repository to check out. It is also used as the target branch name for the Gitea pull request. --- updatebot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/updatebot.py b/updatebot.py index 62e94b5..2aaddfb 100644 --- a/updatebot.py +++ b/updatebot.py @@ -158,6 +158,7 @@ Project = Union[ class RepoConfig(pydantic.BaseModel): url: str token_file: Path + branch: str = 'master' @functools.cached_property def repo_api_url(self) -> str: @@ -300,7 +301,7 @@ def main() -> None: d = Path(d) log.debug('Retreiving repository Git URL') repo_url = config.repo.get_git_url() - repo = git.Repo.clone_from(repo_url, d, depth=1) + repo = git.Repo.clone_from(repo_url, d, depth=1, b=config.repo.branch) log.debug('Checking out new branch: %s', args.branch_name) repo.heads[0].checkout(force=True, B=args.branch_name) title = None @@ -321,7 +322,7 @@ def main() -> None: ) ) repo.remote().push(force=True) - config.repo.create_pr(title, args.branch_name, 'master') + config.repo.create_pr(title, args.branch_name, config.repo.branch) if __name__ == '__main__':