public void CreateObjectWhenProjectRootIsSameAsGitRootAndFileInGitRoot() { var repositoryPath = "/Source".ToNPath(); var unityProjectPath = repositoryPath; SubstituteFactory.CreateProcessEnvironment(repositoryPath); var environment = SubstituteFactory.CreateEnvironment(new CreateEnvironmentOptions { RepositoryPath = repositoryPath, UnityProjectPath = unityProjectPath }); NPath.FileSystem = SubstituteFactory.CreateFileSystem(new CreateFileSystemOptions { CurrentDirectory = repositoryPath }); const string inputPath = "Something.sln"; const GitFileStatus inputStatus = GitFileStatus.Added; var expectedFullPath = repositoryPath.Combine(inputPath); const string expectedProjectPath = inputPath; var expected = new GitStatusEntry(inputPath, expectedFullPath, expectedProjectPath, GitFileStatus.None, inputStatus); var gitStatusEntryFactory = new GitObjectFactory(environment); var result = gitStatusEntryFactory.CreateGitStatusEntry(inputPath, GitFileStatus.None, inputStatus); result.Should().Be(expected); }
public void ShouldBeEqual() { var gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, "SomeOriginalPath"); gitStatusEntry.Should().Be(gitStatusEntry); }
internal RepositoryStatus(Repository repo, StatusOptions options) { statusEntries = new List <StatusEntry>(); using (GitStatusOptions coreOptions = CreateStatusOptions(options ?? new StatusOptions())) using (StatusListSafeHandle list = Proxy.git_status_list_new(repo.Handle, coreOptions)) { int count = Proxy.git_status_list_entrycount(list); for (int i = 0; i < count; i++) { StatusEntrySafeHandle e = Proxy.git_status_byindex(list, i); GitStatusEntry entry = e.MarshalAsGitStatusEntry(); GitDiffDelta deltaHeadToIndex = null; GitDiffDelta deltaIndexToWorkDir = null; if (entry.HeadToIndexPtr != IntPtr.Zero) { deltaHeadToIndex = entry.HeadToIndexPtr.MarshalAs <GitDiffDelta>(); } if (entry.IndexToWorkDirPtr != IntPtr.Zero) { deltaIndexToWorkDir = entry.IndexToWorkDirPtr.MarshalAs <GitDiffDelta>(); } AddStatusEntryForDelta(entry.Status, deltaHeadToIndex, deltaIndexToWorkDir); } isDirty = statusEntries.Any(entry => entry.State != FileStatus.Ignored); } }
public void ShouldBeEqualIfOriginalpathIsNull() { var gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.None, GitFileStatus.Added); gitStatusEntry.Should().Be(gitStatusEntry); }
public void UnmergedDetection() { var gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, GitFileStatus.Added, "SomeOriginalPath"); gitStatusEntry.Unmerged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Deleted, GitFileStatus.Deleted, "SomeOriginalPath"); gitStatusEntry.Unmerged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Unmerged, GitFileStatus.Unmerged, "SomeOriginalPath"); gitStatusEntry.Unmerged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, GitFileStatus.Unmerged, "SomeOriginalPath"); gitStatusEntry.Unmerged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Unmerged, GitFileStatus.Added, "SomeOriginalPath"); gitStatusEntry.Unmerged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Deleted, GitFileStatus.Unmerged, "SomeOriginalPath"); gitStatusEntry.Unmerged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Unmerged, GitFileStatus.Deleted, "SomeOriginalPath"); gitStatusEntry.Unmerged.Should().BeTrue(); }
public void StagedIsFalse() { var gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.None, GitFileStatus.Added, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeFalse(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.None, GitFileStatus.Modified, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeFalse(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.None, GitFileStatus.Deleted, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeFalse(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.None, GitFileStatus.Copied, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeFalse(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.None, GitFileStatus.Renamed, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeFalse(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Untracked, GitFileStatus.Untracked, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeFalse(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Ignored, GitFileStatus.Ignored, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeFalse(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Unmerged, GitFileStatus.Added, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeFalse(); }
public static void AssertEqual(this GitStatusEntry gitStatusEntry, GitStatusEntry other) { gitStatusEntry.Path.Should().Be(other.Path); gitStatusEntry.FullPath.Should().Be(other.FullPath); gitStatusEntry.OriginalPath.Should().Be(other.OriginalPath); gitStatusEntry.ProjectPath.Should().Be(other.ProjectPath); gitStatusEntry.Status.Should().Be(other.Status); gitStatusEntry.Staged.Should().Be(other.Staged); }
public void ShouldBeEqualIfBothAreStaged() { var gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, "SomeOriginalPath", true); var gitStatusEntry2 = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, "SomeOriginalPath", true); gitStatusEntry.Should().Be(gitStatusEntry2); }
public void ShouldNotBeEqualIfOneIsStaged() { var gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, "SomeOriginalPath", staged: true); var gitStatusEntry2 = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, "SomeOriginalPath"); gitStatusEntry.Should().NotBe(gitStatusEntry2); }
public void ShouldNotBeEqualIfPathIsDifferent() { var gitStatusEntry1 = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, "SomeOriginalPath"); var gitStatusEntry2 = new GitStatusEntry("SomePath2", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, "SomeOriginalPath"); gitStatusEntry1.Should().NotBe(gitStatusEntry2); }
private StatusEntryFlags CalculateFlags(GitStatusEntry entry) { StatusEntryFlags flags = 0; if (lfsHelper.IsLfsPath(entry.LocalPath)) { flags |= StatusEntryFlags.IsLfs; } if (gitManager.IsSubModule(entry.LocalPath)) { flags |= StatusEntryFlags.IsSubModule; } return(flags); }
internal void Add(GitStatusEntry entry, IComparer <StatusListEntry> sorter) { StatusListEntry statusEntry; if (UniGitPathHelper.IsMetaPath(entry.LocalPath)) { string mainAssetPath = GitManager.AssetPathFromMeta(entry.LocalPath); if (!gitSettings.ShowEmptyFolders && gitManager.IsEmptyFolder(mainAssetPath)) { return; } int index = entries.FindIndex(e => e.LocalPath == mainAssetPath); if (index >= 0) { StatusListEntry ent = entries[index]; ent.MetaChange |= MetaChangeEnum.Meta; ent.State |= entry.Status; entries[index] = ent; return; } statusEntry = new StatusListEntry(mainAssetPath, entry.Status, MetaChangeEnum.Meta, CalculateFlags(entry)); } else { int index = entries.FindIndex(e => e.LocalPath == entry.LocalPath); if (index >= 0) { StatusListEntry ent = entries[index]; ent.State |= entry.Status; entries[index] = ent; return; } statusEntry = new StatusListEntry(entry.LocalPath, entry.Status, MetaChangeEnum.Object, CalculateFlags(entry)); } if (sorter != null) { AddSorted(statusEntry, sorter); } else { entries.Add(statusEntry); } }
public void StagedIsTrue() { var gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Added, GitFileStatus.None, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Modified, GitFileStatus.None, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Deleted, GitFileStatus.None, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Copied, GitFileStatus.None, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeTrue(); gitStatusEntry = new GitStatusEntry("SomePath", "SomeFullPath", "SomeProjectPath", GitFileStatus.Renamed, GitFileStatus.None, "SomeOriginalPath"); gitStatusEntry.Staged.Should().BeTrue(); }
public static void AssertNotEqual(this GitStatusEntry gitStatusEntry, GitStatusEntry other) { Action action = () => gitStatusEntry.AssertEqual(other); action.ShouldThrow <AssertionException>(); }