@@ -7,11 +7,15 @@ open System.Text.RegularExpressions
77open FSharpx.Control
88open FSharp.Control
99open FSharpx
10+ open Console
11+ open RichOutput
1012
1113type CloneRequest =
1214| CloneRequest of string * AsyncReplyChannel < Async < string >>
1315
14- type GitManager ( git : IGit , cacheDirectory : string ) =
16+ type GitManager ( console : ConsoleManager , git : IGit , cacheDirectory : string ) =
17+
18+ let log = namespacedLogger console " git"
1519
1620 let mutable refsCache = Map.empty
1721
@@ -37,7 +41,7 @@ type GitManager (git : IGit, cacheDirectory : string) =
3741 let folder = sanitizeFilename( url) .ToLower() + " -" + hash.Substring( 0 , 16 )
3842 Path.Combine( cacheDirectory, folder)
3943
40- let mailboxProcessor = MailboxProcessor.Start( fun inbox -> async {
44+ let mailboxCloneProcessor = MailboxProcessor.Start( fun inbox -> async {
4145 let mutable cloneCache : Map < string , Async < string >> = Map.empty
4246 while true do
4347 let! message = inbox.Receive()
@@ -63,11 +67,11 @@ type GitManager (git : IGit, cacheDirectory : string) =
6367 return ! this.DefaultBranch targetDirectory
6468 }
6569 member this.Clone ( url : string ) : Async < string > = async {
66- let! res = mailboxProcessor .PostAndAsyncReply( fun ch -> CloneRequest( url, ch))
70+ let! res = mailboxCloneProcessor .PostAndAsyncReply( fun ch -> CloneRequest( url, ch))
6771 return ! res
6872 }
6973
70- member this.CopyFromCache ( gitUrl : string ) ( revision : Revision ) ( installPath : string ) : Async < Unit > = async {
74+ member this.CopyFromCache ( gitUrl : string ) ( revision : Revision ) ( installPath : string ) : Async < Unit > = async {
7175 let! hasGit = Files.directoryExists ( Path.Combine ( installPath, " .git/" ))
7276 if hasGit then
7377 do ! git.Unshallow installPath
@@ -116,7 +120,9 @@ type GitManager (git : IGit, cacheDirectory : string) =
116120 match refsCache |> Map.tryFind url with
117121 | Some refs -> return refs
118122 | None ->
123+ log( ( text " fetching refs from " ) + ( highlight url), LoggingLevel.Info)
119124 let cacheDir = cloneFolderName url
125+ let startTime = System.DateTime.Now
120126 let! refs =
121127 Async.Parallel
122128 (
@@ -135,6 +141,12 @@ type GitManager (git : IGit, cacheDirectory : string) =
135141 else b
136142 )
137143 refsCache <- refsCache |> Map.add url refs
144+ let endTime = System.DateTime.Now
145+ log(( success " success " ) +
146+ ( text " fetched " ) +
147+ (( refs|> List.length). ToString() |> info) +
148+ ( text " refs in " ) +
149+ (( endTime- startTime). TotalSeconds.ToString( " N3" )|> info), LoggingLevel.Info)
138150 return refs
139151 }
140152 member this.FetchFile ( url : string ) ( revision : Revision ) ( file : string ) : Async < string > =
0 commit comments