The repository name and report date is now included in the generated text.
This commit is contained in:
parent
12e08daf72
commit
4e4d0a2ddb
|
@ -27,22 +27,29 @@ def get_basedir():
|
||||||
else:
|
else:
|
||||||
return os.path.dirname(os.path.realpath(__file__))
|
return os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
__git_basedir__ = None
|
||||||
|
|
||||||
def get_basedir_git():
|
def get_basedir_git():
|
||||||
isbare = subprocess.Popen("git rev-parse --is-bare-repository", shell=True, bufsize=1,
|
global __git_basedir__
|
||||||
stdout=subprocess.PIPE).stdout
|
|
||||||
isbare = isbare.readlines()
|
|
||||||
isbare = (isbare[0].decode("utf-8", "replace").strip() == "true")
|
|
||||||
absolute_path = ""
|
|
||||||
|
|
||||||
if isbare:
|
if not __git_basedir__:
|
||||||
absolute_path = subprocess.Popen("git rev-parse --git-dir", shell=True, bufsize=1,
|
isbare = subprocess.Popen("git rev-parse --is-bare-repository", shell=True, bufsize=1,
|
||||||
stdout=subprocess.PIPE).stdout
|
stdout=subprocess.PIPE).stdout
|
||||||
else:
|
isbare = isbare.readlines()
|
||||||
absolute_path = subprocess.Popen("git rev-parse --show-toplevel", shell=True, bufsize=1,
|
isbare = (isbare[0].decode("utf-8", "replace").strip() == "true")
|
||||||
|
absolute_path = ""
|
||||||
|
|
||||||
|
if isbare:
|
||||||
|
absolute_path = subprocess.Popen("git rev-parse --git-dir", shell=True, bufsize=1,
|
||||||
stdout=subprocess.PIPE).stdout
|
stdout=subprocess.PIPE).stdout
|
||||||
|
else:
|
||||||
|
absolute_path = subprocess.Popen("git rev-parse --show-toplevel", shell=True, bufsize=1,
|
||||||
|
stdout=subprocess.PIPE).stdout
|
||||||
|
|
||||||
absolute_path = absolute_path.readlines()
|
absolute_path = absolute_path.readlines()
|
||||||
if len(absolute_path) == 0:
|
if len(absolute_path) == 0:
|
||||||
sys.exit(_("Unable to determine absolute path of git repository."))
|
sys.exit(_("Unable to determine absolute path of git repository."))
|
||||||
|
|
||||||
return absolute_path[0].decode("utf-8", "replace").strip()
|
__git_basedir__ = absolute_path[0].decode("utf-8", "replace").strip()
|
||||||
|
|
||||||
|
return __git_basedir__
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
#
|
#
|
||||||
# Copyright © 2012-2013 Ejwa Software. All rights reserved.
|
# Copyright © 2012-2014 Ejwa Software. All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of gitinspector.
|
# This file is part of gitinspector.
|
||||||
#
|
#
|
||||||
|
@ -19,10 +19,14 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
import localization
|
||||||
import version
|
import version
|
||||||
import base64
|
import base64
|
||||||
import basedir
|
import basedir
|
||||||
import os
|
import os
|
||||||
|
import terminal
|
||||||
|
import textwrap
|
||||||
|
import time
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
__available_formats__ = ["html", "htmlembedded", "text", "xml"]
|
__available_formats__ = ["html", "htmlembedded", "text", "xml"]
|
||||||
|
@ -88,6 +92,8 @@ def output_header():
|
||||||
logo_text = _("The output has been generated by {0}; the statistical analysis tool"
|
logo_text = _("The output has been generated by {0}; the statistical analysis tool"
|
||||||
" for git repositories.").format(
|
" for git repositories.").format(
|
||||||
"<a href=\"http://gitinspector.googlecode.com\">gitinspector</a>"),
|
"<a href=\"http://gitinspector.googlecode.com\">gitinspector</a>"),
|
||||||
|
repo_text = _("Statistical information for the repository '{0}' was gathered on {1}.").format(
|
||||||
|
os.path.basename(basedir. get_basedir_git()), localization.get_date()),
|
||||||
show_minor_authors = _("Show minor authors"),
|
show_minor_authors = _("Show minor authors"),
|
||||||
hide_minor_authors = _("Hide minor authors"),
|
hide_minor_authors = _("Hide minor authors"),
|
||||||
show_minor_rows = _("Show rows with minor work"),
|
show_minor_rows = _("Show rows with minor work"),
|
||||||
|
@ -95,6 +101,11 @@ def output_header():
|
||||||
elif __selected_format__ == "xml":
|
elif __selected_format__ == "xml":
|
||||||
print("<gitinspector>")
|
print("<gitinspector>")
|
||||||
print("\t<version>" + version.__version__ + "</version>")
|
print("\t<version>" + version.__version__ + "</version>")
|
||||||
|
print("\t<repository>" + os.path.basename(basedir. get_basedir_git()) + "</repository>")
|
||||||
|
print("\t<report-date>" + time.strftime("%Y/%m/%d") + "</report-date>")
|
||||||
|
else:
|
||||||
|
print(textwrap.fill(_("Statistical information for the repository '{0}' was gathered on {1}.").format(
|
||||||
|
os.path.basename(basedir. get_basedir_git()), localization.get_date()), width=terminal.get_size()[0]))
|
||||||
|
|
||||||
def output_footer():
|
def output_footer():
|
||||||
if __selected_format__ == "html":
|
if __selected_format__ == "html":
|
||||||
|
|
|
@ -310,5 +310,5 @@
|
||||||
<body>
|
<body>
|
||||||
<div><div class="box logo">
|
<div><div class="box logo">
|
||||||
<img src="data:image/png;base64,{logo}" />
|
<img src="data:image/png;base64,{logo}" />
|
||||||
<p>{logo_text}<p>
|
<p>{repo_text} {logo_text}</p>
|
||||||
</div></div>
|
</div></div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
#
|
#
|
||||||
# Copyright © 2013 Ejwa Software. All rights reserved.
|
# Copyright © 2013-2014 Ejwa Software. All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of gitinspector.
|
# This file is part of gitinspector.
|
||||||
#
|
#
|
||||||
|
@ -17,12 +17,15 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# 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 print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import basedir
|
import basedir
|
||||||
import gettext
|
import gettext
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
__enabled__ = False
|
||||||
__installed__ = False
|
__installed__ = False
|
||||||
__translation__ = None
|
__translation__ = None
|
||||||
|
|
||||||
|
@ -31,6 +34,7 @@ def N_(message):
|
||||||
return message
|
return message
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
global __enabled__
|
||||||
global __installed__
|
global __installed__
|
||||||
global __translation__
|
global __translation__
|
||||||
|
|
||||||
|
@ -54,13 +58,26 @@ def init():
|
||||||
except IOError:
|
except IOError:
|
||||||
__translation__ = gettext.NullTranslations()
|
__translation__ = gettext.NullTranslations()
|
||||||
|
|
||||||
|
__enabled__ = True
|
||||||
__installed__ = True
|
__installed__ = True
|
||||||
__translation__.install(True)
|
__translation__.install(True)
|
||||||
|
|
||||||
|
def get_date():
|
||||||
|
if __enabled__ and isinstance(__translation__, gettext.GNUTranslations):
|
||||||
|
return time.strftime("%x")
|
||||||
|
else:
|
||||||
|
return time.strftime("%Y/%m/%d")
|
||||||
|
|
||||||
def enable():
|
def enable():
|
||||||
if __installed__ and type(__translation__) is not gettext.GNUTranslations:
|
if isinstance(__translation__, gettext.GNUTranslations):
|
||||||
__translation__.install(True)
|
__translation__.install(True)
|
||||||
|
|
||||||
|
global __enabled__
|
||||||
|
__enabled__ = True
|
||||||
|
|
||||||
def disable():
|
def disable():
|
||||||
|
global __enabled__
|
||||||
|
__enabled__ = False
|
||||||
|
|
||||||
if __installed__:
|
if __installed__:
|
||||||
gettext.NullTranslations().install(True)
|
gettext.NullTranslations().install(True)
|
||||||
|
|
Loading…
Reference in New Issue