public IEnumerable<SyncAction> this[SyncActionState state] { get { // branch does not exist => result is empty if (!GitGroup.Repository.LocalBranchExists(BranchName)) { return Enumerable.Empty<SyncAction>(); } // load the root directory of the branch var gitDirectory = new GitDirectory(null, "root", GitGroup.Repository.GetLocalBranch(BranchName).Tip); // determine if the directory for action with the specified state exists and load actions from it var directoryPath = GetRelativeSyncActionDirectoryPath(state); if (!gitDirectory.DirectoryExists(directoryPath)) { return Enumerable.Empty<SyncAction>(); } var directory = gitDirectory.GetDirectory(directoryPath); return LoadSyncActions(directory); } }
public void Repository_with_subdirectories() { // arrange string commitId; using (var workingDirectory = new TemporaryWorkingDirectory(m_Repository.Directory.Location, "master")) { var directory = new Directory(Path.GetFileName(workingDirectory.Location)) { root => new Directory(root, s_Dir1) { dir1 => new EmptyFile(dir1, s_File1), dir1 => new EmptyFile(dir1, s_File2) }, root => new Directory(root, s_Dir2) { dir2 => new EmptyFile(dir2, s_File1) } }; System.IO.File.Delete(Path.Combine(workingDirectory.Location, RepositoryInfoFile.RepositoryInfoFileName)); m_DirectoryCreator.CreateDirectory(directory, Path.GetDirectoryName(workingDirectory.Location)); commitId = workingDirectory.Commit(); workingDirectory.Push(); } using (var repo = new Repository(m_Repository.Directory.Location)) { // act var commit = repo.Lookup<Commit>(commitId); var gitDirectory = new GitDirectory(null, m_Repository.Directory.Name, commit); // assert Assert.Equal(m_Repository.Directory.Name, gitDirectory.Name); Assert.Equal(2, gitDirectory.Directories.Count()); Assert.Empty(gitDirectory.Files); Assert.True(gitDirectory.DirectoryExists(s_Dir1)); Assert.True(gitDirectory.GetDirectory(s_Dir1).FileExists(s_File1)); Assert.True(gitDirectory.GetDirectory(s_Dir1).FileExists(s_File2)); Assert.True(gitDirectory.DirectoryExists(s_Dir2)); Assert.True(gitDirectory.GetDirectory(s_Dir2).FileExists(s_File1)); } }