@@ -54,9 +54,10 @@ pub fn start_fork(
54
54
new_path : PathBuf ,
55
55
) -> Result < ForkStartResponse , OxenError > {
56
56
if new_path. exists ( ) {
57
- return Err ( OxenError :: basic_str (
58
- "A file already exists at the destination path." ,
59
- ) ) ;
57
+ return Err ( OxenError :: basic_str ( format ! (
58
+ "A file already exists at the destination path: {}" ,
59
+ new_path. to_string_lossy( )
60
+ ) ) ) ;
60
61
}
61
62
62
63
oxen_fs:: create_dir_all ( & new_path) ?;
@@ -184,6 +185,8 @@ fn count_items(path: &Path, status_repo: &Path, current_count: &mut u32) -> Resu
184
185
mod tests {
185
186
use std:: time:: Duration ;
186
187
188
+ use uuid:: Uuid ;
189
+
187
190
use super :: * ;
188
191
use crate :: error:: OxenError ;
189
192
use crate :: test;
@@ -193,11 +196,15 @@ mod tests {
193
196
test:: run_empty_local_repo_test_async ( |original_repo| {
194
197
async move {
195
198
let original_repo_path = original_repo. path ;
199
+ let forked_repo_path = original_repo_path
200
+ . parent ( )
201
+ . unwrap ( )
202
+ . join ( "forked" )
203
+ . join ( Uuid :: new_v4 ( ) . to_string ( ) ) ;
196
204
197
205
// Fork creates new repo
198
- let new_repo_path = original_repo_path. parent ( ) . unwrap ( ) . join ( "forked/new_repo" ) ;
199
- if new_repo_path. exists ( ) {
200
- std:: fs:: remove_dir_all ( & new_repo_path) ?;
206
+ if forked_repo_path. exists ( ) {
207
+ std:: fs:: remove_dir_all ( & forked_repo_path) ?;
201
208
}
202
209
203
210
let dir_path = original_repo_path. join ( "dir" ) ;
@@ -206,13 +213,11 @@ mod tests {
206
213
let file_path = dir_path. join ( "test_file.txt" ) ;
207
214
std:: fs:: write ( file_path, "test file content" ) ?;
208
215
209
- start_fork ( original_repo_path. clone ( ) , new_repo_path. clone ( ) ) ?;
210
- tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ; // Wait for 100 milliseconds
211
- let status = get_fork_status ( & new_repo_path) ; // Await the initial call
212
- let mut current_status = status?. status ;
216
+ start_fork ( original_repo_path. clone ( ) , forked_repo_path. clone ( ) ) ?;
217
+ let mut current_status = "in_progress" . to_string ( ) ;
213
218
while current_status == "in_progress" {
214
219
tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ; // Wait for 100 milliseconds
215
- current_status = match get_fork_status ( & new_repo_path ) {
220
+ current_status = match get_fork_status ( & forked_repo_path ) {
216
221
Ok ( status) => status. status ,
217
222
Err ( e) => {
218
223
if let OxenError :: ForkStatusNotFound ( _) = e {
@@ -225,9 +230,9 @@ mod tests {
225
230
}
226
231
let file_path = original_repo_path. clone ( ) . join ( "dir/test_file.txt" ) ;
227
232
228
- assert ! ( new_repo_path . exists( ) ) ;
233
+ assert ! ( forked_repo_path . exists( ) ) ;
229
234
// Verify that the content of .oxen/config.toml is the same in both repos
230
- let new_file_path = new_repo_path . join ( "dir/test_file.txt" ) ;
235
+ let new_file_path = forked_repo_path . join ( "dir/test_file.txt" ) ;
231
236
let original_content = fs:: read_to_string ( & file_path) ?;
232
237
let mut retries = 20 ;
233
238
let mut sleep_time = 100 ;
@@ -250,15 +255,12 @@ mod tests {
250
255
"The content of test_file.txt should be the same in both repositories"
251
256
) ;
252
257
253
- if new_repo_path. exists ( ) {
254
- std:: fs:: remove_dir_all ( & new_repo_path) ?;
255
- }
256
-
257
258
// Fork fails if repo exists
258
259
let new_repo_path_1 = original_repo_path
259
260
. parent ( )
260
261
. unwrap ( )
261
- . join ( "forked/new_repo_1" ) ;
262
+ . join ( "forked" )
263
+ . join ( Uuid :: new_v4 ( ) . to_string ( ) ) ;
262
264
if new_repo_path_1. exists ( ) {
263
265
std:: fs:: remove_dir_all ( & new_repo_path_1) ?;
264
266
}
@@ -272,10 +274,10 @@ mod tests {
272
274
273
275
// Fork excludes workspaces
274
276
let new_repo_path_2 = original_repo_path
275
- . clone ( )
276
277
. parent ( )
277
278
. unwrap ( )
278
- . join ( "forked/new_repo_2" ) ;
279
+ . join ( "forked" )
280
+ . join ( Uuid :: new_v4 ( ) . to_string ( ) ) ;
279
281
280
282
let workspaces_path = original_repo_path. join ( ".oxen/workspaces" ) ;
281
283
// Create a workspace directory and add a file to it
@@ -284,11 +286,10 @@ mod tests {
284
286
std:: fs:: write ( workspace_file, "test workspace content" ) ?;
285
287
286
288
start_fork ( original_repo_path. clone ( ) , new_repo_path_2. clone ( ) ) ?;
287
- let status = get_fork_status ( & new_repo_path_2) ;
288
- let mut current_status = status?. status ;
289
+ let mut current_status = "in_progress" . to_string ( ) ;
289
290
while current_status == "in_progress" {
290
291
tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
291
- current_status = match get_fork_status ( & new_repo_path ) {
292
+ current_status = match get_fork_status ( & new_repo_path_2 ) {
292
293
Ok ( status) => status. status ,
293
294
Err ( e) => {
294
295
if let OxenError :: ForkStatusNotFound ( _) = e {
0 commit comments