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

Ifeora Okechukwu

October 15, 2016
Tweet

More Decks by Ifeora Okechukwu

Other Decks in Technology

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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.
  6. 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)
  7. 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
  8. TYPES OF WEB HOOKS • Push • Pull Request •

    Commit Comment • Issue Comment • Fork • Branch Creation • Branch Deletion • Release Publish • Page Build • Watch