Ejemplo n.º 1
0
        public async Task Submodule_status_changes_for_second_nested_module_with_first_nested_module_precommit()
        {
            var currentModule = _repo3Module;

            // Update commit in repo2, will check status
            _repo2Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            var result = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            result.AllSubmodules[0].Detailed.Should().NotBeNull();
            result.AllSubmodules[0].Detailed.IsDirty.Should().BeFalse();
            result.AllSubmodules[0].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.FastForward);
            result.AllSubmodules[1].Detailed.Should().BeNull();
            result.TopProject.Detailed.IsDirty.Should().BeTrue();

            // Make a change in repo3, still not changing
            _repo1.CreateFile(_repo3Module.WorkingDir, "test.txt", "test");
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(1);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules[0].Detailed.IsDirty.Should().BeTrue();
            result.AllSubmodules[0].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.FastForward);
            result.AllSubmodules[1].Detailed.IsDirty.Should().BeTrue();
            result.AllSubmodules[1].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.Unknown);
            result.TopProject.Detailed.IsDirty.Should().BeTrue();

            // Revert the change
            _repo2Module.GitExecutable.GetOutput(@"checkout HEAD^", throwOnErrorOutput: false);
            File.Delete(Path.Combine(_repo3Module.WorkingDir, "test.txt"));
            await CheckRevertedStatus(result);
        }
Ejemplo n.º 2
0
        public async Task Submodule_status_changes_for_top_module_with_top_module_changes()
        {
            var currentModule = _repo1Module;

            _repo1.CreateFile(_repo1Module.WorkingDir, "test.txt", "test");

            var result = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            // When top module is current, only structure is updated and no changes seen until explicit git-status
            result.AllSubmodules.All(i => i.Detailed is null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.Should().BeNull();

            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(1);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed is null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.IsDirty.Should().BeTrue();
            result.TopProject.Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.Unknown);

            // Revert the change
            File.Delete(Path.Combine(_repo1Module.WorkingDir, "test.txt"));
            await CheckRevertedStatus(result);
        }
Ejemplo n.º 3
0
        public async Task Submodule_status_changes_for_second_nested_module_with_prechanges_noupdate()
        {
            var currentModule = _repo3Module;

            // Update repos
            _repo1.CreateFile(_repo1Module.WorkingDir, "test.txt", "test");
            _repo1Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            _repo1.CreateFile(_repo2Module.WorkingDir, "test.txt", "test");
            _repo2Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            _repo1.CreateFile(_repo3Module.WorkingDir, "test.txt", "test");
            _repo3Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");

            // Update requires: AppSettings.ShowSubmoduleStatus && (AppSettings.ShowGitStatusInBrowseToolbar || (AppSettings.ShowGitStatusForArtificialCommits && AppSettings.RevisionGraphShowWorkingDirChanges))
            var result = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule, false);

            result.Should().NotBeNull();

            result.AllSubmodules.All(i => i.Detailed is null).Should().BeTrue();
            result.TopProject.Detailed.Should().BeNull();

            // Revert the change
            _repo1Module.GitExecutable.GetOutput(@"checkout HEAD^", throwOnErrorOutput: false);
            File.Delete(Path.Combine(_repo1Module.WorkingDir, "test.txt"));
            _repo2Module.GitExecutable.GetOutput(@"checkout HEAD^", throwOnErrorOutput: false);
            File.Delete(Path.Combine(_repo2Module.WorkingDir, "test.txt"));
            _repo3Module.GitExecutable.GetOutput(@"checkout HEAD^", throwOnErrorOutput: false);
            File.Delete(Path.Combine(_repo3Module.WorkingDir, "test.txt"));
            await CheckRevertedStatus(result);
        }
Ejemplo n.º 4
0
        public async Task Submodule_status_changes_for_second_nested_module_with_second_nested_module_changes()
        {
            var currentModule = _repo3Module;
            var result        = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            // No changes in repo
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed is null).Should().BeTrue();
            result.TopProject.Detailed.Should().BeNull();

            // Make a change in repo3
            _repo1.CreateFile(_repo3Module.WorkingDir, "test.txt", "test");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(1);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules[0].Detailed.IsDirty.Should().BeTrue();
            result.AllSubmodules[0].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.Unknown);
            result.AllSubmodules[1].Detailed.IsDirty.Should().BeTrue();
            result.AllSubmodules[1].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.Unknown);
            result.TopProject.Detailed.IsDirty.Should().BeTrue();

            // Revert the change
            File.Delete(Path.Combine(_repo3Module.WorkingDir, "test.txt"));
            await CheckRevertedStatus(result);
        }
