@@ -42,23 +42,19 @@ public RepositoryBranchMapping(string rootDirectory, (string BranchDirectory, st
42
42
/// </summary>
43
43
public ( string BranchDirectory , string TargetDirectory ) ? SubdirectoryMapping { get ; }
44
44
45
- public RepositoryBranchMapping RenameRootDirectory ( string oldPath , string newPath )
45
+ public RepositoryBranchMapping ApplyRename ( string oldPath , string newPath )
46
46
{
47
47
if ( ! PathUtils . IsAbsolute ( oldPath ) )
48
48
throw new ArgumentException ( "Old path must be absolute." , nameof ( oldPath ) ) ;
49
49
50
50
if ( ! PathUtils . IsAbsolute ( newPath ) )
51
51
throw new ArgumentException ( "New path must be absolute." , nameof ( newPath ) ) ;
52
52
53
- if ( ! PathUtils . IsOrContains ( RootDirectory , oldPath ) )
54
- throw new InvalidOperationException ( "The rename does not apply to this mapping." ) ;
55
-
56
- if ( SubdirectoryMapping is not null )
57
- throw new NotImplementedException ( "Research: Renaming and branching might behave differently when subdirectory mapping is involved." ) ;
58
-
59
53
return new RepositoryBranchMapping (
60
54
PathUtils . ReplaceContainingPath ( RootDirectory , oldPath , newPath ) ,
61
- subdirectoryMapping : null ) ;
55
+ SubdirectoryMapping is null ? null : (
56
+ PathUtils . ReplaceContainingPath ( SubdirectoryMapping . Value . BranchDirectory , oldPath , newPath ) ,
57
+ PathUtils . ReplaceContainingPath ( SubdirectoryMapping . Value . TargetDirectory , oldPath , newPath ) ) ) ;
62
58
}
63
59
64
60
public RepositoryBranchMapping WithSubdirectoryMapping ( string branchDirectory , string targetDirectory )
@@ -76,8 +72,7 @@ public RepositoryBranchMapping WithSubdirectoryMapping(string branchDirectory, s
76
72
if ( PathUtils . IsOrContains ( target , itemPath ) )
77
73
return null ;
78
74
79
- if ( PathUtils . IsOrContains ( branch , itemPath ) )
80
- itemPath = PathUtils . ReplaceContainingPath ( itemPath , branch , target ) ;
75
+ itemPath = PathUtils . ReplaceContainingPath ( itemPath , branch , target ) ;
81
76
}
82
77
83
78
return PathUtils . IsOrContains ( RootDirectory , itemPath )
0 commit comments