Skip to content

Commit 2354b8e

Browse files
committed
refactor: move init_git_bare_repository to GitHub_utils because it is more generic and not bot-specific
1 parent 04c6535 commit 2354b8e

File tree

7 files changed

+18
-25
lines changed

7 files changed

+18
-25
lines changed

bot-components/Git_utils.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
open Base
22
open GitHub_types
3+
open Bot_info
34
open Lwt.Infix
45
open Lwt.Syntax
56
open Utils
@@ -139,3 +140,15 @@ let%expect_test "http_repo_url_parsing_example_from_gitlab_docs" =
139140
{|
140141
GitLab domain: "gitlab.example.com"
141142
GitLab repository full name: "gitlab-org/gitlab-test" |}]
143+
144+
let init_git_bare_repository ~bot_info =
145+
let* () = Lwt_io.printl "Initializing repository..." in
146+
"git init --bare"
147+
|&& f {|git config user.email "%s"|} bot_info.email
148+
|&& f {|git config user.name "%s"|} bot_info.github_name
149+
|> execute_cmd ~mask:[bot_info.github_pat]
150+
>>= function
151+
| Ok _ ->
152+
Lwt_io.printl "Bare repository initialized."
153+
| Error e ->
154+
Lwt_io.printlf "Error while initializing bare repository: %s." e

bot-components/Git_utils.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ val pr_from_branch : string -> int option * string
2828

2929
val parse_gitlab_repo_url :
3030
http_repo_url:string -> (string * string, string) result
31+
32+
val init_git_bare_repository : bot_info:Bot_info.t -> unit Lwt.t

src/ci/minimization.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
open Bot_components
2+
open Git_utils
23
open Base
34
open Utils
45
open Lwt.Infix
56
open GitHub_types
67
open Cohttp
78
open Cohttp_lwt_unix
8-
open Helpers
99

1010
type artifact_info =
1111
| ArtifactInfo of

src/utils/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
(public_name coq-bot.utils)
44
(libraries base bot-components coq-bot.config)
55
(wrapped false)
6-
(modules bench coq helpers))
6+
(modules bench coq))

src/utils/helpers.ml

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/utils/helpers.mli

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/webhooks/github.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ open Cohttp_lwt_unix
44
open Bot_components
55
open Bot_components.GitHub_types
66
open Bot_components.GitHub_GitLab_sync
7+
open Git_utils
78
open Bench
8-
open Helpers
99
open String_utils
1010
open Utils
1111
open Lwt.Infix

0 commit comments

Comments
 (0)