Upgrade to Pro — share decks privately, control downloads, hide ads and more …

All about GIT hooks

All about GIT hooks

A 30mins presentation about GIT hooks

C66dbce1b5c38aabd56bd6d3ef3d29fb?s=128

Ifeora Okechukwu

October 15, 2016
Tweet

Transcript

  1. GIT HOOKS FOR WEB APPLICATIONS For Teams and Solo Development

    By Patrick Ifeora Okechukwu
  2. ABOUT THE SPEAKER • Twitter – https://www.twitter.com/isocroft • Facebook –

    https://www.facebook.com/ifeora.okechukwu • GitHub – https://www.github.com/isocroft Unrepentant Internet addict and Head of e-learning @ CollegeMobile and Blogger @ http://blog.coolandcodes.com #BestPractices #DevOps #ScalableArchitecture
  3. AGENDA • What is a HOOK? (software hook) • What

    is a GIT HOOK? • Types of GIT HOOKS? • Types of Repo HOOKS • How to implement Repo HOOKS (PHP, PowerShell, Bash) • Types of Web HOOKS? • How to implement Web HOOKS (PHP, .NET, JAVA) • Closing Off • Q/A
  4. UP TO SPEED WITH GIT • https://guides.github.com/activities

  5. WHAT IS A HOOK? In computer programming, the term hooking

    covers a range of techniques used to alter or augment the behavior of an operating system, of applications, or of other software components by intercepting function calls or messages or events passed between software components. Code that handles such intercepted function calls, events or messages is called a "hook". Hooking is used for many purposes, including debugging and extending functionality. Examples might include intercepting keyboard or mouse event messages before they reach an application, or intercepting software and/or operating system calls in order to monitor behavior or modify the function of an application or another component. SOURCE: WIKIPEDIA.ORG
  6. WHAT IS A GIT HOOK ? GIT hooks are scripts

    that GIT executes before or after events such as: commit, push, and receive. GIT hooks are a built-in feature - no need to download anything. GIT hooks are run locally (sometime run online). These hook scripts are only limited by a developer's imagination. SOURCE: GITHOOKS.COM
  7. TYPES OF GIT HOOKS REPO HOOKS These are hooks that

    are prepared and controlled on the local version of a GIT repository for intercepting and modifying the behavior of events (i.e. push, commit, merge, rebase) for the benefit of adding more functionality to how GIT processes the codebase. These hooks are used for linting, spellchecking, copying and replacing files, running task runners, sending emails for patch review, style sta dard adhere e, ru i g lo al u it tests a d uild (if you do ’t a t to use paid CI (Continuous Integration) engines for testing and build). WEB HOOKS These are hooks that are prepared and controlled on remote GIT (GitHub). These hooks are used for auto ati uploads to a li e e ser er, ssh-ing i to a re ote ser er e.t.c. They are also referred to as HTTP callbacks.
  8. TYPES OF REPO HOOKS • post-commit (local) • pre-rebase (local)

    • pre-commit (local) • pre-push (local) • post-merge (local) • post-push (local) • pre-applypatch (mail) • post-applypatch (mail) • prepare-commit-msg • post-checkout • commit-msg • pre-receive (server) • post-receive (server) • post-rewrite • post-update (server)
  9. IMPLEMENTING REPO HOOKS Repo hooks can be implemented in any

    language Python, PHP, PowerShell, Bash e.t.c. Example code can be found at https://github.com/isocroft/t alk-on-githooks
  10. PYTHON LINTING https://github.com/sebdah/git-pylint-commit-hook/blob/master/git- pylint-commit-hook

  11. PHP LINITNG https://github.com/sjparkinson/static-review

  12. JAVASCRIPT GRUNT TASK HOOKS https://github.com/nlf/precommit-hook

  13. TYPES OF WEB HOOKS • Push • Pull Request •

    Commit Comment • Issue Comment • Fork • Branch Creation • Branch Deletion • Release Publish • Page Build • Watch
  14. SETTING UP A GIT WEBHOOK

  15. SETTING UP A GIT WEBHOOK

  16. IMPLEMENTING WEB HOOKS Example code can be found at https://github.com/isocroft/talk-on-githooks

  17. THANKS FOR LISTENING Hope you start/keep using GIT hooks soon!!