public void GetSuperprojectCurrentCheckout() { // Create super and sub repo using (CommonTestUtils.GitModuleTestHelper moduleTestHelperSuper = new CommonTestUtils.GitModuleTestHelper("super repo"), moduleTestHelperSub = new CommonTestUtils.GitModuleTestHelper("sub repo")) { // Add and init the submodule moduleTestHelperSuper.AddSubmodule(moduleTestHelperSub, "sub repo"); var moduleSub = moduleTestHelperSuper.GetSubmodulesRecursive().ElementAt(0); // Commit in submodule moduleSub.GitExecutable.GetOutput(@"commit --allow-empty -am ""First commit"""); string commitRef = moduleSub.GitExecutable.GetOutput("show HEAD").Split('\n')[0].Split(' ')[1]; // Update ref in superproject moduleTestHelperSuper.Module.GitExecutable.GetOutput(@"add ""sub repo"""); moduleTestHelperSuper.Module.GitExecutable.GetOutput(@"commit -am ""Update submodule ref"""); // Assert ThreadHelper.JoinableTaskFactory.Run(async() => { (char code, ObjectId commitId) = await moduleSub.GetSuperprojectCurrentCheckoutAsync(); Assert.AreEqual(32, code); Assert.AreEqual(commitRef, commitId.ToString()); }); } }
/// <summary> /// Adds 'subModuleHelper' as a submodule of the current subModuleHelper. /// </summary> /// <param name="subModuleHelper">GitModuleTestHelper to add as a submodule of this.</param> /// <param name="path">Relative submodule path.</param> public void AddSubmodule(GitModuleTestHelper subModuleHelper, string path) { // Submodules require at least one commit subModuleHelper.Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Initial empty commit"""); Module.GitExecutable.GetOutput(GitCommandHelpers.AddSubmoduleCmd(subModuleHelper.Module.WorkingDir.ToPosixPath(), path, null, true), throwOnErrorOutput: false); Module.GitExecutable.GetOutput(@"commit -am ""Add submodule"""); }
/// <summary> /// Adds 'helper' as a submodule of the current helper. /// </summary> /// <param name="helper">GitModuleTestHelper to add as a submodule of this.</param> /// <param name="path">Relative submodule path.</param> /// <returns>Module of added submodule</returns> public VsrModule AddSubmodule(GitModuleTestHelper helper, string path) { // Submodules require at least one commit helper.Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Empty commit"""); Module.GitExecutable.GetOutput(GitCommandHelpers.AddSubmoduleCmd(helper.Module.WorkingDir.ToPosixPath(), path, null, true)); Module.GitExecutable.GetOutput(@"commit -am ""Add submodule"""); return(new VsrModule(Path.Combine(Module.WorkingDir, path).ToPosixPath())); }
public void GetSuperprojectCurrentCheckout() { // Create super and sub repo using (CommonTestUtils.GitModuleTestHelper moduleTestHelperSuper = new CommonTestUtils.GitModuleTestHelper("super repo"), moduleTestHelperSub = new CommonTestUtils.GitModuleTestHelper("sub repo")) { // Inital commit in super project moduleTestHelperSuper.Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Initial commit"""); // Submodules require at least one commit moduleTestHelperSub.Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Empty commit"""); // Add submodule moduleTestHelperSuper.Module.GitExecutable.GetOutput(GitCommandHelpers.AddSubmoduleCmd(moduleTestHelperSub.Module.WorkingDir.ToPosixPath(), "sub repo", null, true)); moduleTestHelperSuper.Module.GitExecutable.GetOutput(@"commit -am ""Add submodule"""); GitModule moduleSub = new GitModule(Path.Combine(moduleTestHelperSuper.Module.WorkingDir, "sub repo").ToPosixPath()); // Init submodule moduleTestHelperSuper.Module.GitExecutable.GetOutput(@"submodule update --init --recursive"); // Commit in submodule moduleSub.GitExecutable.GetOutput(@"commit --allow-empty -am ""First commit"""); string commitRef = moduleSub.GitExecutable.GetOutput("show HEAD").Split('\n')[0].Split(' ')[1]; // Update ref in superproject moduleTestHelperSuper.Module.GitExecutable.GetOutput(@"add ""sub repo"""); moduleTestHelperSuper.Module.GitExecutable.GetOutput(@"commit -am ""Update submodule ref"""); // Assert ThreadHelper.JoinableTaskFactory.Run(async() => { (char code, ObjectId commitId) = await moduleSub.GetSuperprojectCurrentCheckoutAsync(); Assert.AreEqual(32, code); Assert.AreEqual(commitRef, commitId.ToString()); }); } }
public ReferenceRepository() { _moduleTestHelper = new GitModuleTestHelper(); CreateCommit("A commit message", "A"); }