void CopyOriginalUnityFiles() { Log($"Copying files from {unityRepo.RepoPath} to {dnSpyVersionPath}"); unityRepo.ThrowIfTreeNotClean(); dnSpyRepo.ThrowIfTreeNotClean(); unityRepo.CheckOut(unityGitHash); dnSpyRepo.CheckOut(Constants.DnSpyUnityRepo_master_Branch); unityRepo.ThrowIfTreeNotClean(); dnSpyRepo.ThrowIfTreeNotClean(); FileUtils.CopyFilesFromTo(unityRepo.RepoPath, dnSpyVersionPath); foreach (var dir in Constants.unityFoldersToCopy) { var sourceDir = Path.Combine(unityRepo.RepoPath, dir); var destinationDir = Path.Combine(dnSpyVersionPath, dir); FileUtils.CopyDirectoryFromTo(sourceDir, destinationDir); } var gitignore = Path.Combine(dnSpyVersionPath, "mono", "cil", ".gitignore"); if (!TextFilePatcher.RemoveLines(gitignore, line => line.Text == "/opcode.def")) { throw new ProgramException("Couldn't remove /opcode.def from .gitignore"); } Log($"Committing copied files"); dnSpyRepo.CommitAllFiles($"Add Unity files ({Path.GetFileName(dnSpyVersionPath)}), commit hash {unityGitHash}"); }
public static bool RemoveLines(string filename, Func <TextLine, bool> shouldRemove) { if (shouldRemove == null) { throw new ArgumentNullException(nameof(shouldRemove)); } var patcher = new TextFilePatcher(filename); bool removedLines = patcher.RemoveLines(shouldRemove); if (removedLines) { patcher.Write(); } return(removedLines); }