-
Notifications
You must be signed in to change notification settings - Fork 1
/
RepoSetup.fs
41 lines (33 loc) · 1.02 KB
/
RepoSetup.fs
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
/// Preparing a codebase based on a 'RepoSpec'
module FCSBenchmark.Generator.RepoSetup
open System.IO
open LibGit2Sharp
[<CLIMutable>]
type RepoSpec =
{
Name : string
GitUrl : string
Revision : string
}
override this.ToString () =
$"{this.Name} ({this.GitUrl}) @ {this.Revision}"
type Config =
{
BaseDir : string
ForceFCSBuild : bool
}
let revisionDir (config : Config) (spec : RepoSpec) : string =
Path.Combine (config.BaseDir, spec.Name, spec.Revision)
let prepareRepo (config : Config) (spec : RepoSpec) : Repository =
log.Information ("Preparing repo {spec}", spec)
let dir = revisionDir config spec
if Repository.IsValid dir |> not then
use repo = Git.clone dir spec.GitUrl
Git.checkout repo spec.Revision
repo
else
log.Information (
"{dir} already exists and is a git repository - will assume the repository revision is already checked out",
dir
)
new Repository (dir)