Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #79 - correctly pass future parser option #91

Merged
merged 2 commits into from Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -103,3 +103,17 @@ fi
```

Additionally you can call pre-commit script with two options `-s` and `-a`. First one silence standard informations, which file is currently being checked. Second one allow you to check whole repo, not only files changed locally.

Configuration
===============
You can set configuration options in commit_hooks/config.cfg
This file is sourced by the pre-commit/receive hooks.

Current options:
* CHECK_PUPPET_LINT
* USE_PUPPET_FUTURE_PARSER (only used by Puppet < 4)
* CHECK_INITIAL_COMMIT
* CHECK_RSPEC
* PUPPET_LINT_OPTIONS
* PUPPET_LINT_FAIL_ON_WARNINGS
* UNSET_RUBY_ENV (for GitLab users)
7 changes: 6 additions & 1 deletion pre-commit
Expand Up @@ -42,6 +42,11 @@ if [[ -f "$git_root/.git" ]]; then
fi
fi

# Only puppet 3.2.1 - 3.8 support "--parser future" option.
case $(puppet --version) in
4*) USE_PUPPET_FUTURE_PARSER="disabled" ;;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add some information about it to documentation, as now you will need to dig in code to find out, that you can enable it somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not add that feature, I just extended it to work in pre-commit hook aswell (previously it only worked in pre-receive hook); but I'll happyly add a short description in readme later today :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, feature was quite undocumented, but cool that now it's there. Thanks for it!

esac

# Decide if we want puppet-lint
CHECK_PUPPET_LINT="enabled"
if [[ -e ${subhook_root}/config.cfg ]] ; then
Expand All @@ -68,7 +73,7 @@ for changedfile in $files_to_check; do
failures=$((failures + 1))
fi
elif [[ $(echo "$changedfile" | grep -q '\.*\.pp$'; echo $?) -eq 0 ]]; then
${subhook_root}/puppet_manifest_syntax_check.sh "$changedfile"
${subhook_root}/puppet_manifest_syntax_check.sh "$changedfile" "" "$USE_PUPPET_FUTURE_PARSER"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with the empty "" after $changedfile ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$2 is module dir (https://github.com/drwahl/puppet-git-hooks/blob/master/commit_hooks/puppet_manifest_syntax_check.sh)
but its not used with the pre-commit hook; only with the pre-receive hook

RC=$?
if [[ "$RC" -ne 0 ]]; then
failures=$((failures + 1))
Expand Down