2012-05-04 11:40:30 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# coding: utf-8
|
|
|
|
#
|
2013-04-05 14:15:56 +02:00
|
|
|
# Copyright © 2012-2013 Ejwa Software. All rights reserved.
|
2012-05-04 11:40:30 +02:00
|
|
|
#
|
|
|
|
# This file is part of gitinspector.
|
|
|
|
#
|
|
|
|
# gitinspector is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# gitinspector is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-05-25 16:42:29 +02:00
|
|
|
from __future__ import print_function
|
2012-05-04 11:40:30 +02:00
|
|
|
import blame
|
|
|
|
import changes
|
|
|
|
import extensions
|
2012-05-22 17:57:44 +02:00
|
|
|
import filtering
|
2012-10-12 12:52:35 +02:00
|
|
|
import format
|
2012-05-04 11:40:30 +02:00
|
|
|
import getopt
|
|
|
|
import help
|
2013-05-01 23:09:10 +02:00
|
|
|
import interval
|
2012-05-14 15:24:45 +02:00
|
|
|
import metrics
|
2012-05-07 09:38:11 +02:00
|
|
|
import missing
|
2012-05-20 22:02:08 +02:00
|
|
|
import os
|
2013-03-11 00:23:50 +01:00
|
|
|
import outputable
|
2012-05-25 14:27:28 +02:00
|
|
|
import responsibilities
|
2012-05-04 11:40:30 +02:00
|
|
|
import sys
|
|
|
|
import terminal
|
|
|
|
import timeline
|
|
|
|
import version
|
|
|
|
|
|
|
|
class Runner:
|
|
|
|
def __init__(self):
|
|
|
|
self.hard = False
|
2012-05-14 15:24:45 +02:00
|
|
|
self.include_metrics = False
|
2012-05-04 11:40:30 +02:00
|
|
|
self.list_file_types = False
|
|
|
|
self.repo = "."
|
2012-05-25 14:27:28 +02:00
|
|
|
self.responsibilities = False
|
2012-10-09 15:13:25 +02:00
|
|
|
self.grading = False
|
2012-05-04 11:40:30 +02:00
|
|
|
self.timeline = False
|
|
|
|
self.useweeks = False
|
|
|
|
|
|
|
|
def output(self):
|
2012-05-05 10:26:02 +02:00
|
|
|
terminal.skip_escapes(not sys.stdout.isatty())
|
2012-05-20 22:02:08 +02:00
|
|
|
previous_directory = os.getcwd()
|
|
|
|
os.chdir(self.repo)
|
2012-10-18 16:59:52 +02:00
|
|
|
format.output_header()
|
2013-03-11 00:23:50 +01:00
|
|
|
outputable.output(changes.ChangesOutput(self.hard))
|
2012-05-04 11:40:30 +02:00
|
|
|
|
2012-05-20 22:02:08 +02:00
|
|
|
if changes.get(self.hard).get_commits():
|
2013-03-11 00:23:50 +01:00
|
|
|
outputable.output(blame.BlameOutput(self.hard))
|
2012-05-04 11:40:30 +02:00
|
|
|
|
2012-05-14 15:24:45 +02:00
|
|
|
if self.timeline:
|
2013-03-11 00:23:50 +01:00
|
|
|
outputable.output(timeline.Timeline(changes.get(self.hard), self.useweeks))
|
2012-05-04 11:40:30 +02:00
|
|
|
|
2012-05-14 15:24:45 +02:00
|
|
|
if self.include_metrics:
|
2013-03-11 00:23:50 +01:00
|
|
|
outputable.output(metrics.Metrics())
|
2012-05-14 15:24:45 +02:00
|
|
|
|
2012-05-25 14:27:28 +02:00
|
|
|
if self.responsibilities:
|
2013-03-11 00:23:50 +01:00
|
|
|
outputable.output(responsibilities.ResponsibilitiesOutput(self.hard))
|
2012-05-25 14:27:28 +02:00
|
|
|
|
2013-03-11 00:23:50 +01:00
|
|
|
outputable.output(missing.Missing())
|
|
|
|
outputable.output(filtering.Filtering())
|
2012-05-07 09:38:11 +02:00
|
|
|
|
2012-05-14 15:24:45 +02:00
|
|
|
if self.list_file_types:
|
2013-03-11 00:23:50 +01:00
|
|
|
outputable.output(extensions.Extensions())
|
2012-05-04 11:40:30 +02:00
|
|
|
|
2012-10-18 16:59:52 +02:00
|
|
|
format.output_footer()
|
2012-05-20 22:02:08 +02:00
|
|
|
os.chdir(previous_directory)
|
|
|
|
|
2012-05-04 11:40:30 +02:00
|
|
|
if __name__ == "__main__":
|
2012-05-04 15:15:41 +02:00
|
|
|
__run__ = Runner()
|
2012-05-04 11:40:30 +02:00
|
|
|
|
|
|
|
try:
|
2012-10-12 12:52:35 +02:00
|
|
|
__opts__, __args__ = getopt.gnu_getopt(sys.argv[1:], "cf:F:hHlmrTwx:", ["checkout-missing", "exclude=",
|
|
|
|
"file-types=", "format=", "hard", "help", "list-file-types",
|
2013-05-01 23:09:10 +02:00
|
|
|
"metrics", "responsibilities", "since=", "grading",
|
|
|
|
"timeline", "until=", "version"])
|
2012-10-12 12:52:35 +02:00
|
|
|
for o, a in __opts__:
|
|
|
|
if o in("-c", "--checkout-missing"):
|
|
|
|
missing.set_checkout_missing(True)
|
|
|
|
elif o in("-h", "--help"):
|
|
|
|
help.output()
|
|
|
|
sys.exit(0)
|
|
|
|
elif o in("-f", "--file-types"):
|
|
|
|
extensions.define(a)
|
|
|
|
elif o in("-F", "--format"):
|
|
|
|
if not format.select(a):
|
|
|
|
raise format.InvalidFormatError("specified output format not supported.")
|
|
|
|
elif o in("-H", "--hard"):
|
|
|
|
__run__.hard = True
|
|
|
|
elif o in("-l", "--list-file-types"):
|
|
|
|
__run__.list_file_types = True
|
|
|
|
elif o in("-m", "--metrics"):
|
|
|
|
__run__.include_metrics = True
|
|
|
|
elif o in("-r", "--responsibilities"):
|
|
|
|
__run__.responsibilities = True
|
2013-05-01 23:09:10 +02:00
|
|
|
elif o in("--since"):
|
|
|
|
interval.set_since(a)
|
2012-10-12 12:52:35 +02:00
|
|
|
elif o in("--version"):
|
2013-03-11 00:12:35 +01:00
|
|
|
version.output()
|
2012-10-12 12:52:35 +02:00
|
|
|
sys.exit(0)
|
|
|
|
elif o in("--grading"):
|
|
|
|
__run__.include_metrics = True
|
|
|
|
__run__.list_file_types = True
|
|
|
|
__run__.responsibilities = True
|
|
|
|
__run__.grading = True
|
2013-04-09 22:59:32 +02:00
|
|
|
__run__.hard = True
|
2012-10-12 12:52:35 +02:00
|
|
|
__run__.timeline = True
|
|
|
|
__run__.useweeks = True
|
|
|
|
elif o in("-T", "--timeline"):
|
|
|
|
__run__.timeline = True
|
2013-05-01 23:09:10 +02:00
|
|
|
elif o in("--until"):
|
|
|
|
interval.set_until(a)
|
2012-10-12 12:52:35 +02:00
|
|
|
elif o in("-w"):
|
|
|
|
__run__.useweeks = True
|
|
|
|
elif o in("-x", "--exclude"):
|
|
|
|
filtering.add(a)
|
|
|
|
for arg in __args__:
|
|
|
|
__run__.repo = arg
|
|
|
|
|
|
|
|
except (format.InvalidFormatError, getopt.error) as msg:
|
2012-05-25 16:42:29 +02:00
|
|
|
print(sys.argv[0], "\b:", msg)
|
|
|
|
print("Try `", sys.argv[0], "--help' for more information.")
|
2012-05-04 11:40:30 +02:00
|
|
|
sys.exit(2)
|
|
|
|
|
2012-05-04 15:15:41 +02:00
|
|
|
__run__.output()
|