summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Add a 'pre-push' hookhooksBrad King2014-09-102-1/+25
| | | | For now do nothing but chain to a project-specific hook.
* Add .gitattributes to tell git to use LF newlinesBrad King2014-07-071-0/+2
| | | | | | These hook scripts execute with bash and need LF newlines. Set eol=lf to get LF newlines even when core.autocrlf is enabled. While at it, also enable whitespace=indent-with-non-tab.
* commit-msg: Remove MERGE_HEAD check from msg_is_mergeBen Boeckel2013-04-161-1/+0
| | | | | | | | When using "git commit --amend" to edit a merge commit message the MERGE_HEAD is long gone. Also, some Git versions remove this file before the commit-msg hook is called. In either case we should still allow long summary lines that start in 'Merge ' just as we do for 'Revert '.
* Load project-specific "start" hooks before our checksBrad King2013-04-044-0/+15
| | | | | | | | | | Read from the project ".hooks-config" a configuration value hooks.start.commit-msg hooks.start.pre-commit hooks.start.prepare-commit-msg to run from our respective hook before its main checks.
* hooks-config: Factor child execution out of hooks_chainBrad King2013-04-041-4/+9
| | | | | Factor child execution into a separate "hooks_child" function so it can be re-used.
* hooks-config: Read 'git config' values from project .hooks-configBrad King2013-04-041-0/+11
| | | | | | Allow projects to configure hooks with a 'git config'-formatted file at the top of their source tree called ".hooks-config". This avoids use of bash-specific syntax and makes configuration declarative.
* hooks-config: Subsume hooks-chain functionalityBrad King2013-04-045-36/+16
| | | | Remove hooks-chain.bash and place its content in hooks-config.bash.
* Make all hook references relative to thier locationChuck Atkins2012-10-104-5/+8
| | | | | | | Some hooks were getting referenced directly via $GIT_DIR/hooks while at other times getting referenced relative via ${BASH_SOURCE%/*}. By making all references relative then these hooks can reside in a different folder and still be daisy-chained by other hooks.
* Set GIT_DIR if not already setBrad King2012-02-294-8/+13
| | | | | | | | Although it seems reasonable to expect GIT_DIR to be set when hooks are invoked, the "git help hooks" documentation does not guarantee it. On msysGit 1.7.8 (and perhaps others) "git gui" runs prepare-commit-msg without setting GIT_DIR. Set GIT_DIR at the beginning of each commit hook if it is not already set.
* prepare-commit-msg: Add Gerrit Change-Id to mergesBrad King2012-02-061-1/+9
| | | | | | | | The "git merge" command generates its own commit message and does not invoke the commit-msg hook. Fortunately it invokes prepare-commit-msg so teach it to call the gerrit/commit-msg hook for merges. Suggested-by: Chris Harris <chris.harris@kitware.com>
* Merge branch 'itk-hook-cleanup' into hooksBrad King2011-10-240-0/+0
|\
| * Remove pre-commit-style.Matt McCormick2011-10-242-270/+0
| | | | | | | | | | | | | | These pre-commit hooks where added to the ITK specific hook chain since all projects do not use them. Change-Id: Ifcb41645374914c4f30f7c5f2feb2e5d40a4b3e3
| * Remove .txx pre-commit check.Matt McCormick2011-10-241-16/+0
| | | | | | | | | | | | | | | | | | | | This is an ITK specific check. It is already implemented in the ITK Utilities/Hooks/pre-commit script executed in the hook chain. This should allow commiting when on the ITK release branch where .txx files still currently exist. Change-Id: I1115a2129beb89d6657d599aa6e72bb6515dfca3
| * ENH: pre-commit: Prevent add .txx files.Matt McCormick2011-07-191-0/+16
| | | | | | | | | | | | | | A transition occurred in the toolkit to move all .txx files to .hxx files. This prevents accidental additions of or renames to .txx files. Change-Id: Id4ace9cfca2c56506d93396366d146173e015003
* | hooks-chain: Look for chains in project hooks configBrad King2011-10-061-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If a local hook chain rule is not in the local git configuration check for a value defined in .hooks-config.bash: hooks_chain_pre_commit hooks_chain_commit_msg hooks_chain_prepare_commit_msg This allows project to configure chained hooks without adding any values to the local git configuration. Since the project hooks config can be versioned with the hook scripts it references this ensures a consistent state.
* | Load local hooks configuration from work treeBrad King2011-10-064-0/+26
| | | | | | | | | | | | Look for a ".hooks-config.bash" file at the top of the work tree. Load it in each hook to get per-project configuration. Currently we do not define any config options, but this adds the framework.
* | pre-commit: Remove KWStyle and uncrustify supportBrad King2011-10-062-270/+0
|/ | | | | These checks can be added in projects that want them using the pre-commit hook chaining.
* pre-commit-style: Fix exit code on failureBrad King2011-06-141-4/+4
| | | | | The return code from 'die' was absorbed inside a subshell on the right-hand side of a pipeline. Propagate it out to the main script.
* pre-commit: Disallow submodule rewindBrad King2011-01-261-1/+47
| | | | | Reject commits that rewind a submodule relative to any parent (HEAD or MERGE_HEAD).
* pre-commit: Allow merged submodule updatesBrad King2011-01-261-0/+8
| | | | | | If "git merge" brings in a submodule update then allow it without requiring the extra step added in commit 48e72dd1 (Check submodules staged with other changes, 2010-08-10).
* Update copyright notices for year 2011Brad King2011-01-136-6/+6
|
* commit-msg: Do not advise use of COMMIT_MSG after removalBrad King2011-01-111-4/+7
| | | | | Once our temporary COMMIT_MSG file has been removed do not advise the author to use the file to continue editing the message.
* commit-msg: Allow Change-Id only in footerBrad King2010-12-301-1/+9
| | | | Gerrit recognizes the Change-Id line only if it appears in the footer.
* pre-commit: Add whitespace check "no-lf-at-eol"Brad King2010-12-301-0/+12
|
* pre-commit: Generalize custom whitespace checkBrad King2010-12-301-11/+15
| | | | | | Lookup the whitespace attribute for each modified file and dispatch custom checks as necessary. Currently the only custom check is the approximate tab-in-indent check for Git < 1.7.2.
* commit-msg: Allow long first lines starting in "Revert "Brad King2010-11-171-1/+5
| | | | | | | Revert commits always have longer first lines than the commit they revert. Do not reject those that happen to go over the threshold. It is much simpler if the "git revert" command creates the commit without error.
* Chain to script configured by "hooks.chain-<hook>"Brad King2010-11-164-0/+62
| | | | | | | | Chain the pre-commit, commit-msg, and prepare-commit-msg hooks to locally configured scripts. Interpret relative paths with respect to the working directory where the hooks run (top of work tree). This allows project setup scripts to add project-specific checks for each of these hooks.
* Merge branch 'kwstyle-non-blocking' into hooksBrad King2010-11-051-7/+21
|\
| * make the check for KWStyle executable non blockingGaëtan Lehmann2010-11-031-7/+21
|/ | | | | | | | | | | At this time, a contributor won't be able to commit a change if KWStyle is not installed on the computer. KWStyle is not a very common program, and so is likely to have to be installed by hand. This increase the work needed to be able to contribute to ITK. With this change a warning is displayed if KWStyle is not installed but the commit is not blocked. Change-Id: I0719ee5ac6e048120504bbdc4dc022043c0f0ded
* Merge branch 'style-checks' into hooksBrad King2010-09-272-0/+258
|\
| * pre-commit: Apply uncrustify and KWStyle check for modified files.Matt McCormick (thewtex)2010-09-272-0/+258
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | uncrustify (uncrustify.sourceforge.net) is applied to changed files prior to commit. This feature is off by default. To enable this behavior, set git config hooks.uncrustify true By default, the behavior of git-mergetool is used to review the changes uncrustify makes before they are added to the commit. For more information on this behavior, see git help mergetool KWStyle is run on the changed C++ files and the commit is aborted if the files do not pass the test. A file similar to the original is saved with a '*.kws' extension so that line numbers referenced in the error message can be examined. The test is off by default. To enable this behavoir, set git config hooks.KWStyle true Project specific uncrustify and KWStyle configuration files are set with 'git config'. For example, git config hooks.uncrustify.conf path/to/uncrustify.conf git config hooks.KWStyle.conf path/to/KWStyle.conf git config hooks.KWStyle.overwriteRulesConf path/to/overwrite.conf # optional If the appropriate values have not been set, die() is called. An optional KWStyle overwrite rules file can also been configured. The files on which to run the style checks must also be identified in the repository's '.gitattributes'. For example, *.h hooks.style *.cpp hooks.style Or, to only enable a subset of style hooks, *.h hooks.style=KWStyle *.cpp hooks.style=KWStyle,uncrustify Change-Id: Ia6b2d4136af3002eb0ec5d36f03c50df928917f4
* pre-commit: Allow submodule check to be disabledBrad King2010-09-151-1/+9
| | | | | | | If hooks.submodule is 'false' disable all checks. If an individual hooks.<module>.update is 'true' then accept any update for that module. Leave these options out of the hints printed. Developers that know what they are doing will be able to find them by reading the hook source.
* commit-msg: Allow long merge commit subject linesBrad King2010-09-141-1/+6
| | | | | Merge commits can have long subject lines because they name other branches. Accept such messages as a special case for merge commits.
* commit-msg: Fix silent failure when no remote looks like GerritBrad King2010-08-311-1/+1
|
* commit-msg: Invoke gerrit/commit-msg if hooks.GerritId=trueBrad King2010-08-301-1/+41
| | | | | Add a Gerrit Change-Id header if hooks.GerritId is true. Print help if the option is not set and a remote URL looks like Gerrit.
* commit-msg: Simplify newlines in die() callsBrad King2010-08-301-7/+5
|
* gerrit/commit-msg: Report added Change-IdBrad King2010-08-301-0/+1
|
* gerrit/commit-msg: Reference bash in shebang lineBrad King2010-08-301-1/+1
| | | | This script uses bashisms like $() so we need a real bash.
* Add commit-msg hook from Gerrit Code ReviewBrad King2010-08-302-0/+107
| | | | | Currently the hook is unused but later we will invoke it from the main commit-msg hook.
* pre-commit: Approximate Git 1.7.2 tab-in-indent checkBrad King2010-08-301-23/+20
| | | | | Check for leading TABs in files marked with the whitespace=tab-in-indent attribute instead of hard-coding a list of file extensions.
* Add Apache 2.0 LICENSE and copyright NOTICEBrad King2010-08-274-0/+237
|
* Remove out-dated instructionsBrad King2010-08-272-4/+0
|
* pre-commit: Allow .gitattributes to limit file sizeBrad King2010-08-251-4/+39
| | | | | Check for a 'hooks.MaxObjectKiB' attribute to set the limit of specific files or patterns.
* pre-commit: Check submodules staged with other changesBrad King2010-08-101-3/+61
| | | | | | | | | | | | | | Since Git does not automatically update submodule checkouts when checking out a new version in the work tree, it is common to have locally modified submodule references. Therefore it is easy to stage such modifications with other changes by accident, especially with commands like "git add -u" or "git commit -a". The result is almost always wrong if the submodule change is not intended. Prevent such mistakes by requiring an extra step to commit submodule link updates with other changes. When this case is detected, print a message describing the situation and provide cut-and-paste instructions to proceed.
* Reference bash explicitly in shebang linesGaëtan Lehmann2010-08-032-2/+2
| | | | | | | | | | On Solaris, where /bin/sh is actually sh, not bash, some expressions like $() are not supported. Git's own scripts on this machine are configured to use "#!/bin/bash". Change our shebang line to #!/usr/bin/env bash which should work almost everywhere.
* commit-msg: Reject leading or trailing space on first lineBrad King2010-06-161-1/+5
|
* pre-commit: Check file size alwaysBrad King2010-06-071-2/+3
| | | | | Fix logic to call check_size for all updated index entries, not just those whose mode changed.
* pre-commit: Check file sizesBrad King2010-06-071-1/+19
| | | | | | | | | Check blob and tree object sizes to prevent large objects from entering the repository. The default limit is 1024 KiB, but it can be set with git config hooks.MaxObjectKiB $KiB locally, or disabled by using 0 KiB.
* pre-commit: Rename looks_executable -> mode_looks_exeBrad King2010-06-071-3/+3
| | | | Keep all mode-related check helpers in the "mode_" namespace.
* pre-commit: Check file modesBrad King2010-05-201-0/+39
| | | | | | | Check new files and files whose mode changes to verify that each file mode matches the content of the file. The mode of a file must be executable if and only if the file looks executable (name ends in a Windows executable extension or content starts with a shebang line).