Commit Graph

575 Commits

Author SHA1 Message Date
Thomas Quinot
ff90d51cb1 Set LANG to C for reproduceable output
Make sure GIT messages in actual output match expected locale.
2017-12-13 17:35:04 +04:00
Joel Brobecker
0ce5aa8f51 reject commits with non-ISO-8859-15 characters.
For QB25-001.
2017-12-13 15:39:06 +04:00
Joel Brobecker
d79d7b0e66 Require TNs to be on word boundaries to be accepted.
For QB25-001.
2017-12-13 15:38:58 +04:00
Joel Brobecker
087a8bcdf0 disable all checks on revert commits
For QB08-047.
2017-11-09 07:57:00 -08:00
Joel Brobecker
1e1e4ec080 Add support for hooks.no-style-checks config option
For Q608-030.
2017-08-04 16:06:50 -07:00
Joel Brobecker
c8e66c1be6 AbstractUpdate: move style checking code to its own private method.
It makes it easier to separate this part of the code from the rest,
and this is preparation for skipping this part if the repository
has been configured to do so.

For Q608-030.
2017-08-04 16:06:49 -07:00
Joel Brobecker
3fed778872 rename check_commit and check_files to style_check_{commit,files}
This makes it clear what this functions are meant to do.
2017-08-04 16:06:47 -07:00
Joel Brobecker
acfb6e6349 Remove hooks.no-gitreview-check using hooks.no-precommit-check instead
The latter is really all-encompassing, and expected to disable all
precommit checks. And it would be used in the scenario that lead
to the creation of the hooks.no-gitreview-check config. So it should
be good enough for now to simply rely on hooks.no-precommit-check.

For Q802-008.
2017-08-02 06:09:53 -07:00
Joel Brobecker
6bd7529c2d Add support for hooks.no-gitreview-check configuration
For Q802-008.
2017-08-02 05:58:36 -07:00
Joel Brobecker
d607c1c432 reject a branch creation if gerrit.defaultbranch is set improperly
This patch rejects a branch creation if it looks like the user
forgot to update the gerrit.defaultbranch config in the .gitreview
file. This is to prevent some fairly confusing behavior when
we forgot..,

For P426-022
2017-07-28 16:24:56 -07:00
Joel Brobecker
407bcd597e remove support for the word "minor" as substitute for a TN
Users are now invited to use "no-tn-check" exclusively for that.

For Q728-031.
2017-07-28 16:24:55 -07:00
Joel Brobecker
54bf80d9f7 Add support for users disallowing updates to specific references
This commit introduces a new hooks.frozen-ref (tuple) config which
allows a user, via an update of the refs/meta/config::project.config
file, to disallow changes to any reference.

Typically, this would be used when a given branch gets retired,
to prevent people from pushing updates to is, thinking that they
are updating an active branch, when in fact the branch is no longer
being used.

The same effect could be achieved using the "retired/*" namespace,
but this approach was deemed easier to manage for certain users
(and the latter approach was designed before users had access to
the hook's config file).

For Q314-009.
2017-07-05 09:11:08 -07:00
Joel Brobecker
229a66eb14 Support defining tuple configs via multiple entries of the same config
For instance, instead of defining hooks.no-emails as...

    no-emails = refs/heads/topic*,refs/heads/wip*

... one can now say:

    no-emails = refs/heads/topic*
    no-emails = refsheads/wip*

For Q314-009.
2017-07-05 09:11:06 -07:00
Joel Brobecker
9d2ee9ff3c add support for multiline values in git config files.
Prior to this patch, the git-hooks were assuming that all options
in the project.config file were entirely contained within a single
line. This patch lifts this limitation.

For Q119-043.
2017-07-05 09:11:04 -07:00
Joel Brobecker
415ea95e68 hooks/updates/__init__.py: Fix PEP8 style violation 2017-07-05 09:11:03 -07:00
Joel Brobecker
7cedde9495 Only call style_checker once per commit (or group of commits)
This is a performance enhancement which reduces the number of calls
to style_checker to, at most, once per commit. For repositories which
are configured to combine the commits for style-checking, the
style_checker should only be called once at most.

In terms of performance gains, the new approach increases
the performance by a factor of about 5 to 8 (measured using
a set of 10, 100, 1000 and 4500 files, the latter being the typical
commit in the GDB repository when adjusting the copyright year in
all GDB sources).

Roughly speaking, on an Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz,
style-checking 4,500 text files, for which no check is actually
performed, took 31 seconds instead of 226 seconds. Using 4,500 Ada
files, for which we actually run the GNAT compiler and perform some
rulific checks, the new approach took 61 seconds instead of 230
seconds. The relative gain in the Ada case may appear to decrease
with the number of files to check, but 61 secs instead of 230 secs
is the difference between completing before the gerrit timeout
(around 2 minutes) or being aborted by the gerrit timeout.

For Q530-009.
2017-07-05 09:11:02 -07:00
Joel Brobecker
030bd984d1 minor enhancement in cvs_check script used in various testcases
Given the recent change where we're preparing for calling the style_checker
only once for all files at once, the hooks are no longer printing
the name of the file that failed style checking. For that, we rely
on the style_checker itself. What this commit does is adjusting
the fake cvs_check scripts we use as the style checker within
this testsuite to mimick the desired behavior a little more.
Rather than just printing an error message, we print the name
of the file that triggered the error as well.

Related to Q530-009.
2017-07-05 09:11:01 -07:00
Joel Brobecker
e4fa3fd38b pre_commit_checks: pass the filename via stdin rather than the command line
This is preparation work towards calling the style checker only once
for an entire commit, rather than once per file.

This commit also adds a new testcase, allowing the code coverage to
remain at 100%.

For Q530-009.
2017-07-05 09:10:59 -07:00
Joel Brobecker
8333edae90 simplify module name in call to style_checker
Thanks to the transition to the new style checker, we can now
call it directly with the module name, without having to fake
the SVN path to that module.

Part of NA17-007.
2017-05-18 09:34:28 -07:00
Joel Brobecker
168de73a97 transition default style checker to style_checker
For NA17-007.
2017-05-18 09:34:27 -07:00
Joel Brobecker
c43ac46b79 syslog.py: Fix style issue.
Part of NA17-007.
2017-05-18 09:34:25 -07:00
Joel Brobecker
048462bc05 do not require '(' and ')' around no-rh-check or no-precommit-check
The team felt that requiring the extra '(' and ')' around the keywords
we can use in revision logs aren't really all that necessary, so
this patch makes it all consistent within the git-hooks, but
the svn hooks as well.

This patch also adjusts the two corresponding tests
(M424-008__no_rh_check_keyword, and P426-035__no_precommit_check_in_rh)
to verify that the relaxed requirement is actually relaxed.

Part of OA23-034.
2017-03-17 14:25:55 -07:00
Joel Brobecker
e70a745ab5 Handle filenames with special characters properly
For Q224-008.
2017-02-27 08:54:09 +01:00
Joel Brobecker
b427e31c30 remove hard-coded attribute name in call to git.check_attr 2017-02-27 08:54:08 +01:00
Joel Brobecker
918f24dc73 notes_parasite: Adjust expected output following git version upgrade
(version 2.9.3)
2017-02-27 08:54:06 +01:00