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.
This commit is contained in:
2024-08-26 08:29:00 -05:00
committed by Dustin C. Hatch
parent d19481b063
commit 22a9b26619

View File

@@ -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__':