public TreeRenderer( ILogger <TreeRenderer> log, IGraphVizWriter gvWriter, IStyleProvider style, IGraphTooltipHelper tooltipHelper, IRemoteWebUrlProviderFactory remoteWebUrlProviderFactory) { _log = log; _gvWriter = gvWriter; _style = style; _tooltipHelper = tooltipHelper; _remoteWebUrlProviderFactory = remoteWebUrlProviderFactory; }
protected override void RunInternal() { // Get the immutable repository information. IRepositoryData repositoryData = _loader.LoadFrom(_repositoryDir.FullName); // Pick the remote to work on. IRemote remoteToUse = _remoteHelper.PickRemote(repositoryData, Options.RemoteToUse); // Create the tree. IBranchingStrategy strategy = _strategyProvider.GetStrategy(Options.LesserBranchesRegex); IBranch[] allBranches = repositoryData.Branches.GetFor(remoteToUse).ToArray(); IBranchesKnowledge branchesKnowledge = strategy.CreateKnowledge(allBranches); // Options for building the tree. ITagPickingOptions tagPickingOptions = TagPickingOptions.Set( Options.TagPickingMode, Options.TagCount, Options.IncludeOrphanedTags); IBranchPickingOptions branchPickingOptions = BranchPickingOptions.Set( Options.IncludeBranchesRegices, Options.ExcludeBranchesRegices); ITree tree = _treeBuilder.Build( repositoryData, remoteToUse, branchesKnowledge, branchPickingOptions, tagPickingOptions); SimplifyTree(tree); string tempPath = _fileSystem.Path.GetTempFileName(); tempPath = _fileSystem.Path.ChangeExtension(tempPath, "gv"); // Rendering options. TreeRenderingOptions renderingOptions = TreeRenderingOptions.Default; renderingOptions.ForceTreatAsGitHub = Options.ForceTreatAsGitHub; // ReSharper disable once AssignNullToNotNullAttribute using (IFileStream fileStream = _fileSystem.File.OpenWrite(tempPath)) { using (IStreamWriter textWriter = _textWriterFactory.CreateStreamWriter(fileStream)) { IGraphVizWriter graphVizWriter = _graphVizFactory.CreateGraphVizWriter(textWriter); ITreeRenderer treeRenderer = _treeRendererFactory.CreateRenderer(graphVizWriter); treeRenderer.Render(tree, remoteToUse, branchesKnowledge, renderingOptions); } } string targetPath = PrepareTargetPath(); string graphVizCommand = _appPathProvider.GetProperAppPath(ExternalApp.GraphViz); string graphVizArgs = $@"""{tempPath}"" -T{_outputFormat} -o""{targetPath}"""; Log.Debug($"Starting GraphViz with arguments: [{graphVizArgs}]."); int code = _processRunner.Execute(graphVizCommand, graphVizArgs); if (code != 0) { Log.Fatal("GraphViz execution failed."); } else { Log.Info("GraphViz execution succeeded."); Log.Info($"Saved to {targetPath}."); } }
public static void Node(this IGraphVizWriter writer, ITreeish n, IAttrSet attrSet = null) { writer.Node(n.Treeish, attrSet); }
public static void Edge(this IGraphVizWriter writer, ITreeish a, ITreeish b, IAttrSet attrSet = null) { writer.Edge(a.Treeish, b.Treeish, attrSet); }
public ITreeRenderer CreateRenderer(IGraphVizWriter textWriter) { return(_rendererMaker(textWriter)); }