Slide 1

Slide 1 text

GIT HOOKS FOR WEB APPLICATIONS For Teams and Solo Development By Patrick Ifeora Okechukwu

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

UP TO SPEED WITH GIT • https://guides.github.com/activities

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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.

Slide 8

Slide 8 text

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)

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

PYTHON LINTING https://github.com/sebdah/git-pylint-commit-hook/blob/master/git- pylint-commit-hook

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

TYPES OF WEB HOOKS • Push • Pull Request • Commit Comment • Issue Comment • Fork • Branch Creation • Branch Deletion • Release Publish • Page Build • Watch

Slide 14

Slide 14 text

SETTING UP A GIT WEBHOOK

Slide 15

Slide 15 text

SETTING UP A GIT WEBHOOK

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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