mirror of
https://github.com/ejwa/gitinspector.git
synced 2025-01-03 11:22:15 +01:00
Rewrote git-config support once again.
It was still presuming that we were using optparse.
This commit is contained in:
parent
b28d86d1f2
commit
4fbcb48127
1 changed files with 58 additions and 33 deletions
|
@ -18,15 +18,17 @@
|
||||||
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
import extensions
|
||||||
|
import filtering
|
||||||
|
import format
|
||||||
|
import missing
|
||||||
|
import optval
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def __read_git_config__(run, variable, destination=None):
|
def __read_git_config__(repo, variable):
|
||||||
if destination == None:
|
|
||||||
destination = variable
|
|
||||||
|
|
||||||
previous_directory = os.getcwd()
|
previous_directory = os.getcwd()
|
||||||
os.chdir(run.repo)
|
os.chdir(repo)
|
||||||
setting = subprocess.Popen("git config inspector." + variable, shell=True, bufsize=1,
|
setting = subprocess.Popen("git config inspector." + variable, shell=True, bufsize=1,
|
||||||
stdout=subprocess.PIPE).stdout
|
stdout=subprocess.PIPE).stdout
|
||||||
os.chdir(previous_directory)
|
os.chdir(previous_directory)
|
||||||
|
@ -34,35 +36,58 @@ def __read_git_config__(run, variable, destination=None):
|
||||||
try:
|
try:
|
||||||
setting = setting.readlines()[0]
|
setting = setting.readlines()[0]
|
||||||
setting = setting.decode("utf-8", "replace").strip()
|
setting = setting.decode("utf-8", "replace").strip()
|
||||||
|
|
||||||
if setting == "True" or setting == "true" or setting == "t" or setting == "1":
|
|
||||||
vars(run.opts)[destination] = True
|
|
||||||
elif setting == "False" or setting == "false" or setting == "f" or setting == "0":
|
|
||||||
vars(run.opts)[destination] = False
|
|
||||||
return True
|
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
setting = ""
|
||||||
|
|
||||||
|
return setting
|
||||||
|
|
||||||
|
def __read_git_config_bool__(repo, variable):
|
||||||
|
try:
|
||||||
|
variable = __read_git_config__(repo, variable)
|
||||||
|
return optval.get_boolean_argument(False if variable == "" else variable)
|
||||||
|
except optval.InvalidOptionArgument:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def init(run):
|
def __read_git_config_string__(repo, variable):
|
||||||
__read_git_config__(run, "checkout-missing", "checkout_missing")
|
string = __read_git_config__(repo, variable)
|
||||||
__read_git_config__(run, "file-types", "file_types")
|
return (True, string) if len(string) > 0 else (False, None)
|
||||||
__read_git_config__(run, "exclude")
|
|
||||||
__read_git_config__(run, "format")
|
|
||||||
__read_git_config__(run, "hard")
|
|
||||||
__read_git_config__(run, "list-file-types", "list_file_types")
|
|
||||||
__read_git_config__(run, "localize-output", "localize_output")
|
|
||||||
__read_git_config__(run, "metrics")
|
|
||||||
__read_git_config__(run, "responsibilities")
|
|
||||||
__read_git_config__(run, "weeks", "useweeks")
|
|
||||||
__read_git_config__(run, "since")
|
|
||||||
__read_git_config__(run, "until")
|
|
||||||
__read_git_config__(run, "timeline")
|
|
||||||
|
|
||||||
if __read_git_config__(run, "grading"):
|
def init(run):
|
||||||
run.opts.hard = True
|
missing.set_checkout_missing(__read_git_config_bool__(run.repo, "checkout-missing"))
|
||||||
run.opts.list_file_types = True
|
|
||||||
run.opts.metrics = True
|
var = __read_git_config_string__(run.repo, "file-types")
|
||||||
run.opts.responsibilities = True
|
if var[0]:
|
||||||
run.opts.timeline = True
|
extensions.define(var[1])
|
||||||
run.opts.useweeks = True
|
|
||||||
|
var = __read_git_config_string__(run.repo, "exclude")
|
||||||
|
if var[0]:
|
||||||
|
filtering.add(var[1])
|
||||||
|
|
||||||
|
var = __read_git_config_string__(run.repo, "format")
|
||||||
|
if var[0] and not format.select(var[1]):
|
||||||
|
raise format.InvalidFormatError(_("specified output format not supported."))
|
||||||
|
|
||||||
|
run.hard = __read_git_config_bool__(run.repo, "hard")
|
||||||
|
run.list_file_types = __read_git_config_bool__(run.repo, "list-file-types")
|
||||||
|
run.localize_output = __read_git_config_bool__(run.repo, "localize-output")
|
||||||
|
run.metrics = __read_git_config_bool__(run.repo, "metrics")
|
||||||
|
run.responsibilities = __read_git_config_bool__(run.repo, "responsibilities")
|
||||||
|
run.useweeks = __read_git_config_bool__(run.repo, "weeks")
|
||||||
|
|
||||||
|
var = __read_git_config_string__(run.repo, "since")
|
||||||
|
if var[0]:
|
||||||
|
interval.set_since(var[1])
|
||||||
|
|
||||||
|
var = __read_git_config_string__(run.repo, "until")
|
||||||
|
if var[0]:
|
||||||
|
interval.set_until(var[1])
|
||||||
|
|
||||||
|
run.timeline = __read_git_config_bool__(run.repo, "timeline")
|
||||||
|
|
||||||
|
if __read_git_config_bool__(run.repo, "grading"):
|
||||||
|
run.hard = True
|
||||||
|
run.list_file_types = True
|
||||||
|
run.metrics = True
|
||||||
|
run.responsibilities = True
|
||||||
|
run.timeline = True
|
||||||
|
run.useweeks = True
|
||||||
|
|
Loading…
Reference in a new issue