Ejemplo n.º 5
0
        public async Task Submodule_status_changes_for_second_nested_module_with_first_nested_module_commit()
        {
            var currentModule = _repo3Module;
            var result        = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            // No changes in repo
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed is null).Should().BeTrue();
            result.TopProject.Detailed.Should().BeNull();

            // Update commit in repo2
            _repo2Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed is null).Should().BeTrue();
            result.TopProject.Detailed.Should().BeNull();

            // Revert the change
            _repo2Module.GitExecutable.GetOutput(@"checkout HEAD^", throwOnErrorOutput: false);
            await CheckRevertedStatus(result);
        }
        public async Task Submodule_status_changes_for_first_nested_module_with_second_nested_module_commit()
        {
            var currentModule = _repo2Module;
            var result        = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            // No changes in repo
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            result.OurSubmodules[0].Should().BeEquivalentTo(result.AllSubmodules[1]);
            result.TopProject.Detailed.Should().BeNull();

            // Update commit in repo3
            _repo3Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(1);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules[0].Detailed.IsDirty.Should().BeTrue();
            result.AllSubmodules[0].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.Unknown);
            result.AllSubmodules[1].Detailed.IsDirty.Should().BeFalse();
            result.AllSubmodules[1].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.FastForward);
            result.OurSubmodules[0].Should().BeEquivalentTo(result.AllSubmodules[1]);
            result.TopProject.Detailed.IsDirty.Should().BeTrue();

            // Revert the change
            _repo3Module.GitExecutable.GetOutput(@"checkout HEAD^");
            await CheckRevertedStatus(result);
        }
        public void RepoObjectTree_should_show_all_submodules()
        {
            RunFormTest(
                async form =>
            {
                // act
                await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, _repo1Module);

                // assert
                var submodulesNode = GetSubmoduleNode(form);

                submodulesNode.Nodes.Count.Should().Be(1);

                var repo1Node = submodulesNode.Nodes[0];
                repo1Node.Name.Should().StartWith("repo1");
                repo1Node.Nodes.Count.Should().Be(1);

                var repo2Node = repo1Node.Nodes[0];
                repo2Node.Name.Should().StartWith("repo2");
                repo2Node.Nodes.Count.Should().Be(1);

                var repo3Node = repo2Node.Nodes[0];
                repo3Node.Name.Should().StartWith("repo3");
                repo3Node.Nodes.Count.Should().Be(0);
            });
        }
        public async Task Submodule_status_changes_for_second_nested_module_with_first_nested_module_prechanges()
        {
            var currentModule = _repo3Module;

            // Update commit in repo2, will check status
            _repo2Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            var result = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            result.AllSubmodules[0].Detailed.Should().NotBeNull();
            result.AllSubmodules[0].Detailed.IsDirty.Should().BeFalse();
            result.AllSubmodules[0].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.FastForward);
            result.AllSubmodules[1].Detailed.Should().BeNull();
            result.TopProject.Detailed.IsDirty.Should().BeTrue();

            // Revert the change, top and first level status is not reverted
            _repo2Module.GitExecutable.GetOutput(@"checkout HEAD^");
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules[0].Detailed.IsDirty.Should().BeFalse();
            result.AllSubmodules[0].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.FastForward);
            result.AllSubmodules[1].Detailed.Should().BeNull();
            result.TopProject.Detailed.IsDirty.Should().BeTrue();
        }
        public async Task Submodule_status_changes_for_top_module()
        {
            var currentModule = _repo1Module;
            var result        = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            // No changes in repo
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.OurSubmodules.All(i => i.Detailed == null).Should().BeTrue();

            // Make a change in repo2
            _repo1.CreateFile(_repo2Module.WorkingDir, "test.txt", "test");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(1);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.OurSubmodules[0].Detailed.IsDirty.Should().BeTrue();
            result.OurSubmodules[1].Detailed.Should().BeNull();

            // Revert the change
            File.Delete(Path.Combine(_repo2Module.WorkingDir, "test.txt"));
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.OurSubmodules.All(i => i.Detailed == null).Should().BeTrue();
        }
Ejemplo n.º 10
0
            public async Task UpdateSubmoduleStructure_valid_result_for_second_nested_submodule()
            {
                var result = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, _repo3Module, true);

                result.TopProject.Path.Should().Be(_repo1Module.WorkingDir);
                result.SuperProject.Path.Should().Be(_repo2Module.WorkingDir);
                result.CurrentSubmoduleName.Should().Be("repo3");
                result.OurSubmodules.Select(info => info.Path).Should().BeEmpty();
                result.SuperSubmodules.Select(info => info.Path).Should().Contain(_repo2Module.WorkingDir, _repo3Module.WorkingDir);
                result.OurSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            }
