git hooks for php developers

34
Umut IŞIK Git Hooks The lion tamer

Upload: umut-isik

Post on 20-Jun-2015

213 views

Category:

Technology


6 download

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

Page 1: Git hooks For PHP Developers

Umut IŞIK

Git HooksThe lion tamer

Page 2: Git hooks For PHP Developers

▪The Case

▪The Problem

▪The Purpose

▪Git Hooks

▪Personal Experience

▪Discussion

Agenda

Page 3: Git hooks For PHP Developers

Life Of Developer

▪Code

▪Bug Fix

▪Refactor

▪Work with Multiple Developers

▪Merge

▪Deadline

1. The Case

Page 4: Git hooks For PHP Developers

Poor Pi

1. The Case

Page 5: Git hooks For PHP Developers

▪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

Page 6: Git hooks For PHP Developers

What we do?

▪ Implementation ▪ New Feature

▪ Bug Fix

▪Commit▪ ‘git commit –a’

2. The Problem

Page 7: Git hooks For PHP Developers

We are what we repeatedly do. Excellence, then, is not an act, but a habit.

Aristotle

2. The Problem

Page 8: Git hooks For PHP Developers

Habbits

▪ Implementation▪ Coding standards

▪ Code Comments

▪ Naming convention

▪ Unused variable

▪ Copy/Paste

2. The Problem

Page 9: Git hooks For PHP Developers

Habbits

▪Commit▪ Tests

▪ Team members

▪ The number of files

▪ Case / Story ID

2. The Problem

Page 10: Git hooks For PHP Developers

Confession Time

2. The Problem

Page 11: Git hooks For PHP Developers

▪We are a little bit lazy.

2. The Problem

Page 12: Git hooks For PHP Developers

The ego

▪The all code is crap, except mine, attitude.

2. The Problem

Page 13: Git hooks For PHP Developers

A Second Miracle

▪The “I fix that in a second” catastrophe.

▪The “That will only take a second” misconception.

2. The Problem

Page 14: Git hooks For PHP Developers

We do not

▪obey coding standards

▪check unused variables

▪write comments

2. The Problem

Page 15: Git hooks For PHP Developers

We like

▪copy paste

2. The Problem

Page 16: Git hooks For PHP Developers

We commit without checking

▪Unit Tests

▪ team members

2. The Problem

Page 17: Git hooks For PHP Developers

▪Bad habbits will kill you soon…

2. The Problem

Page 18: Git hooks For PHP Developers

▪Try to have good habbits

3. The Purpose

Page 19: Git hooks For PHP Developers

▪Setup better rules (good habbits ☺ )

▪Fource yourself to obey the new rules

3. The Purpose

Page 20: Git hooks For PHP Developers

Fire custom scripts when certain actions occured

▪Client-Side

▪Server-Side

4. Git Hooks

Page 21: Git hooks For PHP Developers

Installation

▪Nothing todo

▪ .git/hooks folder

▪Shell scripts

▪Custom scripts with Phyton, Ruby, PHP or whatever ..

▪Not interactive ☹

4. Git Hooks

Page 22: Git hooks For PHP Developers

Client-Side

▪Committing Workflow

▪E-mail Workflow

▪Other

4. Git Hooks

Page 23: Git hooks For PHP Developers

▪Committing Workflow▪ pre-commit

▪ prepare-commit-msg

▪ commit-msg

▪ post-commit

▪Email Workflow▪ applypatch-msg

▪ pre-applypatch

▪ post-applypatch

4. Git Hooks

Page 24: Git hooks For PHP Developers

▪Other▪ pre-rebase

▪ post-merge

▪ post-checkout

4. Git Hooks

Page 25: Git hooks For PHP Developers

▪Server-side▪ pre-receive

▪ post-recieve

▪ update

4. Git Hooks

Page 26: Git hooks For PHP Developers

Bad habbits

▪Unused variable

▪Copy-Paste

▪Unit Test

▪Commit comments

4. Personal Experience

Page 27: Git hooks For PHP Developers

Check my code before commit

▪Use «pre-commit» hook▪ Fired before commit

▪ Can stop commit process

4. Personal Experience

Page 28: Git hooks For PHP Developers

«php -l» syntax check

▪Syntax errors

▪Unused variables

4. Personal Experience

Page 29: Git hooks For PHP Developers

«phpcpd» tool

▪Copy/Paste Detector (CPD) for PHP code

4. Personal Experience

Page 30: Git hooks For PHP Developers

PHPCodesniffer

▪PHP, JavaScript and CSS files

▪Detects violations of a defined set of coding standards

4. Personal Experience

Page 31: Git hooks For PHP Developers

▪«pre-commit» hook

4. Personal Experience

Page 32: Git hooks For PHP Developers

Commit message

▪«prepare-commit-msg» hook▪ Fired before comment editor

▪ You can change default message

▪«commit-msg» hook▪ Validate commit comment

4. Personal Experience

Page 33: Git hooks For PHP Developers

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

Page 34: Git hooks For PHP Developers

5. Discussion ☺