mirror of
https://github.com/ejwa/gitinspector.git
synced 2025-03-16 13:28:04 +01:00
Added a new --checkout-missing option. Missing files are now pretty-printed.
If any missing files are detected during analysis, gitinspector reports them in a list. If, on the other hand, the --checkout-missing option is supplied, gitinspector will try to checkout any missing files instead.
This commit is contained in:
parent
4b1267ba39
commit
f8b3a20652
4 changed files with 70 additions and 11 deletions
18
blame.py
18
blame.py
|
@ -18,6 +18,7 @@
|
|||
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from changes import FileDiff
|
||||
import missing
|
||||
import re
|
||||
import sysrun
|
||||
import terminal
|
||||
|
@ -29,17 +30,18 @@ class Blame:
|
|||
|
||||
for i in ls_tree_r.readlines():
|
||||
if FileDiff.is_valid_extension(i):
|
||||
git_blame_r = sysrun.run(repo, "git blame -w {0} \"".format("-C -M" if hard else "") +
|
||||
i.strip() + "\"")
|
||||
if not missing.add(repo, i.strip()):
|
||||
git_blame_r = sysrun.run(repo, "git blame -w {0} \"".format("-C -M" if hard else "") +
|
||||
i.strip() + "\"")
|
||||
|
||||
for j in git_blame_r.readlines():
|
||||
if Blame.is_blame_line(j):
|
||||
author = Blame.get_author(j)
|
||||
for j in git_blame_r.readlines():
|
||||
if Blame.is_blame_line(j):
|
||||
author = Blame.get_author(j)
|
||||
|
||||
if self.blames.get(author, None) == None:
|
||||
self.blames[author] = 0
|
||||
if self.blames.get(author, None) == None:
|
||||
self.blames[author] = 0
|
||||
|
||||
self.blames[author] += 1
|
||||
self.blames[author] += 1
|
||||
|
||||
@staticmethod
|
||||
def is_blame_line(string):
|
||||
|
|
|
@ -23,6 +23,7 @@ import changes
|
|||
import extensions
|
||||
import getopt
|
||||
import help
|
||||
import missing
|
||||
import sys
|
||||
import terminal
|
||||
import timeline
|
||||
|
@ -47,6 +48,8 @@ class Runner:
|
|||
if self.timeline == True:
|
||||
timeline.output(changes.get(self.repo, self.hard), self.useweeks)
|
||||
|
||||
missing.output()
|
||||
|
||||
if self.list_file_types == True:
|
||||
ex = extensions.get_located()
|
||||
if (ex):
|
||||
|
@ -58,14 +61,16 @@ if __name__ == "__main__":
|
|||
__run__ = Runner()
|
||||
|
||||
try:
|
||||
__opts__, __args__ = getopt.gnu_getopt(sys.argv[1:], "f:hHlTw", ["file-types=", "hard", "help",
|
||||
"list-file-types", "tda367", "timeline", "version"])
|
||||
__opts__, __args__ = getopt.gnu_getopt(sys.argv[1:], "cf:hHlTw", ["checkout-missing", "file-types=", "hard",
|
||||
"help", "list-file-types", "tda367", "timeline", "version"])
|
||||
except getopt.error, msg:
|
||||
print sys.argv[0], "\b:", msg
|
||||
print "Try `", sys.argv[0], "--help' for more information."
|
||||
sys.exit(2)
|
||||
for o, a in __opts__:
|
||||
if o in("-h", "--help"):
|
||||
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"):
|
||||
|
|
1
help.py
1
help.py
|
@ -23,6 +23,7 @@ specified, the current directory is used. If multiple directories are
|
|||
given, information will be fetched from the last directory specified.
|
||||
|
||||
Mandatory arguments to long options are mandatory for short options too.
|
||||
-c, --checkout-missing try to checkout any missing files
|
||||
-f, --file-types=EXTENSIONS a comma separated list of file extensions to
|
||||
include when computing statistics. The
|
||||
default extensions used are:
|
||||
|
|
51
missing.py
Normal file
51
missing.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2012 Ejwa Software. All rights reserved.
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
import os
|
||||
import sysrun
|
||||
|
||||
__checkout_missing__ = False
|
||||
__missing_files__ = set()
|
||||
|
||||
def add(repo, file_name):
|
||||
previous_directory = os.getcwd()
|
||||
os.chdir(repo)
|
||||
exists = os.path.exists(file_name)
|
||||
os.chdir(previous_directory)
|
||||
|
||||
if not exists:
|
||||
if __checkout_missing__:
|
||||
sysrun.run(repo, "git checkout \"" + file_name.strip() + "\"")
|
||||
else:
|
||||
__missing_files__.add(file_name)
|
||||
return True
|
||||
return False
|
||||
|
||||
def set_checkout_missing(checkout):
|
||||
global __checkout_missing__
|
||||
__checkout_missing__ = checkout
|
||||
|
||||
def output():
|
||||
if __missing_files__:
|
||||
print "\nThe following files were missing in the repository and were therefore not"
|
||||
print "completely included in the statistical analysis. To include them, you can"
|
||||
print "either checkout manually using git or use the -c option in gitinspector:"
|
||||
|
||||
for missing in __missing_files__:
|
||||
print missing
|
Loading…
Add table
Reference in a new issue