Skip to content

Commit 9747cf5

Browse files
mmitchemthalman
andauthored
Fix nested submodule clone in inner source clone (#13819)
* Fix nested submodule clone in inner source clone When a submodule has submodules, $sm_path only refers to the subpath from the immediate submodule parent. Based on this, it meant that nested submodules got cloned at the top level repo root. Instead, use $toplevel, which is the full path to the immediate parent. * Attempt to remove trailing slash * Add comments * Update src/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets Co-authored-by: Matt Thalman <mthalman@microsoft.com> --------- Co-authored-by: Matt Thalman <mthalman@microsoft.com>
1 parent 3ddc98a commit 9747cf5

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,19 @@
167167

168168
<_GitSubmoduleCloneArgs />
169169
<_GitSubmoduleCloneArgs>$(_GitSubmoduleCloneArgs) --source .</_GitSubmoduleCloneArgs>
170-
<_GitSubmoduleCloneArgs>$(_GitSubmoduleCloneArgs) --dest &quot;$(InnerSourceBuildRepoRoot)$sm_path&quot;</_GitSubmoduleCloneArgs>
170+
<!-- The destination is set using a bit of bash and msbuild logic that takes the root directory of innermost repository
171+
containing the submodule (root of repo, or parent submodule), then replaces that root path with the inner source build root
172+
location using sed, and then adds on the subpath of the submodule.
173+
174+
There are various escaped special characters here:
175+
- %24 ensures that msbuild does not attempt to evaluate the whole bash statement as a variable
176+
- &quot; ensures that the whole path is quoted.
177+
178+
We also use an atypical sed replacement delimiter (+), because the typical '/' would occur within paths
179+
180+
It is expected that when the inner clone goes away, this code goes away (see https://github.com/dotnet/source-build/issues/3072).
181+
-->
182+
<_GitSubmoduleCloneArgs>$(_GitSubmoduleCloneArgs) --dest &quot;%24(echo &quot;${toplevel}/&quot; | sed s+$(RepoRoot)+$(InnerSourceBuildRepoRoot)+)${sm_path}&quot;</_GitSubmoduleCloneArgs>
171183
<_GitSubmoduleCloneArgs Condition="'$(CopyWipIntoInnerSourceBuildRepo)' == 'true'">$(_GitSubmoduleCloneArgs) --copy-wip</_GitSubmoduleCloneArgs>
172184
<_GitSubmoduleCloneArgs Condition="'$(CleanInnerSourceBuildRepoRoot)' == 'true'">$(_GitSubmoduleCloneArgs) --clean</_GitSubmoduleCloneArgs>
173185
</PropertyGroup>

0 commit comments

Comments
 (0)