diff --git a/mrhlpr/frontend.py b/mrhlpr/frontend.py index d16f03ca78937f066165fa30f447619cd0740fc2..77603cddb97fef8d5dd50016a4842bc3edf88ee9 100644 --- a/mrhlpr/frontend.py +++ b/mrhlpr/frontend.py @@ -230,6 +230,9 @@ def parse_args() -> argparse.Namespace: help=f"add message to last commit: {ci_labels['skip_vercheck']}", ) + # push + sub.add_parser("push", help="Push the MR to gitlab") + # finish finish = sub.add_parser("finish", help="help finishing the MR (push, approve, merge...)") finish.add_argument( @@ -265,6 +268,9 @@ def main(): mr_id = mr.checked_out() mr.fixmsg(mr_id, args.skip_build, args.ignore_count, args.skip_vercheck) print_status(mr_id) + elif args.action == "push": + mr_id = mr.checked_out() + mr.push(mr_id, args.no_cache) elif args.action == "finish": mr_id = mr.checked_out() # TODO: Check that everything passed diff --git a/mrhlpr/mr.py b/mrhlpr/mr.py index 349112e83f07b9df10ccf78743884f18a93fbfb5..3ab89d04b81336b348d05bafe69cc359519f72c5 100644 --- a/mrhlpr/mr.py +++ b/mrhlpr/mr.py @@ -445,6 +445,16 @@ def fixmsg( run_git_filter_branch("msg_filter_add_label.py", "HEAD~1", label="skip_vercheck") +def push(mr_id: int, no_cache: bool = False) -> None: + print("Pushing changes...") + status = get_status(mr_id, no_cache) + origin = gitlab.parse_git_origin() + remote_local = status.source.split("/", 1)[0] + if remote_local == origin.project: + remote_local = "origin" + git.push_head(remote_local, status.source_branch) + + def finish( mr_id: int, comment: Optional[str], no_cache: bool = False, skip_approve: bool = False ) -> None: @@ -460,14 +470,7 @@ def finish( ) exit(1) - print("Pushing changes...") - status = get_status(mr_id, no_cache) - origin = gitlab.parse_git_origin() - remote_local = status.source.split("/", 1)[0] - if remote_local == origin.project: - remote_local = "origin" - git.push_head(remote_local, status.source_branch) - + push(mr_id, no_cache) gl = gitlab_api.Gitlab(url="https://gitlab.com", private_token=gitlab_token) try: gl.auth() @@ -478,6 +481,7 @@ def finish( ) exit(1) + origin = gitlab.parse_git_origin() project = gl.projects.get(origin.project_id) mr = project.mergerequests.get(mr_id) if skip_approve or (gl.user and mr.author and gl.user.id == mr.author.get("id")):