Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncgitpush.ml
More file actions
Latest commit
60 lines (56 loc) · 1.71 KB
/
Copy pathsyncgitpush.ml
File metadata and controls
60 lines (56 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(* (c) Syncgit - Lucas Baudin <lucas.baudin@ens.fr> – 2015 - see LICENSE file. *)
openSyncgitcore
openThread
openUnix
openLwt
letdo_syncrepo_statetarget_repository_opt=
let target_repository =
match target_repository_opt with
|Somet -> t
|None ->
begin
match repo_state.repository.name with
|Somes -> Syncgitconfig.github_user ^"/"^ s
|None -> raise (InvalidArgument"source http url")
end
in
match repo_state.repository.name, repo_state.repository.source_http_url with
|Somename, Somesource_http_url ->
begin
print_string ("Syncing "^ name);
let (valid, end_source_url) = is_valid_uri source_http_url in
if valid then
let project_path =Syncgitconfig.path_git ^"/"^ end_source_url in
begin
begin
try
begin
Unix.stat project_path;
Unix.chdir project_path;
letWEXITED i =Lwt_main.run (Lwt_process.exec ("git", [|"git";"pull";source_http_url|])) in
if i =0then()
else raise UnknownGitPullError
end
with
|Unix.Unix_error(_) ->
begin
ensure_path_exist Syncgitconfig.path_git;
(* Now we can check if it has already been cloned *)
letWEXITED i =Lwt_main.run (Lwt_process.exec ("git", [|"git";"clone";source_http_url;project_path|])) in
if i =0then()
else raise UnknownGitCloneError
end
end;
Unix.chdir project_path;
letWEXITED i =Lwt_main.run (Lwt_process.exec ("git", [|"git";"push";Syncgitconfig.github_url ^ target_repository;"master"|])) in
if i ==0then
target_repository
else
raise UnknownGitPushError
end
else
raise (InvalidArgument"source http url")
end
|_ -> raise (NotEnoughArgumentsError"name, git source")
letlaunch_syncr=
Thread.create do_sync r