Skip to content

Commit

Permalink
Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
jairbubbles committed Sep 22, 2023
1 parent 9256cb4 commit 737ecb2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
22 changes: 22 additions & 0 deletions NGitLab.Mock.Tests/ProjectsMockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ public void Test_project_with_submodules()
Assert.IsTrue(System.IO.File.Exists(tempDir.GetFullPath("ModuleB/B.txt")));
}

[Test]
public void Test_project_with_nested_submodules()
{
using var tempDir = TemporaryDirectory.Create();
using var server = new GitLabConfig()
.WithUser("Test", isDefault: true)
.WithProject("ModuleA", configure: x => x.WithCommit(configure: c => c.WithFile("A.txt")))
.WithProject("ModuleB", configure: x => x.WithCommit(configure: c
=> c.WithFile("B.txt")
.WithSubModule("ModuleA")))
.WithProject("Test", clonePath: tempDir.FullPath, configure: x =>
x.WithCommit(configure: c
=> c.WithSubModule("ModuleB")))
.BuildServer();

Assert.IsTrue(Directory.Exists(tempDir.GetFullPath(".git")));
Assert.IsTrue(System.IO.File.Exists(tempDir.GetFullPath("ModuleB/.git")));
Assert.IsTrue(System.IO.File.Exists(tempDir.GetFullPath("ModuleB/B.txt")));
Assert.IsTrue(System.IO.File.Exists(tempDir.GetFullPath("ModuleB/ModuleA/.git")));
Assert.IsTrue(System.IO.File.Exists(tempDir.GetFullPath("ModuleB/ModuleA/A.txt")));
}

[Test]
public void Test_projects_created_url_ends_with_namespace_and_name()
{
Expand Down
7 changes: 6 additions & 1 deletion NGitLab.Mock/Config/GitLabHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,12 +1278,17 @@ private static IEnumerable<string> CreateSubModules(GitLabServer server, Project
using var process = Process.Start(
new ProcessStartInfo("git", $"-c protocol.file.allow=always submodule add {subModuleProject.SshUrl} {subModuleProject.Name}")
{
RedirectStandardError = true,
UseShellExecute = false,
WorkingDirectory = prj.Repository.FullPath,
});

process.WaitForExit();
if (process.ExitCode != 0)
throw new GitLabException("Cannot add submodule");
{
var error = process.StandardError.ReadToEnd();
throw new GitLabException($"Cannot add submodule: {error}");
}

submodules.Add(subModuleProject.Name);
}
Expand Down

0 comments on commit 737ecb2

Please sign in to comment.