From 50bdbb499933cd6bc8dfc97119166ed1e5a59908 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 21 Sep 2024 04:19:30 -0500 Subject: [PATCH 1/7] ci TWEAK --- .github/workflows/ci-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml index 71ae6267..1023879a 100644 --- a/.github/workflows/ci-dev.yml +++ b/.github/workflows/ci-dev.yml @@ -13,10 +13,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup .NET + - name: Setup .NET 8 uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.102 + dotnet-version: 8.0.* - name: Install dependencies run: dotnet restore Synthesis.Bethesda.sln - name: Build From 3949d95cf7098a19fb417aa7f5dc95f65a542399 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 21 Sep 2024 05:06:04 -0500 Subject: [PATCH 2/7] Noggog.GitRepository update --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 5637f921..b38f9633 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -84,7 +84,7 @@ 2.65.1-nightly-20240911-092507 - 1.2 + 1.3 2.65.1-nightly-20240911-092507 From 39273ffb2ecd4463450097ad75e190cb11d44175 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 21 Sep 2024 05:28:04 -0500 Subject: [PATCH 3/7] Adjustment for GetRepository test function --- Directory.Packages.props | 2 +- Synthesis.Bethesda.UnitTests/RepoTestUtility.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index b38f9633..5637f921 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -84,7 +84,7 @@ 2.65.1-nightly-20240911-092507 - 1.3 + 1.2 2.65.1-nightly-20240911-092507 diff --git a/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs b/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs index fc1ea1be..25e7d65a 100644 --- a/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs +++ b/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs @@ -5,7 +5,6 @@ using Mutagen.Bethesda.Synthesis.Versioning; using Noggog; using Noggog.IO; -using Noggog.Utility; namespace Synthesis.Bethesda.UnitTests; @@ -57,12 +56,16 @@ public TempFolder GetRepository( } var remoteRef = localRepo.Network.Remotes.Add("origin", remote); - var master = localRepo.Branches[DefaultBranch]; + var master = localRepo.Branches.First(); localRepo.Branches.Update( master, b => b.Remote = remoteRef.Name, b => b.UpstreamBranch = master.CanonicalName); localRepo.Network.Push(master); + if (master.FriendlyName != DefaultBranch) + { + localRepo.Branches.Add("dev", localRepo.Head.Tip); + } return folder; } From 54f36e236d927f759201fce6e66a0638ef6ee2e6 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 21 Sep 2024 05:42:48 -0500 Subject: [PATCH 4/7] More git test tweaks --- .../RepoTestUtility.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs b/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs index 25e7d65a..16f5f187 100644 --- a/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs +++ b/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs @@ -37,7 +37,14 @@ public TempFolder GetRepository( LibGit2Sharp.Commands.Stage(localRepo, AFile); var sig = Signature; localRepo.Commit("Initial commit", sig, sig); - + var defaultBranch = localRepo.Branches.First(); + if (defaultBranch.FriendlyName != DefaultBranch) + { + var dev = localRepo.Branches.Add(DefaultBranch, localRepo.Head.Tip); + localRepo.Branches.Remove(defaultBranch); + defaultBranch = dev; + } + if (createPatcherFiles) { var files = new CreateSolutionFile(IFileSystemExt.DefaultFilesystem, new ExportStringToFile()).Create(Path.Combine(local, SlnPath)) @@ -56,16 +63,11 @@ public TempFolder GetRepository( } var remoteRef = localRepo.Network.Remotes.Add("origin", remote); - var master = localRepo.Branches.First(); localRepo.Branches.Update( - master, + defaultBranch, b => b.Remote = remoteRef.Name, - b => b.UpstreamBranch = master.CanonicalName); - localRepo.Network.Push(master); - if (master.FriendlyName != DefaultBranch) - { - localRepo.Branches.Add("dev", localRepo.Head.Tip); - } + b => b.UpstreamBranch = defaultBranch.CanonicalName); + localRepo.Network.Push(defaultBranch); return folder; } From d869386f81c278d6463ed87740e87008716f0137 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 21 Sep 2024 05:49:23 -0500 Subject: [PATCH 5/7] More git test tweaks --- Synthesis.Bethesda.UnitTests/RepoTestUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs b/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs index 16f5f187..3991d1d2 100644 --- a/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs +++ b/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs @@ -41,6 +41,7 @@ public TempFolder GetRepository( if (defaultBranch.FriendlyName != DefaultBranch) { var dev = localRepo.Branches.Add(DefaultBranch, localRepo.Head.Tip); + LibGit2Sharp.Commands.Checkout(localRepo, dev); localRepo.Branches.Remove(defaultBranch); defaultBranch = dev; } From 2756185ea9145a09da59df35ba1bda90a1418547 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 21 Sep 2024 05:54:07 -0500 Subject: [PATCH 6/7] More git test tweaks --- .../PrepareRunnerRepositoryIntegrationTests.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Synthesis.Bethesda.UnitTests/Execution/Patchers/Git/PrepareRunner/PrepareRunnerRepositoryIntegrationTests.cs b/Synthesis.Bethesda.UnitTests/Execution/Patchers/Git/PrepareRunner/PrepareRunnerRepositoryIntegrationTests.cs index e0f6c350..43b9e9bc 100644 --- a/Synthesis.Bethesda.UnitTests/Execution/Patchers/Git/PrepareRunner/PrepareRunnerRepositoryIntegrationTests.cs +++ b/Synthesis.Bethesda.UnitTests/Execution/Patchers/Git/PrepareRunner/PrepareRunnerRepositoryIntegrationTests.cs @@ -194,6 +194,7 @@ public async Task TagTarget() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); repo.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); @@ -228,6 +229,7 @@ public async Task TagTargetNoLocal() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); clone.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); @@ -255,6 +257,7 @@ public async Task TagTargetJumpback() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); repo.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); @@ -288,6 +291,7 @@ public async Task TagTargetNewContent() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); clone.Head.Tip.Sha.Should().BeEquivalentTo(commitSha); @@ -313,6 +317,7 @@ public async Task CommitTargetJumpback() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); repo.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); @@ -344,6 +349,7 @@ public async Task CommitTargetNoLocal() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); clone.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); @@ -376,6 +382,7 @@ public async Task CommitTargetNewContent() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); clone.Head.Tip.Sha.Should().BeEquivalentTo(commitSha); @@ -408,6 +415,7 @@ public async Task BranchTargetJumpback() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); repo.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); @@ -451,6 +459,7 @@ public async Task BranchTargetNoLocal() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); clone.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); @@ -485,6 +494,7 @@ public async Task BranchNewContent() versioning, TypicalNugetVersioning()), cancel: CancellationToken.None); + resp.RunnableState.Exception.Should().BeNull(); resp.IsHaltingError.Should().BeFalse(); resp.RunnableState.Succeeded.Should().BeTrue(); clone.Head.Tip.Sha.Should().BeEquivalentTo(commitSha); From 538fcbe471c81ab9bdc6d8505e4083f5aceaf667 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 21 Sep 2024 06:04:12 -0500 Subject: [PATCH 7/7] More git test tweaks --- ...PrepareRunnerRepositoryIntegrationTests.cs | 66 +++++++++++-------- .../RepoTestUtility.cs | 10 +-- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/Synthesis.Bethesda.UnitTests/Execution/Patchers/Git/PrepareRunner/PrepareRunnerRepositoryIntegrationTests.cs b/Synthesis.Bethesda.UnitTests/Execution/Patchers/Git/PrepareRunner/PrepareRunnerRepositoryIntegrationTests.cs index 43b9e9bc..594c8b4c 100644 --- a/Synthesis.Bethesda.UnitTests/Execution/Patchers/Git/PrepareRunner/PrepareRunnerRepositoryIntegrationTests.cs +++ b/Synthesis.Bethesda.UnitTests/Execution/Patchers/Git/PrepareRunner/PrepareRunnerRepositoryIntegrationTests.cs @@ -12,7 +12,6 @@ using Synthesis.Bethesda.Execution.Settings; using Synthesis.Bethesda.Execution.Versioning; using Synthesis.Bethesda.UnitTests.AutoData; -using Xunit; using ILogger = Serilog.ILogger; namespace Synthesis.Bethesda.UnitTests.Execution.Patchers.Git.PrepareRunner; @@ -65,10 +64,10 @@ public Commit AddACommit(string path) } [DebuggerStepThrough] - public GitPatcherVersioning TypicalPatcherVersioning() => + public GitPatcherVersioning TypicalPatcherVersioning(string defaultBranchName) => new( PatcherVersioningEnum.Branch, - DefaultBranch); + defaultBranchName); [DebuggerStepThrough] public NugetsVersioningTarget TypicalNugetVersioning() => @@ -95,11 +94,12 @@ public async Task CreatesRunnerBranch() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var resp = await Get(local).Checkout( new CheckoutInput( ProjPath, - TypicalPatcherVersioning(), + TypicalPatcherVersioning(defaultBranchName), TypicalNugetVersioning()), cancel: CancellationToken.None); using var repo = new Repository(local); @@ -111,11 +111,12 @@ public async Task NonExistentProjPath() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var resp = await Get(local).Checkout( new CheckoutInput( string.Empty, - TypicalPatcherVersioning(), + TypicalPatcherVersioning(defaultBranchName), TypicalNugetVersioning()), cancel: CancellationToken.None); resp.IsHaltingError.Should().BeTrue(); @@ -129,11 +130,12 @@ public async Task NonExistentSlnPath() using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), out var remote, out var local, + out var defaultBranchName, createPatcherFiles: false); var resp = await Get(local).Checkout( new CheckoutInput( ProjPath, - TypicalPatcherVersioning(), + TypicalPatcherVersioning(defaultBranchName), TypicalNugetVersioning()), cancel: CancellationToken.None); resp.IsHaltingError.Should().BeTrue(); @@ -146,7 +148,8 @@ public async Task UnknownSha() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var versioning = new GitPatcherVersioning(PatcherVersioningEnum.Commit, "46c207318c1531de7dc2f8e8c2a91aced183bc30"); var resp = await Get(local).Checkout( new CheckoutInput( @@ -164,7 +167,8 @@ public async Task MalformedSha() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var versioning = new GitPatcherVersioning(PatcherVersioningEnum.Commit, "derp"); var resp = await Get(local).Checkout( new CheckoutInput( @@ -182,7 +186,8 @@ public async Task TagTarget() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var tagStr = "1.3.4"; using var repo = new Repository(local); var tipSha = repo.Head.Tip.Sha; @@ -206,7 +211,8 @@ public async Task TagTargetNoLocal() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var tagStr = "1.3.4"; string tipSha; { @@ -241,7 +247,8 @@ public async Task TagTargetJumpback() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var tag = "1.3.4"; using var repo = new Repository(local); var tipSha = repo.Head.Tip.Sha; @@ -269,7 +276,8 @@ public async Task TagTargetNewContent() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var clonePath = Path.Combine(repoPath.Dir.Path, "Clone"); using var clone = new Repository(Repository.Clone(remote, clonePath)); @@ -303,7 +311,8 @@ public async Task CommitTargetJumpback() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); using var repo = new Repository(local); var tipSha = repo.Head.Tip.Sha; @@ -329,7 +338,8 @@ public async Task CommitTargetNoLocal() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); string tipSha; { using var repo = new Repository(local); @@ -361,7 +371,8 @@ public async Task CommitTargetNewContent() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var clonePath = Path.Combine(repoPath.Dir.Path, "Clone"); using var clone = new Repository(Repository.Clone(remote, clonePath)); @@ -394,7 +405,8 @@ public async Task BranchTargetJumpback() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); using var repo = new Repository(local); var tipSha = repo.Head.Tip.Sha; var jbName = "Jumpback"; @@ -421,7 +433,7 @@ public async Task BranchTargetJumpback() repo.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); repo.Head.FriendlyName.Should().BeEquivalentTo(CheckoutRunnerBranch.RunnerBranch); repo.Branches[jbName].Tip.Sha.Should().BeEquivalentTo(tipSha); - repo.Branches[DefaultBranch].Tip.Sha.Should().BeEquivalentTo(commit.Sha); + repo.Branches[defaultBranchName].Tip.Sha.Should().BeEquivalentTo(commit.Sha); } [Fact] @@ -429,7 +441,8 @@ public async Task BranchTargetNoLocal() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); var jbName = "Jumpback"; string tipSha; string commitSha; @@ -446,7 +459,7 @@ public async Task BranchTargetNoLocal() repo.Branches.Remove(jbName); commitSha = AddACommit(local).Sha; repo.Head.Tip.Sha.Should().NotBeEquivalentTo(tipSha); - repo.Network.Push(repo.Branches[DefaultBranch]); + repo.Network.Push(repo.Branches[defaultBranchName]); } var clonePath = Path.Combine(repoPath.Dir.Path, "Clone"); @@ -465,7 +478,7 @@ public async Task BranchTargetNoLocal() clone.Head.Tip.Sha.Should().BeEquivalentTo(tipSha); clone.Head.FriendlyName.Should().BeEquivalentTo(CheckoutRunnerBranch.RunnerBranch); clone.Branches[jbName].Should().BeNull(); - clone.Branches[DefaultBranch].Tip.Sha.Should().BeEquivalentTo(commitSha); + clone.Branches[defaultBranchName].Tip.Sha.Should().BeEquivalentTo(commitSha); } [Fact] @@ -473,7 +486,8 @@ public async Task BranchNewContent() { using var repoPath = GetRepository( nameof(PrepareRunnerRepositoryIntegrationTests), - out var remote, out var local); + out var remote, out var local, + out var defaultBranchName); string tipSha; string commitSha; @@ -484,10 +498,10 @@ public async Task BranchNewContent() tipSha = repo.Head.Tip.Sha; commitSha = AddACommit(local).Sha; repo.Head.Tip.Sha.Should().NotBeEquivalentTo(tipSha); - repo.Network.Push(repo.Branches[DefaultBranch]); + repo.Network.Push(repo.Branches[defaultBranchName]); } - var versioning = new GitPatcherVersioning(PatcherVersioningEnum.Branch, $"origin/{DefaultBranch}"); + var versioning = new GitPatcherVersioning(PatcherVersioningEnum.Branch, $"origin/{defaultBranchName}"); var resp = await Get(clonePath).Checkout( new CheckoutInput( ProjPath, @@ -499,7 +513,7 @@ public async Task BranchNewContent() resp.RunnableState.Succeeded.Should().BeTrue(); clone.Head.Tip.Sha.Should().BeEquivalentTo(commitSha); clone.Head.FriendlyName.Should().BeEquivalentTo(CheckoutRunnerBranch.RunnerBranch); - clone.Branches[DefaultBranch].Tip.Sha.Should().BeEquivalentTo(tipSha); + clone.Branches[defaultBranchName].Tip.Sha.Should().BeEquivalentTo(tipSha); } #endregion } \ No newline at end of file diff --git a/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs b/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs index 3991d1d2..a830067d 100644 --- a/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs +++ b/Synthesis.Bethesda.UnitTests/RepoTestUtility.cs @@ -10,7 +10,6 @@ namespace Synthesis.Bethesda.UnitTests; public class RepoTestUtility { - public string DefaultBranch => "dev"; public string AFile => "Somefile.txt"; public string SlnPath => "Solution.sln"; public string ProjPath => "MyProj/MyProj.csproj"; @@ -20,6 +19,7 @@ public TempFolder GetRepository( string folderName, out DirectoryPath remote, out DirectoryPath local, + out string defaultBranchName, bool createPatcherFiles = true, [CallerMemberName] string? testName = null) { @@ -38,13 +38,7 @@ public TempFolder GetRepository( var sig = Signature; localRepo.Commit("Initial commit", sig, sig); var defaultBranch = localRepo.Branches.First(); - if (defaultBranch.FriendlyName != DefaultBranch) - { - var dev = localRepo.Branches.Add(DefaultBranch, localRepo.Head.Tip); - LibGit2Sharp.Commands.Checkout(localRepo, dev); - localRepo.Branches.Remove(defaultBranch); - defaultBranch = dev; - } + defaultBranchName = defaultBranch.FriendlyName; if (createPatcherFiles) {