Whenever filtering of author or email was enabled, problems could arise
when calculating comments percentage. Did some reshuffling of the logic;
resolving it.
It was not taking the caret (^) character into consideration when --since
was being specified, something which resulted in an excess of attributed
rows.
With this easy fix, the behavior should now be "correct".
This is flag should not be needed anymore, as gitinspector always uses
a reference point such as HEAD or some reivision when looking into the
repository (never the file structure directly).
Instead of specifying -x (or --exclude) multiple times, it is possible to
specify multiple filtering rules by separating each rule with a comma (,)
character. This enables the new support for filtering authors and email to
work in conjunction with git-config.
As a side effect, this means that we reserve the comma character for
internal use in gitinspector and that it can't be used in any regular
expression or filtering rule. However, this is not a big problem.
Of course, specifying -x multiple times (like before) is still supported.
To access this functionality; the -x flag can now be called in the
following ways:
-x file
-x file:<file>
-x author:<author name>
-x email:<email>
Just passing -x file will presume that the filtering rule is intended for
a file (just like the previous behavior).
All the filtering is case sensitive (even filtering by email) in order to
not break any regular expressions used. Case-insensitive matching can
instead be easily achieved with the appropriate regular expression.
To get reversed filtering (excluding everything not matched within -x) a
regular expression with the a syntax such as '^(?!<rule>)' can be used.
This works in the same manner as the other filtering available in the HTML
view. The minor authors of the responsibilities view equal the minor
authors of the blame view.
Previously, an email for a specific author was collected whenever some
insertions/deletions were detected in an active or valid extension. This
was introduced with the addition of gravatars.
This had the side-effect that if #author1 committed some rows to a file
with an inactive or non-valid extension and #author2 later moved some of
those rows into an active or valid extension, those rows could still
belong to #author1. Consequently, when associating the author name with
an email in the blame phase, there would not be any stored email for
#author1 and no email would be associated with that author or those blamed
lines.
Emails are now (instead) always stored and associated with an author
regardless of the work or files analyzed.
This is unnecessary as there is a get() function inside the changes module
to fetch an object of this class, so we can fetch this directly in
BlameOutput.__init__().
The error message when using an incompatible version of
Python contains a typo.
Signed-off-by: Chris Ring <chris@ringthis.com>
Reviewed-by: Adam Waldenberg <adam.waldenberg@ejwa.se>
Previously; the __get_size_windows__() function could return "None",
whenever the terminal size couldn't be determined; something which broke
the execution.
There was some chance for misbehavior under Linux as well.
Previously, gitinspector always tried to merge authors with the same name
(independently of the email). This behavior tends to (for the most part)
help in projects missing a .mailmap file. Often; authors commit under the
same name, but with different emails on different computers (if they for
example have a work email on their office desktop).
Whenever different e-mail addresses are used by an author; gitinspector
will use the last email it finds and will generate a gravatar from that
email address. This behavior was chosen because authors mostly do not tend
to create a gravatar image for their old email accounts (but often have
one in their newer ones).
References to gravatar images are generated with HTML and XML outputs only
as these are the only formats where referencing gravatars makes sense
right now. The HTMLEmbedded format, for example, does not link to any
gravatars as that format prohibits the use of external links.
To accommodate the new images; the width of the generated HTML page has
been slightly increased. However, the HTML page should still fit on a
1280 display.
This is a better solution than simply relying on ValueError and also
helps us to maintain compatibility with all our other exceptions (it gives
us a msg attribute that we can access when catching the error).
Also localized the string for InvalidRegExpError.
This was fixed by storing the exception string manually inside each
exception class. The error message is now stored in exception.msg instead
of relying on __str__(). It seems the normal behavior (by printing exceptions
directly) is broken in Python 2. It *does* work in Python 3, but this is
because it always handles everything as unicode.
The support for optional boolean arguments is the same; but uses
getopt instead of optparse.
The whole adventure with optparse was a giant waste of time and just
forced us to monkey-patch optparse with some very ugly solutions in order
to make it do what we wanted; thus it was better to switch back to the
more low-level getopt module.
To accomplish this; a optval.gnu_getopt() function was added that is a
duplicate of the original getopt.gnu_getopt function but with support for
optional arguments.
A long option which accepts an optional argument is denoted with
arg:default_value in the long_options string.
In the end, this solution feels much better than the one with optparse.
If gitinspector was not executed standing in the root directory of the
git repository (or with a git root specified at the command line),
"git ls-tree" would not find all files properly.
In the process, the new strings were also translated to Swedish. To
properly handle localized string constants, a new function "N_()" was
added which can be supplied to xgettext when collecting strings.
The default behaviour is now not to localize the output, only the help
text and error messages (all the user interaction).
The way localized messages are fetched in the modules has been modified
as well; to allow for the ability to enable and disable the localization.
Just like in many GNU tools, it is now possible to pass an optional
boolean to some of the flags of gitinspector in the form;
--flag[=BOOL]
This gives us the ability to override options set via git-config.
For example; say we did the following:
git-config --global inspector.timeline true
We could then override this setting when running gitinspector by supplying:
./gitinspector.py --timeline=false
Implementing this was not a trivial task, as no command-line parser in
Python supports this by default (getopt, optparse, argparse). In order to
properly handle optional boolean arguments; some clever patching had to
be done to the command-line in combination with a callback function that
can handle boolean strings. To maintain compatibility with Python 2.6,
this was implemented using optparse (instead of argparse).
This function moves most of the logic of handling comments into the
comment module itself, thus avoiding duplicated code and allowing for
a cleaner solution.
In contrast to the -x/--exclude option that can be given on the command
line, --exclude can not be set multiple times when used with git-config.
Luckily, the same behavior can be attained by using the pipe ("|")
character. Ie, specifying the following on the command line:
-x "hello.txt" -x "goodbye.txt"
is the same thing as:
-x "hello.txt|goodbye.txt"
when sent to git-config or the command line.
All long options that can be set in gitinspector (with the exception of
--version and --help) can be configured using git-config. This is only the
first step towards the support of git-config. The reading of the command
line also needs to be changed to support overriding settings from
git-config before this is fully usable. Also; support for --exclude is
not yet included.
If we wanted to enable the timeline across all repositories when running
gitinspector we could do;
git-config --global inspector.timeline true
For local settings (per repository); the --local option can of course be
used when calling git-config.
The currency sorter of the plugin supports €, $ and £. Unfortunately,
the "€" (euro) sign can cause problems with certain character maps,
something which means we might as well remove support for it as
gitinspector is not using any currency sorting anyway.
Even though it is supported, LaTex is not part of the default file
extensions used during analysis. To include LaTex files in the statistical
analysis, the extension (.tex) needs to be supplied to gitinspector using
the -f flag.
This format behaves the same as the old "html" output. Consequently, the
ordinary "html" output now hot-links the JQuery script to
ajax.googleapis.com. This results in a generated file with roughly half
the stitching code compared to previously.
The gettext.install() functions supplies a way to force it to return
unicode which helps with compatibility between Python 2 & 3. To make it
work properly when merging those returned string with strings in the
different modules of gitinspector we also had to do some changes to make
sure all string literals are in unicode.
The name of the author is now highlighted in the table whenever a pie
piece in the pie chart is hovered over. Currently, it does not work the
other way around (because of a limitation in the flot library).
This particular setup script has been tested with Distribute 0.6.24.
For some strange reason, the generated entry-point script does not work
with Python 3.3 - resulting in import errors. I can only assume this is
a bug in this version of the Distribute package when it's running together
with Python 3.3.