@@ -296,6 +296,8 @@ impl SanityCheck for StatementCompiledOrGit {
296
296
return Ok ( ( ) ) ;
297
297
} ;
298
298
299
+ let relative_target = relatively_resolve_symlink ( path) ?;
300
+
299
301
if booklet_dest. contains ( target) {
300
302
return Ok ( ( ) ) ;
301
303
}
@@ -314,7 +316,7 @@ impl SanityCheck for StatementCompiledOrGit {
314
316
) ) ,
315
317
) ?;
316
318
317
- if check_known_to_git ( task, task. path_of ( target ) ) ? {
319
+ if check_known_to_git ( task, task. path_of ( & relative_target ) ) ? {
318
320
return Ok ( ( ) ) ;
319
321
}
320
322
@@ -323,10 +325,10 @@ impl SanityCheck for StatementCompiledOrGit {
323
325
eval. add_diagnostic (
324
326
Diagnostic :: error ( format ! (
325
327
"The official statement at {} is not compiled by task-maker and not known to git" ,
326
- task. path_of( target ) . display( )
328
+ task. path_of( & relative_target ) . display( )
327
329
) )
328
330
. with_note ( "This means that it won't be available outside of your local directory" )
329
- . with_help ( format ! ( "Try git add -f {}" , task. path_of( target ) . display( ) ) )
331
+ . with_help ( format ! ( "Try git add -f {}" , task. path_of( & relative_target ) . display( ) ) )
330
332
) ?;
331
333
332
334
Ok ( ( ) )
@@ -462,6 +464,14 @@ fn extract_subtasks(path: &Path, tex: &str) -> Option<Vec<ExtractedSubtask>> {
462
464
. or_else ( || check_subtasks_ois ( path, tex) )
463
465
}
464
466
467
+ fn relatively_resolve_symlink ( path : & Path ) -> Result < PathBuf , Error > {
468
+ let mut path = path. to_path_buf ( ) ;
469
+ while path. is_symlink ( ) {
470
+ path = path. read_link ( ) ?;
471
+ }
472
+ Ok ( path)
473
+ }
474
+
465
475
/// Search for the statement file, returning its path or None if it doesn't exists.
466
476
///
467
477
/// Will return the path even in case of broken links.
0 commit comments