Ejemplo n.º 11
0
        public async Task UpdateSubmoduleStructure_valid_result_for_top_module()
        {
            var result = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, _repo1Module);

            result.Should().NotBeNull();
            result.TopProject.Path.Should().Be(_repo1Module.WorkingDir);
            result.SuperProject.Should().Be(null);
            result.CurrentSubmoduleName.Should().Be(null);
            result.AllSubmodules.Select(info => info.Path).Should().Contain(_repo2Module.WorkingDir, _repo3Module.WorkingDir);
            result.AllSubmodules.All(i => i.Detailed is null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
        }
        public async Task Submodule_status_changes_for_top_module_with_no_forced_changes()
        {
            var currentModule = _repo1Module;
            var result        = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            // No changes in repo
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.Should().BeNull();

            // Make a change in repo1 without force update, should take 15s
            DateTime statusStart = DateTime.Now;

            _repo1.CreateFile(_repo1Module.WorkingDir, "test.txt", "test");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(1);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles, false);

            result.AllSubmodules[0].Detailed.Should().BeNull();
            result.AllSubmodules[1].Detailed.Should().BeNull();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.IsDirty.Should().BeTrue();
            result.TopProject.Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.Unknown);
            (DateTime.Now - statusStart).TotalSeconds.Should().BeGreaterOrEqualTo(14);

            // Revert the change
            File.Delete(Path.Combine(_repo1Module.WorkingDir, "test.txt"));
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.Should().BeNull();
        }
        public async Task Submodule_status_changes_for_top_module_with_first_nested_module_change_commit()
        {
            var currentModule = _repo1Module;
            var result        = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            // No changes in repo
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.Should().BeNull();

            // Make a change and update commit in repo2
            _repo1.CreateFile(_repo2Module.WorkingDir, "test.txt", "test");
            _repo2Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(1);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules[0].Detailed.IsDirty.Should().BeTrue();
            result.AllSubmodules[0].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.FastForward);
            result.AllSubmodules[1].Detailed.Should().BeNull();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.IsDirty.Should().BeTrue();
            result.TopProject.Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.Unknown);

            // Revert the change
            File.Delete(Path.Combine(_repo2Module.WorkingDir, "test.txt"));
            _repo2Module.GitExecutable.GetOutput(@"checkout HEAD^");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.Should().BeNull();
        }
        public async Task Submodule_status_changes_for_second_nested_module_with_first_nested_module_prechanges()
        {
            var currentModule = _repo3Module;

            // Update commit in repo2, will check status
            _repo2Module.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            var result = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            result.AllSubmodules[0].Detailed.Should().NotBeNull();
            result.AllSubmodules[0].Detailed.IsDirty.Should().BeFalse();
            result.AllSubmodules[0].Detailed.Status.Should().BeEquivalentTo(SubmoduleStatus.FastForward);
            result.AllSubmodules[1].Detailed.Should().BeNull();
            result.TopProject.Detailed.IsDirty.Should().BeTrue();

            // Revert the change
            _repo2Module.GitExecutable.Execute(@"checkout HEAD^", throwOnErrorExit: false);
            await CheckRevertedStatus(result);
        }
        public async Task Submodule_status_changes_for_top_module_top_module_commit()
        {
            var currentModule = _repo1Module;
            var result        = await SubmoduleTestHelpers.UpdateSubmoduleStructureAndWaitForResultAsync(_provider, currentModule);

            result.Should().NotBeNull();

            // No changes in repo
            var changedFiles = GetStatusChangedFiles(currentModule);

            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.Should().BeNull();

            // Update commit in topmodule
            currentModule.GitExecutable.GetOutput(@"commit --allow-empty -m ""Dummy commit""");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.Should().BeNull();

            // Revert the change
            _repo1Module.GitExecutable.GetOutput(@"checkout HEAD^");
            changedFiles = GetStatusChangedFiles(currentModule);
            changedFiles.Should().HaveCount(0);
            await SubmoduleTestHelpers.UpdateSubmoduleStatusAndWaitForResultAsync(_provider, currentModule, changedFiles);

            result.AllSubmodules.All(i => i.Detailed == null).Should().BeTrue();
            result.OurSubmodules.Should().BeEquivalentTo(result.AllSubmodules);
            result.TopProject.Detailed.Should().BeNull();
        }