Skip to content
Snippets Groups Projects
Commit b5cc8829 authored by Pablo Correa Gomez's avatar Pablo Correa Gomez Committed by Robert Eckelmann
Browse files

mrhlpr: add push command (MR 48)

Fixes #21
parent 3b23338f
No related branches found
No related tags found
1 merge request!48mrhlpr: add push command
Pipeline #185194 passed
......@@ -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
......
......@@ -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")):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment