From 16cc99ca735fa1a023a8d6d176f0a34387b2acb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Zimmermann?= Date: Fri, 6 Oct 2023 18:01:47 +0200 Subject: [PATCH] Fix support for mirroring tags. --- src/actions.ml | 8 ++++---- src/git_utils.ml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/actions.ml b/src/actions.ml index 134be272..58998c70 100644 --- a/src/actions.ml +++ b/src/actions.ml @@ -2277,7 +2277,7 @@ let remove_labels_if_present ~bot_info (issue : issue_info) labels = let mirror_action ~bot_info ?(force = true) ~gitlab_domain ~owner ~repo ~base_ref ~head_sha () = (let open Lwt_result.Infix in - let local_ref = head_sha in + let local_ref = base_ref ^ "-" ^ head_sha in let gh_ref = {repo_url= f "https://github.com/%s/%s" owner repo; name= base_ref} in @@ -2293,7 +2293,7 @@ let mirror_action ~bot_info ?(force = true) ~gitlab_domain ~owner ~repo | Ok () -> Lwt.return_unit | Error e -> - Lwt_io.printlf "Error while mirroring branch %s of repository %s/%s: %s" + Lwt_io.printlf "Error while mirroring branch/tag %s of repository %s/%s: %s" base_ref owner repo e (* TODO: ensure there's no race condition for 2 push with very close timestamps *) @@ -2302,10 +2302,10 @@ let update_pr ?full_ci ?(skip_author_check = false) ~bot_info let open Lwt_result.Infix in (* Try as much as possible to get unique refnames for local branches. *) let local_head_branch = - f "head-%s-%s" pr_info.head.branch.name pr_info.head.sha + f "refs/heads/head-%s-%s" pr_info.head.branch.name pr_info.head.sha in let local_base_branch = - f "base-%s-%s" pr_info.base.branch.name pr_info.base.sha + f "refs/heads/base-%s-%s" pr_info.base.branch.name pr_info.base.sha in git_fetch pr_info.base.branch local_base_branch |&& git_fetch pr_info.head.branch local_head_branch diff --git a/src/git_utils.ml b/src/git_utils.ml index 12736a88..a3c49238 100644 --- a/src/git_utils.ml +++ b/src/git_utils.ml @@ -97,7 +97,7 @@ let execute_cmd command = report_status command "was stopped by signal number" signal let git_fetch ?(force = true) remote_ref local_branch_name = - f "git fetch --quiet -fu %s %s%s:refs/heads/%s" remote_ref.repo_url + f "git fetch --quiet -fu %s %s%s:%s" remote_ref.repo_url (if force then "+" else "") (Stdlib.Filename.quote remote_ref.name) (Stdlib.Filename.quote local_branch_name)