private static void DoCreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName) { sourceDirectoryName = Path.GetFullPath(sourceDirectoryName); // We ensure the name ends with '\' or '/' if (!sourceDirectoryName.EndsWith(Path.AltDirectorySeparatorChar)) { sourceDirectoryName += Path.AltDirectorySeparatorChar; } destinationArchiveFileName = Path.GetFullPath(destinationArchiveFileName); var di = new DirectoryInfo(sourceDirectoryName); using (var archive = ZipFile.Open(destinationArchiveFileName, ZipArchiveMode.Create)) { var basePath = di.FullName; var ignoreFile = IgnoreFile.Parse(Path.Combine(sourceDirectoryName, ".gitignore"), includeParentDirectories: true); foreach (var gitFile in ignoreFile.ListDirectory(sourceDirectoryName)) { var localPath = gitFile.Path.Substring(sourceDirectoryName.Length); Log.Verbose($"Adding {localPath}"); var entry = archive.CreateEntryFromFile(gitFile.Path, localPath); } } }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SourceBaseDirectory != null ? SourceBaseDirectory.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProjectFile != null ? ProjectFile.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProjectFolder != null ? ProjectFolder.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (IgnoreFile != null ? IgnoreFile.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)SourceType; return(hashCode); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(_replaySorterConfiguration.IgnoreFilePath)) { try { _ignoreFile = _ignoreFileManager.Load(_replaySorterConfiguration.IgnoreFilePath); var ignoredFiles = new StringBuilder(); foreach (var file in _ignoreFile.IgnoredFiles.Select(iFile => iFile.Item1)) { ignoredFiles.AppendLine(file); } editIgnoreFileTextBox.Text = ignoredFiles.ToString(); } catch (Exception ex) { ErrorLogger.GetInstance()?.LogError($"Failed to load existing ignore file at location {_replaySorterConfiguration.IgnoreFilePath}", ex: ex); MessageBox.Show($"Failed to load existing ignore file at location {_replaySorterConfiguration.IgnoreFilePath}", "Invalid file", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);; } } }
public void TestReadIgnoreFile() { var testfilesLocation = Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..", "..", "..", "TestFiles", ".wtignore"); IgnoreFile.TryLoadIgnoreFile(testfilesLocation, out var ignoredExtensions, out var ignoredPaths); // This test must match the filesystem, and the .wtignore in TestFiles. Assert.That(ignoredExtensions.Count, Is.EqualTo(3)); Assert.That(ignoredExtensions, Has.Member(".wtignore")); Assert.That(ignoredExtensions, Has.Member(".diff")); Assert.That(ignoredExtensions, Has.Member(".wild")); Assert.That(ignoredPaths.Count, Is.EqualTo(7)); Assert.That(ignoredPaths, Has.Member("Thumb.db")); Assert.That(ignoredPaths, Has.Member("DirectoryToIgnore\\FileIgnoredImplicitly.txt")); Assert.That(ignoredPaths, Has.Member("WildcardIgnoredDirectory\\")); Assert.That(ignoredPaths, Has.Member("WildcardIgnoredDirectory\\FileIgnoredImplicitly.txt")); Assert.That(ignoredPaths, Has.Member("DirectoryNotIgnored\\WildcardIgnoredDirectory\\")); Assert.That(ignoredPaths, Has.Member("DirectoryNotIgnored\\WildcardIgnoredDirectory\\FileIgnoredImplicitly.txt")); Assert.That(ignoredPaths, Has.Member(".IgnoredAsFile")); }
internal void AcceptOrDenyNonRecursivePatterns(IgnoreFile ignoreFile, string path, bool expected) { Assert.Equal(expected, ignoreFile.Accepts(path)); }