diff options
Diffstat (limited to 'context_mirror_bot.ml')
| -rw-r--r-- | context_mirror_bot.ml | 50 | 
1 files changed, 36 insertions, 14 deletions
| diff --git a/context_mirror_bot.ml b/context_mirror_bot.ml index 1953aeb..cd619ea 100644 --- a/context_mirror_bot.ml +++ b/context_mirror_bot.ml @@ -62,7 +62,8 @@ exception Prepare_failed of string  let bootstrap_repo = "git@bitbucket.org:phg/context-mirror.git"         (* our mirror *)  let garden_repo    = "http://git.contextgarden.net/context/context.git" (* official, but broken *)  (*let mirror_repo    = "git@bitbucket.org:phg/context-mirror.git"         [> our mirror <]*) -let mirror_repo    = "git@bb-git-mirror:phg/context-mirror.git"         (* our mirror *) +let mirror_repos   = [ "old", "git@bb-git-mirror:phg/context-mirror.git"         (* our old mirror *) +                     ; "new", "git@gitlab.com:phgsng/context-mirror.git" ]      (* our current mirror *)  let sources =    [ { name = "beta"; @@ -90,7 +91,8 @@ let static_files = [    ("context-readme.rst",  "README.rst")  ] -let gitconfig = Printf.sprintf "\ +let gitconfig = +  let repo_config = Printf.sprintf "\  [core]    repositoryformatversion       = 0    filemode                      = true @@ -124,18 +126,32 @@ let gitconfig = Printf.sprintf "\    remote = garden    merge  = refs/heads/origin -[remote \"mirror\"] +"  bootstrap_repo garden_repo +  and dst_config = +    String.concat "\n" +      (List.map +         (fun (name, url) -> +            let rem = "mirror-"^name in +            Printf.sprintf "\ +[remote \"%s\"]    url   = %s -  fetch = +refs/heads/*:refs/remotes/mirror/* +  fetch = +refs/heads/*:refs/remotes/%s/* +" rem url rem) +         mirror_repos) +  in repo_config ^ dst_config + +(* +"  [branch \"beta\"] -  remote = mirror +  remote = %s    merge  = refs/heads/beta  [branch \"current\"] -  remote = mirror +  remote = %s    merge  = refs/heads/current -"  bootstrap_repo garden_repo mirror_repo +" +*)  let ssh_wrapper_script = Printf.sprintf "\  #!/bin/sh @@ -466,9 +482,15 @@ end = struct        | None -> raise (Git_checkout_failed br)        | Some _ ->            begin -            match list_of_pipe ("git push mirror " ^ br) with -              | None -> Bad "git push failed" -              | Some _ -> Good +            let rec aux = function +              | [] -> Good +              | (rem, _) :: rest -> +                 let cmd = Printf.sprintf "git push \"mirror-%s\" \"%s\"" rem br in +                 match list_of_pipe cmd with +                 | None -> Bad (Printf.sprintf "git-push: [%s] failed" cmd) +                 | Some _ -> aux rest +            in +            aux mirror_repos            end  end @@ -729,7 +751,7 @@ let run_update () =            | Import_ignored rationale -> msg rationale            | Import_failed errmsg -> err errmsg            | Imported br -> -            msg (Printf.sprintf "Pushing %s to mirror ..." br); +            msg (Printf.sprintf "Pushing %s to mirrors ..." br);              match Git.push br with                | Good -> msg "Success!"                | Bad errmsg -> @@ -739,12 +761,12 @@ let run_update () =    ()  let run_sync () = -  Git.fetch "mirror"; +  List.iter (fun (rem, _) -> Git.fetch rem) mirror_repos;    Git.fetch "garden";    Git.pull "beta";    Git.pull "current"; -  Git.pull ~rbr:"garden/master" "garden-master";    let name = "garden-master" in +  Git.pull ~rbr:name name;    msg "Pushing changes from context garden repo to mirror";    match Git.push name with      | Good -> msg "Success!" @@ -767,7 +789,7 @@ let run_push () =    forall_sources      (fun src ->         let name = src.name in -       msg (Printf.sprintf "Pushing branch %s to mirror ..." name); +       msg (Printf.sprintf "Pushing branch %s to mirrors ..." name);         match Git.push name with          | Good -> msg "Success!"          | Bad errmsg -> | 
