Skip to content

Commit

Permalink
Merge pull request #137 from AshleighAdams/shadow-clone-improvements
Browse files Browse the repository at this point in the history
Harded shadow repo against filterspec woes
  • Loading branch information
AshleighAdams authored Jun 27, 2023
2 parents 804ac95 + 4cd9f38 commit fd973fa
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/Verlite.Core/GitShadowRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private GitShadowRepo(ILogger? log, ICommandRunner runner, string root, string r
}
catch (CommandException)
{
Log?.Verbose($"Shadow repo fetch failed during ReadObject(), trying with --refetch");
await CmdRunner.Run(Root, "git", new[] { "fetch", RemoteUrl, "--filter=tree:0", "--prune", "--force", "--refetch" });
}

Expand All @@ -69,8 +70,26 @@ public async Task FetchTag(Tag tag, string gitRoot, string remoteName)
{
var (remoteUrl, _) = await CmdRunner.Run(gitRoot, "git", new[] { "remote", "get-url", remoteName });

await CmdRunner.Run(Root,
"git", new[] { "fetch", remoteUrl, $"+refs/tags/{tag.Name}:refs/tags/{tag.Name}", "--filter=tree:0" });
try
{
await CmdRunner.Run(Root,
"git", new[] {
"fetch", remoteUrl,
$"+refs/tags/{tag.Name}:refs/tags/{tag.Name}",
"--filter=tree:0",
});
}
catch (CommandException)
{
Log?.Verbose($"Shadow repo fetch failed during FetchTag(), trying with --refetch");
await CmdRunner.Run(Root,
"git", new[] {
"fetch", remoteUrl,
$"+refs/tags/{tag.Name}:refs/tags/{tag.Name}",
"--filter=tree:0",
"--refetch",
});
}
}

public void Dispose()
Expand Down

0 comments on commit fd973fa

Please sign in to comment.