Skip to content

Commit

Permalink
Merge pull request #1707 from tgstation/LibShitFix [TGSDeploy]
Browse files Browse the repository at this point in the history
v5.17.2: Fix tag fetching
  • Loading branch information
Cyberboss authored Nov 12, 2023
2 parents 7cada26 + a252c5f commit d9e80ac
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Integration tests will ensure they match across the board -->
<Import Project="ControlPanelVersion.props" />
<PropertyGroup>
<TgsCoreVersion>5.17.1</TgsCoreVersion>
<TgsCoreVersion>5.17.2</TgsCoreVersion>
<TgsConfigVersion>4.7.1</TgsConfigVersion>
<TgsApiVersion>9.13.0</TgsApiVersion>
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
Expand All @@ -17,7 +17,7 @@
<TgsNugetNetFramework>netstandard2.0</TgsNugetNetFramework>
<TgsNetMajorVersion>6</TgsNetMajorVersion>
<!-- Update this frequently with dotnet runtime patches. MAJOR MUST MATCH ABOVE! -->
<TgsDotnetRedistUrl>https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/6.0.23/dotnet-hosting-6.0.23-win.exe</TgsDotnetRedistUrl>
<TgsDotnetRedistUrl>https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/6.0.24/dotnet-hosting-6.0.24-win.exe</TgsDotnetRedistUrl>
<TgsMariaDBRedistVersion>10.11.5</TgsMariaDBRedistVersion>
<!-- The two versions must match above, this is referenced by XML readers in scripts so we can't use an MSBuild property reference -->
<TgsMariaDBRedistUrl>https://ftp.osuosl.org/pub/mariadb//mariadb-10.11.5/winx64-packages/mariadb-10.11.5-winx64.msi</TgsMariaDBRedistUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ await Task.Factory.StartNew(
OnTransferProgress = TransferProgressHandler(progressReporter.CreateSection("Fetch Origin", 1.0), cancellationToken),
OnUpdateTips = (a, b, c) => !cancellationToken.IsCancellationRequested,
CredentialsProvider = credentialsProvider.GenerateCredentialsHandler(username, password),
TagFetchMode = TagFetchMode.All,
},
"Fetch origin commits");
}
Expand Down
80 changes: 78 additions & 2 deletions tests/Tgstation.Server.Tests/TestRepository.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using LibGit2Sharp;

using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand All @@ -28,15 +31,15 @@ public async Task TestRepoParentLookup()
{
LibGit2Sharp.Repository.Clone("https://github.com/Cyberboss/test", tempPath);
var libGit2Repo = new LibGit2Sharp.Repository(tempPath);
using var repo = new Repository(
using var repo = new Host.Components.Repository.Repository(
libGit2Repo,
new LibGit2Commands(),
Mock.Of<IIOManager>(),
Mock.Of<IEventConsumer>(),
Mock.Of<ICredentialsProvider>(),
Mock.Of<IPostWriteHandler>(),
Mock.Of<IGitRemoteFeaturesFactory>(),
Mock.Of<ILogger<Repository>>(),
Mock.Of<ILogger<Host.Components.Repository.Repository>>(),
new GeneralConfiguration(),
() => { });

Expand All @@ -56,5 +59,78 @@ public async Task TestRepoParentLookup()
CancellationToken.None);
}
}

[TestMethod]
public async Task TestFetchingAdditionalCommits()
{
var tempPath = Path.Combine(Path.GetTempPath(), "TGS-Repository-Integration-Test", Guid.NewGuid().ToString());
var repoFac =
new LibGit2RepositoryFactory(
Mock.Of<ILogger<LibGit2RepositoryFactory>>());
var commands = new LibGit2Commands();
using var manager = new RepositoryManager(
repoFac,
commands,
new ResolvingIOManager(
new DefaultIOManager(),
tempPath),
Mock.Of<IEventConsumer>(),
new WindowsPostWriteHandler(),
Mock.Of<IGitRemoteFeaturesFactory>(),
Mock.Of<ILogger<Host.Components.Repository.Repository>>(),
Mock.Of<ILogger<RepositoryManager>>(),
new GeneralConfiguration());
try
{
using (await manager.CloneRepository(
new Uri("https://github.com/Cyberboss/common_core"),
null,
null,
null,
new JobProgressReporter(Mock.Of<ILogger<JobProgressReporter>>(), null, (_, _) => { }),
true,
default))
{
}

using (var repo = await repoFac.CreateFromPath(tempPath, default))
{
repo.Network.Remotes.Update("origin", updater =>
{
updater.Url = "https://github.com/tgstation/common_core";
});

var targetCommit = repo.Lookup<Commit>("5b0d0a38057a2c8306a852ccbd6cd6f4ae766a33");
Assert.IsNull(targetCommit);
}

using (var repo2 = await manager.LoadRepository(default))
{
await repo2.FetchOrigin(
new JobProgressReporter(Mock.Of<ILogger<JobProgressReporter>>(), null, (_, _) => { }),
null,
null,
false,
default);
}

using var repo3 = await repoFac.CreateFromPath(tempPath, default);
var remote = repo3.Network.Remotes.First();
commands.Fetch(repo3, remote.FetchRefSpecs.Select(x => x.Specification), remote, new FetchOptions
{
TagFetchMode = TagFetchMode.All,
Prune = true,
}, "test");

var targetCommit2 = repo3.Lookup<Commit>("5b0d0a38057a2c8306a852ccbd6cd6f4ae766a33");
Assert.IsNotNull(targetCommit2);
}
finally
{
await new DefaultIOManager().DeleteDirectory(
Path.GetDirectoryName(tempPath),
CancellationToken.None);
}
}
}
}

0 comments on commit d9e80ac

Please sign in to comment.