@@ -87,7 +87,10 @@ fn find_git_dir(path: &str) -> Result<Vec<PathBuf>> {
87
87
Ok ( found)
88
88
}
89
89
90
- /// Represents a workspace which is just a collection of repositories.
90
+ /// A `Workspace` is filesystem directory containing git repositories checked out
91
+ /// from one or more remotes. Each repository's path matches the remote's path,
92
+ /// for example:
93
+ /// <workspace path>/github.com/cilki/wsx
91
94
#[ derive( Debug , Serialize , Deserialize ) ]
92
95
pub struct Workspace {
93
96
/// A user-friendly name for the workspace like "personal" or "work"
@@ -121,23 +124,24 @@ pub struct Provider {
121
124
pub name : String ,
122
125
}
123
126
124
- /// Represents a workspace cache which is just a collection of bare repositories.
127
+ /// Caches repositories that are dropped from a `Workspace` in a separate directory.
128
+ /// Entries in this cache are bare repositories for space efficiency.
125
129
#[ derive( Debug , Serialize , Deserialize ) ]
126
130
pub struct Cache {
127
- pub cache : String ,
131
+ pub path : String ,
128
132
}
129
133
130
134
impl Cache {
131
135
/// Move the given repository into the cache.
132
136
pub fn cache ( & self , repo_path : String ) -> Result < ( ) > {
133
137
// Make sure the cache directory exists first
134
- std:: fs:: create_dir_all ( & self . cache ) ?;
138
+ std:: fs:: create_dir_all ( & self . path ) ?;
135
139
136
140
let source = format ! ( "{}/.git" , repo_path) ;
137
141
let dest = self . compute_cache_key ( & repo_path) ;
138
142
run_fun ! ( git -C $source config core. bare true ) ?;
139
143
140
- debug ! ( "Caching '{}' -> '{}'" , source, dest) ;
144
+ debug ! ( source = % source, dest = %dest , "Caching repository" ) ;
141
145
142
146
// Clear the cache entry if it exists
143
147
std:: fs:: remove_dir_all ( & dest) . ok ( ) ;
@@ -162,7 +166,7 @@ impl Cache {
162
166
fn compute_cache_key ( & self , path : & str ) -> String {
163
167
format ! (
164
168
"{}/{:x}" ,
165
- self . cache ,
169
+ self . path ,
166
170
Sha512 :: new( ) . chain_update( path) . finalize( )
167
171
)
168
172
}
0 commit comments