@@ -59,10 +59,22 @@ public protocol WorkspaceDelegate: class {
59
59
/// The workspace has finished updating and all the dependencies are already up-to-date.
60
60
func dependenciesUpToDate( )
61
61
62
- /// The workspace has started cloning this repository.
62
+ /// The workspace is about to clone a repository from the local cache to a working directory.
63
+ func willClone( repository url: String , to path: AbsolutePath )
64
+
65
+ /// The workspace has cloned a repository from the local cache to a working directory. The error indicates whether the operation failed or succeeded.
66
+ func didClone( repository url: String , to path: AbsolutePath , error: Diagnostic ? )
67
+
68
+ /// The workspace has started cloning this repository. This callback is marginally deprecated in favor of the willClone/didClone pair.
63
69
func cloning( repository: String )
64
70
65
- /// The workspace is checking out a repository.
71
+ /// The workspace is about to check out a particular revision of a working directory.
72
+ func willCheckOut( repository url: String , revision: String , at path: AbsolutePath )
73
+
74
+ /// The workspace has checked out a particular revision of a working directory. The error indicates whether the operation failed or succeeded.
75
+ func didCheckOut( repository url: String , revision: String , at path: AbsolutePath , error: Diagnostic ? )
76
+
77
+ /// The workspace is checking out a repository. This callback is marginally deprecated in favor of the willCheckOut/didCheckOut pair.
66
78
func checkingOut( repository: String , atReference reference: String , to path: AbsolutePath )
67
79
68
80
/// The workspace is removing this repository because it is no longer needed.
@@ -86,6 +98,15 @@ public protocol WorkspaceDelegate: class {
86
98
public extension WorkspaceDelegate {
87
99
func willLoadManifest( packagePath: AbsolutePath , url: String , version: Version ? , packageKind: PackageReference . Kind ) { }
88
100
func didLoadManifest( packagePath: AbsolutePath , url: String , version: Version ? , packageKind: PackageReference . Kind , manifest: Manifest ? , diagnostics: [ Diagnostic ] ) { }
101
+ func willClone( repository url: String , to path: AbsolutePath ) {
102
+ cloning ( repository: url)
103
+ }
104
+ func didClone( repository url: String , to path: AbsolutePath , error: Diagnostic ? ) { }
105
+ func cloning( repository: String ) { }
106
+ func willCheckOut( repository url: String , revision: String , at path: AbsolutePath ) {
107
+ checkingOut ( repository: url, atReference: revision, to: path)
108
+ }
109
+ func didCheckOut( repository url: String , revision: String , at path: AbsolutePath , error: Diagnostic ? ) { }
89
110
func checkingOut( repository: String , atReference: String , to path: AbsolutePath ) { }
90
111
func repositoryWillUpdate( _ repository: String ) { }
91
112
func repositoryDidUpdate( _ repository: String ) { }
@@ -2233,8 +2254,9 @@ extension Workspace {
2233
2254
try fileSystem. removeFileTree ( path)
2234
2255
2235
2256
// Inform the delegate that we're starting cloning.
2236
- delegate? . cloning ( repository: handle. repository. url)
2257
+ delegate? . willClone ( repository: handle. repository. url, to : path )
2237
2258
try handle. cloneCheckout ( to: path, editable: false )
2259
+ delegate? . didClone ( repository: handle. repository. url, to: path, error: nil )
2238
2260
2239
2261
return path
2240
2262
}
@@ -2260,7 +2282,7 @@ extension Workspace {
2260
2282
let workingRepo = try repositoryManager. provider. openCheckout ( at: path)
2261
2283
2262
2284
// Inform the delegate.
2263
- delegate? . checkingOut ( repository: package . repository. url, atReference : checkoutState. description, to : path)
2285
+ delegate? . willCheckOut ( repository: package . repository. url, revision : checkoutState. description, at : path)
2264
2286
2265
2287
// Do mutable-immutable dance because checkout operation modifies the disk state.
2266
2288
try fileSystem. chmod ( . userWritable, path: path, options: [ . recursive, . onlyFiles] )
@@ -2274,6 +2296,8 @@ extension Workspace {
2274
2296
checkoutState: checkoutState) )
2275
2297
try state. saveState ( )
2276
2298
2299
+ delegate? . didCheckOut ( repository: package . repository. url, revision: checkoutState. description, at: path, error: nil )
2300
+
2277
2301
return path
2278
2302
}
2279
2303
0 commit comments