From fd11d844667e7ffb80b4a14515128a4d008aff24 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sun, 3 Nov 2024 21:11:12 -0500 Subject: [PATCH] feat: ensure push on pr create --- frg/cli.py | 4 ++++ frg/git.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/frg/cli.py b/frg/cli.py index 32a229b..f982d28 100644 --- a/frg/cli.py +++ b/frg/cli.py @@ -4,6 +4,7 @@ import click import pydantic import frg.forgejo.browser as forgejo_browser +import frg.git as git from frg.configuration import Config, get_configuration from frg.context import GitContext, get_git_context @@ -61,6 +62,9 @@ def pr(ctx): @click.pass_obj def create_pr(ctx, web: bool): """Interacts with pull requests.""" + + git.push(branch=ctx.git.current_branch) + if web: forgejo_browser.create_pull_request_via_web( head=ctx.git.current_branch, diff --git a/frg/git.py b/frg/git.py index 83b05bd..50ccffd 100644 --- a/frg/git.py +++ b/frg/git.py @@ -27,3 +27,8 @@ def get_current_branch() -> CommandResult: def get_current_remote_url() -> CommandResult: """Returns the remote origin url.""" return _git(["config", "--get", "remote.origin.url"]) + + +def push(*, branch: str) -> CommandResult: + """Pushes the current local commits to remote.""" + return _git(["push", "--set-upstream", "origin", branch])