Skip to content

Commit 4987764

Browse files
Update .autoManagedVhd marker file location to agent work folder (#5416)
* Update the location of .autoManagedVhd marker file * Address feedback * Use executionContext.Variables --------- Co-authored-by: Semih Okur <seokur@microsoft.com>
1 parent d10c117 commit 4987764

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Agent.Plugins/GitSourceProvider.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,16 @@ public async Task GetSourceAsync(
618618
}
619619
}
620620

621-
if (File.Exists(Path.Combine(targetPath, ".autoManagedVhd"))
621+
string agentWorkFolder = executionContext.Variables.GetValueOrDefault("agent.workfolder")?.Value;
622+
if (!string.IsNullOrEmpty(agentWorkFolder)
623+
&& File.Exists(Path.Combine(agentWorkFolder, ".autoManagedVhd"))
622624
&& !AgentKnobs.DisableAutoManagedVhdShallowOverride.GetValue(executionContext).AsBoolean())
623625
{
624-
// The existing working directory comes from an auto-managed VHD and is a full,
625-
// non-shallow clone of the repository. Some pipelines enable shallow fetch, but
626-
// Git cannot convert an existing full clone into a shallow one in-place.
626+
// The existing working directory comes from an AutoManagedVHD (indicated by the
627+
// .autoManagedVhd marker file placed in the agent work folder).
628+
// An AutoManagedVHD always contains a full, non-shallow clone of the repository.
629+
// Some pipelines enable shallow fetch parameters (e.g., fetchDepth > 0). However,
630+
// Git cannot convert an existing full clone into a shallow one in-place.
627631
//
628632
// Technical reason:
629633
// A full clone already has complete commit history and object reachability.

0 commit comments

Comments
 (0)