From 65072c4da7ed9250a9165a946336af9f39a5c253 Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Thu, 10 Jul 2008 13:20:20 +0200 Subject: [PATCH] gitstats: Made use of the new config parser in bug.py With the new config parser it is now possible to just run 'stats.py bug -t HEAD' and get a report on that commit. --- src/git_stats/bug.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/git_stats/bug.py b/src/git_stats/bug.py index 51a049c..89f669d 100644 --- a/src/git_stats/bug.py +++ b/src/git_stats/bug.py @@ -6,6 +6,9 @@ import sys from optparse import OptionParser, OptionValueError from git import Repo +from git_stats import branch +from git_stats import commit +from git_stats import config from git_stats import parse def aggregateType(debug): @@ -18,7 +21,7 @@ def aggregateType(debug): return result -def determineType(commit, +def determineType(target, debug=False, branchFilter=None, msgFilter=None, @@ -33,10 +36,10 @@ def determineType(commit, diffFilter: Type=fix if the commit diff matches this filter. """ - branches = branch.belongsTo(commit) - reverts = commit.findRevert(commit) - msg_matches = msgFilter and commitmsgMatches(commit, msgFilter) - diff_matches = diffFilter and commitdiffMatches(commit, diffFilter) + branches = branch.belongsTo(target) + reverts = commit.findReverts(target) + msg_matches = msgFilter and commit.commitmsgMatches(target, msgFilter) + diff_matches = diffFilter and commit.commitdiffMatches(target, diffFilter) result = [] @@ -47,10 +50,10 @@ def determineType(commit, result.append("Reverts a previous commit!") if msg_matches: - result.append("Message matches!") + result.append("Message matches: '" + msgFilter + "'.") if diff_matches: - result.append("Diff matches!") + result.append("Diff matches: '" + diffFilter + "'.") return result @@ -108,16 +111,18 @@ def dispatch(*args): (options, args) = parser.parse_args(list(args)) - _checkOptions(parser, options) + _checkOptions(parser, options) if options.aggregate: result = aggregateType(options.debug) elif options.type: - result = determineType( options.type, - debug=options.debug, - msgFilter=options.msg_filter, - diffFilter=options.diff_filter, - branchFilter=options.branch_filter) + opts = config.read() + result = determineType( + options.type, + debug=options.debug or opts.get("debug", False), + msgFilter=options.message_filter or opts["msgFilter"], + diffFilter=options.diff_filter or opts["diffFilter"], + branchFilter=options.branch_filter or opts["branchFilter"]) for line in result: print(line) -- 2.11.4.GIT