git hooks for php developers
DESCRIPTION
Git hooks are scripts that are executed by Git before/after events such as: commit, push, and receive. Git hooks are a built-in feature so there is need to download or install anything. Git hooks helps you to improve your programming skills. Additionally, they help teams to setup and apply rules for the development cycle.TRANSCRIPT
Umut IŞIK
Git HooksThe lion tamer
▪The Case
▪The Problem
▪The Purpose
▪Git Hooks
▪Personal Experience
▪Discussion
Agenda
Life Of Developer
▪Code
▪Bug Fix
▪Refactor
▪Work with Multiple Developers
▪Merge
▪Deadline
1. The Case
Poor Pi
1. The Case
▪Pi is the developer
▪Boat is the software development
▪Storm, ocean, sun, etc are the challanges
▪Survival is the requirement
▪Tiger is the habbits
1. The Case
What we do?
▪ Implementation ▪ New Feature
▪ Bug Fix
▪Commit▪ ‘git commit –a’
2. The Problem
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
Aristotle
2. The Problem
Habbits
▪ Implementation▪ Coding standards
▪ Code Comments
▪ Naming convention
▪ Unused variable
▪ Copy/Paste
2. The Problem
Habbits
▪Commit▪ Tests
▪ Team members
▪ The number of files
▪ Case / Story ID
2. The Problem
Confession Time
2. The Problem
▪We are a little bit lazy.
2. The Problem
The ego
▪The all code is crap, except mine, attitude.
2. The Problem
A Second Miracle
▪The “I fix that in a second” catastrophe.
▪The “That will only take a second” misconception.
2. The Problem
We do not
▪obey coding standards
▪check unused variables
▪write comments
2. The Problem
We like
▪copy paste
2. The Problem
We commit without checking
▪Unit Tests
▪ team members
2. The Problem
▪Bad habbits will kill you soon…
2. The Problem
▪Try to have good habbits
3. The Purpose
▪Setup better rules (good habbits ☺ )
▪Fource yourself to obey the new rules
3. The Purpose
Fire custom scripts when certain actions occured
▪Client-Side
▪Server-Side
4. Git Hooks
Installation
▪Nothing todo
▪ .git/hooks folder
▪Shell scripts
▪Custom scripts with Phyton, Ruby, PHP or whatever ..
▪Not interactive ☹
4. Git Hooks
Client-Side
▪Committing Workflow
▪E-mail Workflow
▪Other
4. Git Hooks
▪Committing Workflow▪ pre-commit
▪ prepare-commit-msg
▪ commit-msg
▪ post-commit
▪Email Workflow▪ applypatch-msg
▪ pre-applypatch
▪ post-applypatch
4. Git Hooks
▪Other▪ pre-rebase
▪ post-merge
▪ post-checkout
4. Git Hooks
▪Server-side▪ pre-receive
▪ post-recieve
▪ update
4. Git Hooks
Bad habbits
▪Unused variable
▪Copy-Paste
▪Unit Test
▪Commit comments
4. Personal Experience
Check my code before commit
▪Use «pre-commit» hook▪ Fired before commit
▪ Can stop commit process
4. Personal Experience
«php -l» syntax check
▪Syntax errors
▪Unused variables
4. Personal Experience
«phpcpd» tool
▪Copy/Paste Detector (CPD) for PHP code
4. Personal Experience
PHPCodesniffer
▪PHP, JavaScript and CSS files
▪Detects violations of a defined set of coding standards
4. Personal Experience
▪«pre-commit» hook
4. Personal Experience
Commit message
▪«prepare-commit-msg» hook▪ Fired before comment editor
▪ You can change default message
▪«commit-msg» hook▪ Validate commit comment
4. Personal Experience
Improvement
▪Check view files for XSS
▪Check test implementation for methods
▪Check log implementation
▪Check if test the test suite failed because of my commit
▪Validate Jira/Mingle case id
4. Personal Experience
5. Discussion ☺