Commit graph

249 commits

Author SHA1 Message Date
Adam Waldenberg
291761e6a4 Exceptions now store messages in self.msg directly.
Previously, they had a msg() method for fetching the error string. This
has now been removed in favor of the directly callable attribute.
2013-07-14 04:57:32 +02:00
Adam Waldenberg
cf63af8819 Fixed some pylint violations in some newly added code. 2013-07-14 04:47:34 +02:00
Adam Waldenberg
adf6ee412f -x and --exclude options now clear the filtering rules when first found.
This behavior is preferred in order for us to be able to override any
exclude filter set via git-config.
2013-07-14 04:29:00 +02:00
Adam Waldenberg
3a34be0d06 Added missing "--checkout-missing" long option to gitinspector module. 2013-07-14 04:15:41 +02:00
Adam Waldenberg
4fbcb48127 Rewrote git-config support once again.
It was still presuming that we were using optparse.
2013-07-14 04:15:10 +02:00
Adam Waldenberg
b28d86d1f2 Fixed a long-standing bug with exceptions not being able to handle unicode.
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.
2013-07-14 03:15:14 +02:00
Adam Waldenberg
5c9335088a Command-line arguments are now always converted to UTF-8 before use. 2013-07-14 03:10:00 +02:00
Adam Waldenberg
7f0e2b6fe8 Changed the argument parsing back to using getopt!
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.
2013-07-14 00:07:36 +02:00
Adam Waldenberg
cae99cb3f7 Extended the README with some "quick start" notes. 2013-07-12 03:50:21 +02:00
Adam Waldenberg
c073e32dbe Hacked optparse (yet again) to force it to play nice with unicode flags.
Previously, whenever a flag had unicode characters in it; it would all
completely blow up.
2013-07-12 03:36:03 +02:00
Adam Waldenberg
f4b10ce15f Moved unicode function declaration to a compatibility module.
This is used (as the name suggests) for compatibility between Python 2 and
Python 3.
2013-07-12 03:33:13 +02:00
Adam Waldenberg
8edd72a609 gitinspector now exits if it fails to change directory to the repo root. 2013-07-10 16:58:06 +02:00
Adam Waldenberg
84bb7bed2d Removed a pylint violation in the localization module. 2013-07-10 16:45:46 +02:00
Adam Waldenberg
aeb55c5a3e Fixed a potential encoding issue when printing exception messages. 2013-07-10 16:45:12 +02:00
Adam Waldenberg
2df9a31b60 gitinspector now finds the absolute path of the git directory.
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.
2013-07-10 14:23:11 +02:00
Adam Waldenberg
9e39bf8ed2 Added the new localization strings to the pot file.
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.
2013-07-10 13:55:23 +02:00
Adam Waldenberg
ccd995a02b Improved localization in the optval module. 2013-07-10 05:25:57 +02:00
Adam Waldenberg
3b82acdfa1 Added a --localize-output flag.
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.
2013-07-10 05:24:18 +02:00
Adam Waldenberg
109fefb978 Fixed some small mistakes in relation to handling of git-config settings. 2013-07-10 03:32:29 +02:00
Adam Waldenberg
a05403df60 Added localization support to optparse error messages.
The optparse module does not seem to support this by default. The solution
is not very pretty, but it works.
2013-07-10 03:11:15 +02:00
Adam Waldenberg
0d2bf9b0a8 Implemented optional boolean arguments to some command-line options.
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).
2013-07-09 12:40:59 +02:00
Adam Waldenberg
663493fd41 Localization module is now initialized only once (instead of twice).
This removes an unnecessary initialization and also fixes the behavior
under Windows which was broken because of the second initialization.
2013-07-04 10:55:54 +02:00
Adam Waldenberg
7bc297e99f Added two unit tests for testing the comment module. 2013-07-04 10:10:11 +02:00
Adam Waldenberg
942836cc1c There was a mixup in the metrics module (wrong ordering of return values). 2013-07-04 10:07:41 +02:00
Adam Waldenberg
bb72cc8f02 Added a handle_comment_block() function in the comment module.
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.
2013-07-02 23:03:09 +02:00
Adam Waldenberg
f20b826d2d Added long option (--weeks) to the -w option.
This makes it clearer that it is supported in conjunction with git-config
as well.
2013-07-02 07:45:56 +02:00
Adam Waldenberg
15026f6f00 Translation files are now included during packaging via setup.py. 2013-07-02 07:35:40 +02:00
Adam Waldenberg
017f63e98a The translation files are now found regardless of the current directory.
It was previously only working if gitinspector was executed from the base
directory.
2013-07-02 07:33:46 +02:00
Adam Waldenberg
0923547947 Added a configuration file used by stdeb when creating debian packages.
The default distribution chosen is "Debian testing" with Python 2.6+.
2013-07-01 03:19:45 +02:00
Adam Waldenberg
c6df0cc95c Setuptools now places the documentation (txt files) in the correct folder. 2013-07-01 03:18:23 +02:00
Adam Waldenberg
f9808c609b Import of localization module failed when running setup.py under Python 3. 2013-07-01 03:17:35 +02:00
Adam Waldenberg
021c1e479e git-config settings were not being fetched when a git directory was set.
It was only working if gitinspector was invoked inside a git directory.
2013-07-01 01:38:19 +02:00
Adam Waldenberg
ce98a2ed70 Fixed a syntax error in the config module. 2013-07-01 00:34:28 +02:00
Adam Waldenberg
ac5e38c8f0 The handling of output format was wrong in the config module. 2013-07-01 00:33:58 +02:00
Adam Waldenberg
84a7fd1945 Added support for --exclude to the git-config support.
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.
2013-07-01 00:26:06 +02:00
Adam Waldenberg
bfdac450c4 Regular expression handling now throws an error on an invalid regex.
Previously, it was giving of an incomprehensible error from the "re"
module in Python.
2013-07-01 00:15:42 +02:00
Adam Waldenberg
dcb4cedf27 Fixed some reported pylint violations. 2013-07-01 00:11:34 +02:00
Adam Waldenberg
aec58ac499 Filtering and the -x/--exclude option now support regular expressions.
Thanks to this change; we can support the --exclude option in conjunction
with git-config.
2013-06-30 23:58:49 +02:00
Adam Waldenberg
8bd761f872 Settings for gitinspector can now be set using git-config.
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.
2013-06-30 20:58:30 +02:00
Adam Waldenberg
e15ee100a2 Removed the "€" character from the tablesorter plugin (Fixes issue 6).
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.
2013-06-30 18:34:45 +02:00
Adam Waldenberg
16701a4d51 Added support for comments in LaTex (.tex) files (Fixes issue 8).
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.
2013-06-30 01:53:08 +02:00
Adam Waldenberg
aec012b877 The HTML output now shows the number of hidden entries in tables. 2013-06-26 04:30:57 +02:00
Adam Waldenberg
cd1c1f0c65 gitinspector now tries to get around any invalid locale.
Whenever a locale is found that is simply wrong; gitinspector will try to
get the default strings from gettext and try to execute.
2013-06-26 03:51:43 +02:00
Adam Waldenberg
f030147206 Added missing localization strings to/in the timeline module. 2013-06-26 03:24:31 +02:00
Adam Waldenberg
0d8c3534dc There wasn't always enough room for the Swedish strings in the text output. 2013-06-26 03:23:58 +02:00
Adam Waldenberg
c19680dc39 Changed the default format back to "text" instead of "htmlembedded". 2013-06-26 02:42:41 +02:00
Adam Waldenberg
45429d9a35 Added a "htmlembedded" output format.
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.
2013-06-26 02:36:13 +02:00
Adam Waldenberg
58fbd0f3e1 Added more space in the help text for listing available output formats.
As a consequence; the locales also had to be updated.
2013-06-26 02:32:34 +02:00
Adam Waldenberg
4f1adb83f6 Added the binary for the Swedish translation. 2013-06-26 02:10:48 +02:00
Adam Waldenberg
a54be45d23 Updated the translation files to include the new localization. 2013-06-26 01:29:37 +02:00