示例#1
0
        public override bool Run()
        {
            if (CodeInfo is null || CodePath is null)
            {
                Status.WriteLine(Severity.Error,
                                 "Application error. Must choose the code repo against which to run this report.");
            }

            try
            {
                Contract.Requires(Directory.Exists(CodePath));
                Contract.Requires(Directory.Exists(Path.Combine(CodePath, ".git")));
            }
            catch
            {
                MessageBox.Show("Invalid code directory.");
                return(false);
            }

            LinkMap.Clear();

            var helper = new RepoHelper();

            try
            {
                using (var docRepo = helper.GetRepository(DocPath))
                    using (var codeRepo = helper.GetRepository(CodePath))
                    {
                        FindRelevantCodeLinks(docRepo, codeRepo);
                        BackfillCommitDates(LinkMap.DocFileIndex.Keys, docRepo, helper);
                        BackfillCommitDates(LinkMap.CodeFileIndex.Keys, codeRepo, helper);
                    }

                if (LinkMap.IsEmpty)
                {
                    Status.WriteLine(Severity.Warning, "No code links found in this repo.");
                    return(false);
                }
                else
                {
                    Status.WriteLine(Severity.Information, "Found links to " +
                                     $"{LinkMap.CodeFileIndex.Count} code files, linked to from " +
                                     $"{LinkMap.DocFileIndex.Count} doc files.");

                    SaveDialog.Title = "Choose where to save the code link report:";
                    var result = SaveDialog.TrySave((writer) => { WriteReport(writer); });
                    Status.WriteLine(result.Sev, result.Message);
                    if (result.Reason == DialogResult.OK)
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Status.WriteLine(Severity.Error, $"{ex.GetType().Name}: {ex.Message}");
            }
            return(false);
        }
示例#2
0
 public void Clear()
 {
     LinkMap.Clear();
 }