{"id":15013958,"url":"https://github.com/mattiasgeniar/puppet-pre-commit-hook","last_synced_at":"2025-04-12T05:53:23.863Z","repository":{"id":40909901,"uuid":"9810417","full_name":"mattiasgeniar/puppet-pre-commit-hook","owner":"mattiasgeniar","description":"A Puppet pre-commit hook to validate syntax","archived":false,"fork":false,"pushed_at":"2022-06-28T07:19:39.000Z","size":47,"stargazers_count":59,"open_issues_count":2,"forks_count":36,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-12T05:53:13.952Z","etag":null,"topics":["git","pre-commit","puppet"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattiasgeniar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-02T09:58:29.000Z","updated_at":"2024-10-16T14:38:09.000Z","dependencies_parsed_at":"2022-09-14T22:55:25.162Z","dependency_job_id":null,"html_url":"https://github.com/mattiasgeniar/puppet-pre-commit-hook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattiasgeniar%2Fpuppet-pre-commit-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattiasgeniar%2Fpuppet-pre-commit-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattiasgeniar%2Fpuppet-pre-commit-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattiasgeniar%2Fpuppet-pre-commit-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattiasgeniar","download_url":"https://codeload.github.com/mattiasgeniar/puppet-pre-commit-hook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525156,"owners_count":21118616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","pre-commit","puppet"],"created_at":"2024-09-24T19:45:00.070Z","updated_at":"2025-04-12T05:53:23.843Z","avatar_url":"https://github.com/mattiasgeniar.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"A Puppet pre-commit hook\n========================\n\nThis is inspired/editted from the pre-commit hook found on the following blog: http://techblog.roethof.net/puppet/a-puppet-git-pre-commit-hook-is-always-easy-to-have/\n\nAll credits should really go to Ronny Roethof, I merely editted it and added some ERB template checking.\n\nThe code is made available here under the MIT license.\n\nWhat does this do?\n-----------------\n\nFor every commit you make into your repository, this script will check the syntax of your code (both Puppet (.pp) and Ruby Templates (.erb)) to make sure they are valid. This does not check the actual workings of your Puppet code, you should look into rspec or cucumber testing for that.\n\nIf any invalid syntax is found, it will abort the commit and you won't be able to commit your faulty code that will break production. Yay!\n\nInstallation\n------------\n\nGo to your git repository, create the file .git/hooks/pre-commit and place the content of this repo in it. Make it execute (chmod +x $file).\n\nThere is also a simple installer provided called `install`. Provide a directory that contains your puppet repositories (default: `..`). Running this will attempt symlink the `.git/hooks/pre-commit` to this hook in all directories at the specified location without regard to whether it is a valid git repository. This may simplify installation when you have multiple puppet repos in the same directory.\n\n```\n$ ./install ~/git/puppet/\nInstalling hook to all directories underneath /home/rnelson0/git/puppet/\nAdding hook to directory controlrepo\nAdding hook to directory custom_facts\nAdding hook to directory profile\nAdding hook to directory role\nSetting the executable bit on the hook.\nInstallation complete.\n\n```\n\nPDK vs Bundler\n--------------\n\nThe pre-commit hook attempts to auto-detect the availability of the PDK or a bundler setup, with a preference for the PDK. If you have the PDK installed but prefer to use bundler, you may override the default behavior by:\n* Creating `~/.prefer_bundler` (global override)\n* Creating `./.prefer_bundler` (override only in the current directory)\n* Set `PREFER_BUNDLER` to any non-null value (override only for the current command/shell instance)\n\nWhat does it look like ?\n------------------------\n\nEvery commit will check the changed files and will report on them as such.\n\n\u003cpre\u003e $ git commit modules/name/ -m \"Your commit message\"\n\n*** Checking puppet code for style ***\nPASSED: modules/name/manifests/init.pp\nPASSED: modules/name/tests/init.pp\n\n*** Checking puppet manifest syntax ***\nPASSED: modules/name/manifests/init.pp\nPASSED: modules/name/tests/init.pp\n\n*** Checking ruby template(erb) syntax ***\nPASSED: modules/name/templates/template-file.erb\n\nNo Errors Found, Commit ACCEPTED\n[develop adb6889] Your commit message\n 3 files changed, 120 insertions(+)\n  create mode 100644 modules/name/manifests/init.pp\n  create mode 100644 modules/name/templates/template-file.erb\n  create mode 100644 modules/name/tests/init.pp\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattiasgeniar%2Fpuppet-pre-commit-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattiasgeniar%2Fpuppet-pre-commit-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattiasgeniar%2Fpuppet-pre-commit-hook/lists"}