static void Process(string path, SearchOptions options, SearchRange range, ActionType action, IEnumerable <ParsedCommit> commitsToIgnore) { IEnumerable <CommitInfo> commits = CommitFinder.Parse(path, range); Explain.Print($"Found {commits.Count ()} commits."); switch (action) { case ActionType.ListConsideredCommits: PrintCommits(commits); return; case ActionType.ListBugs: var parsedCommits = CommitParser.Parse(commits, options).ToList(); var bugCollection = BugCollector.ClassifyCommits(parsedCommits, options, commitsToIgnore); PrintBugs(bugCollection, options); if (options.ValidateBugStatus) { BugValidator.Validate(bugCollection, options); } return; default: throw new InvalidOperationException($"Internal Error - Unknown action requested {action}"); } }
public void Run(ActionType action) { // This can mutage Range so must be done first. var commitsToIgnore = ProcessOldestBranch(); Process(Path, Options, Range, action, commitsToIgnore); if (Options.Submodules) { string oldest = Range.Oldest.ValueOr(""); var initialSubmoduleStatus = CommitFinder.FindSubmodulesStatus(Path, oldest); string newest = Range.Newest.ValueOr("HEAD"); var finalSubmoduleStatus = CommitFinder.FindSubmodulesStatus(Path, newest); Explain.Print($"Processing {initialSubmoduleStatus.Count} submodules for change as well"); Explain.Indent(); foreach (var submodule in initialSubmoduleStatus.Keys) { string initialHash = initialSubmoduleStatus[submodule]; string finalHash = finalSubmoduleStatus[submodule]; if (initialHash == finalHash) { Explain.Print($"Submodule {submodule} had zero changes ({finalHash})."); continue; } Console.WriteLine($"\nSubmodule: {submodule}"); Explain.Print($"Processing {submodule} submodule from {initialHash} to {finalHash}."); SearchRange submoduleRange = new SearchRange() { Oldest = initialHash.Some(), Newest = finalHash.Some() }; Explain.Indent(); Process(System.IO.Path.Combine(Path, submodule), Options, submoduleRange, action, Enumerable.Empty <ParsedCommit> ()); Explain.Deindent(); } Explain.Deindent(); } }
IEnumerable <ParsedCommit> ProcessOldestBranch() { if (Range.OldestBranch.HasValue) { var branchName = Range.OldestBranch.ValueOrFailure(); if (branchName.StartsWith("origin/", StringComparison.InvariantCulture)) { branchName = branchName.Remove(0, 7); } var commitInfo = CommitFinder.FindCommitsOnBranchToIgnore(Path, branchName, Options); IEnumerable <ParsedCommit> commitsToIgnore = CommitParser.Parse(commitInfo.Item1, Options); Explain.Print($"Found {commitsToIgnore.Count ()} bugs on {branchName} after branch to ignore."); Range.Oldest = commitInfo.Item2.Some(); Range.IncludeOldest = false; return(commitsToIgnore); } return(Enumerable.Empty <ParsedCommit> ()); }
public static void Main(string[] args) { string path = null; SearchOptions options = new SearchOptions(); SearchRange range = new SearchRange(); ActionType requestedAction = ActionType.ListBugs; OptionSet os = new OptionSet() { { "h|?|help", "Displays the help", v => requestedAction = ActionType.Help }, { "l|list-commits", "List commits that would be considered", v => requestedAction = ActionType.ListConsideredCommits }, { "b|list-bugs", "List bugs discovered instead of formatting release notes", v => requestedAction = ActionType.ListBugs }, { "oldest=", "Starting hash to consider", s => range.Oldest = s.Some() }, { "newest=", "Ending hash to consider", e => range.Newest = e.Some() }, { "oldest-branch=", "Starting branch to consider. Finds the last commit in master before branch, and ignore all bugs fixed in master that are also fixed in this branch.", s => range.OldestBranch = s.Some() }, { "exclude-oldest", "Exclude oldest item from range considered (included by default)", v => range.IncludeOldest = false }, { "explain", "Explain why each commit is considered a bug", v => Explain.Enabled = true }, { "bugzilla=", "What level should bugzilla queries be made at (Public, Private, Disable)", v => { switch (v.ToLower(CultureInfo.InvariantCulture)) { case "public": options.Bugzilla = BugzillaLevel.Public; break; case "private": options.Bugzilla = BugzillaLevel.Private; break; case "disable": options.Bugzilla = BugzillaLevel.Disable; break; default: Die($"Unknown value for --bugzilla {v}"); break; } } }, { "additional-bug-info", "Print additional information on each bug for list-bugs", v => options.AdditionalBugInfo = true }, { "split-enhancement=", "Split out enhancement bugs from others in listing (defaults to true)", (bool v) => options.SplitEnhancementBugs = v }, { "validate-bug-status", "Validate bugzilla status for referenced bugs and report discrepancies (Not closed, not matching milestone)", v => options.ValidateBugStatus = true }, { "expected-target-milestone=", "Target Milestone to expect when validate-bug-status (instead of using the most common).", v => options.ExpectedTargetMilestone = v }, { "submodules", "Query submodules as well", v => options.Submodules = true }, new ResponseFileSource(), }; try { IList <string> unprocessed = os.Parse(args); if (requestedAction == ActionType.Help || unprocessed.Count != 1) { ShowHelp(os); return; } path = unprocessed[0]; } catch (Exception e) { Console.Error.WriteLine("Could not parse the command line arguments: {0}", e.Message); } if (options.ValidateBugStatus && options.Bugzilla == BugzillaLevel.Disable) { Die("Unable to Validate Bug Status with Bugzilla support disabled."); } if (range.Oldest.HasValue && range.Newest.HasValue) { if (!CommitFinder.ValidateGitHashes(path, range.Oldest.ValueOrFailure(), range.Newest.ValueOrFailure())) { Environment.Exit(-1); } } var request = new clio(path, range, options); request.Run(requestedAction); }