From 81ffa61ea45388ad17f25e8d3fc36478b9f039eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Ferr=C3=A9?= Date: Wed, 20 Oct 2021 10:40:28 +0200 Subject: [PATCH] Fix DeleteSourceBranch option in mocks --- NGitLab.Mock/Config/GitLabHelpers.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/NGitLab.Mock/Config/GitLabHelpers.cs b/NGitLab.Mock/Config/GitLabHelpers.cs index f0610134..a1ed4d0d 100644 --- a/NGitLab.Mock/Config/GitLabHelpers.cs +++ b/NGitLab.Mock/Config/GitLabHelpers.cs @@ -940,8 +940,7 @@ private static void CreateCommit(GitLabServer server, Project prj, GitLabCommit { var username = commit.User ?? commit.Parent.Parent.DefaultUser ?? throw new InvalidOperationException("Default user is required when author not set"); var user = server.Users.First(x => string.Equals(x.UserName, username, StringComparison.Ordinal)); - var targetBranch = commit.TargetBranch; - if (string.IsNullOrEmpty(targetBranch)) + if (string.IsNullOrEmpty(commit.TargetBranch)) { var branchExists = string.IsNullOrEmpty(commit.SourceBranch) || prj.Repository.GetAllBranches().Any(x => string.Equals(x.FriendlyName, commit.SourceBranch, StringComparison.Ordinal)); if (!branchExists) @@ -954,9 +953,9 @@ private static void CreateCommit(GitLabServer server, Project prj, GitLabCommit } else { - prj.Repository.Merge(user, commit.SourceBranch, targetBranch); + prj.Repository.Merge(user, commit.SourceBranch, commit.TargetBranch); if (commit.DeleteSourceBranch) - prj.Repository.RemoveBranch(targetBranch); + prj.Repository.RemoveBranch(commit.SourceBranch); } foreach (var tag in commit.Tags)