SlideShare a Scribd company logo
Safe Git::Hooks Installation 
Git Hooks with Plenv and Carton 
Mikko Koivunalho 
NORDIC PERL WORKSHOP 2014 
Nov 17th, 2014 / Helsinki
Outline 
Introduction 
Our Problem 
Solution 
Our Tools 
Last 
Questions 
SubGit
Git and Perl 
Git and Perl go hand-in-hand. 
I some parts of Git are made with Perl.
Git Hooks 
I Common to many Version Control Systems, also Git has a way to
re o custom scripts when certain important actions occur. These 
are called hooks. 
I There are two groups of these hooks: client-side and server-side. 
Client-side hooks are triggered by operations such as committing 
and merging, while server-side hooks run on network operations such 
as receiving pushed commits. 
I We want to use the hooks mechanism to some actions! 
I De
ne our needs: 
1. Only client side hooks. 
2. Must be expandable. 
3. Must not touch the client's system (speci
cally, system Perl).
Solution? 
I We need a solution which is: 
expandable Easy to develop further and easy to deploy improments to it. 
friendly Easy for user to take into use. 
maintainable Automatically install new versions into client's system. 
invisible Cover our tracks, i.e. hide Perl away.
Go on. . . 
Let's build that!
Git::Hooks 
Framework for Git Hooks 
I CPAN: Git::Hooks 
I Framework for implementing Git (and Gerrit) hooks 
I Author: Gustavo L. de M. Chaves gnustavo@cpan.org 
I https://metacpan.org/release/Git-Hooks 
I Git::Hooks provides several hooks out-of-the-package. We just need 
to get Git::Hooks running.
Plenv 
I Plenv 
I Perl binary manager. (Create virtual Perl environments: Installs any 
Perl version and keeps the Perls and their corresponding CPAN 
installations from getting mixed.) 
I Author: Tokuhiro Matsuno 
I https://github.com/tokuhirom/plenv/ 
I Installation: Clone the Git repository and set global path. 
I Alternative installation: Use anyenv from 
https://github.com/riywo/anyenv.git. Get Ruby, Python, 
Java, Lua, Go environments in the bargain.
Carton 
I Carton 
I Perl module dependency manager. Download and install CPAN 
modules locally in directory 'local'. Isolate the installation so you 
always run the same versions. 
I Author: Tatsuhiko Miyagawa 
I https://metacpan.org/pod/Carton 
I Installation: Install via plenv. 
I Alternative installation: Use anyenv from 
https://github.com/riywo/anyenv.git. Get Ruby, Python, 
Java, Lua, Go environments in the bargain.
Repo Layout 
Our empty repository contains: 
/ 
.git 
.git-repo-admin 
.perl-version........................................17 
cpanfile.............................................246 
cpanfile.snapshot................................58165 
local...................| ../.git/git-hooks-carton-local/
Starting Files 
.perl-version (the name of the perl to install with plenv.): 
5.18.4 g i thooks 
cpan
le (Carton seed
le): 
# At l e a s t t h i s Pe r l v e r s i o n ( can be h i g h e r ) : 
r e q u i r e s ' p e r l ' , ' 5 . 1 8 . 4 ' ; 
# The o n l y package we r e a l l y need . 
r e q u i r e s ' Gi t : : Hooks ' , ' 1 . 3 . 0 ' ; 
# P e r l C r i t i c f o r c h e c k i n g the Pe r l code (most r e l a t e d to Gi t 
hooks ) . 
r e q u i r e s ' Pe r l : : C r i t i c ' , ' 1.122 ' ; 
Install: 
cd . . # Step out o f the . p e r l v e r s i o n c o n t r o l l e d ' space ' 
p l e n v i n s t a l l 5 . 1 8 . 4 as=5.18.4 g i thooks 
p l e n v i n s t a l l cpanm ; p l e n v r e h a s h 
cpanm Car ton ; c a r t o n i n s t a l l
Carton at work 
I Running 
carton install 
I
lls the directory 'local' with installed CPAN modules. 
I It also creates a new
le: 'cpan
le.snapshot'. 
I This
le contains a snapshot of the whole 'local' directory: modules, 
their dependencies, the exact versions. 
I Commit both
les 'cpan

More Related Content

What's hot

Effective Benchmarks
Effective BenchmarksEffective Benchmarks
Effective Benchmarks
Workhorse Computing
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
charsbar
 
Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?
Kirill Chebunin
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Zyxware Technologies
 
Productivity tips for developers
Productivity tips for developersProductivity tips for developers
Productivity tips for developers
Sebastian Witowski
 
plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6
Nobuo Danjou
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with Ruby
Nikhil Mungel
 
Eat my data
Eat my dataEat my data
Eat my data
Peng Zuo
 
2010/7/31 LTの虎@LL Tiger
2010/7/31 LTの虎@LL Tiger2010/7/31 LTの虎@LL Tiger
2010/7/31 LTの虎@LL Tiger
Akihiro Okuno
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
Pavan Devarakonda
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
Nikhil Mungel
 
Publishing a Perl6 Module
Publishing a Perl6 ModulePublishing a Perl6 Module
Publishing a Perl6 Module
ast_j
 
Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6
Workhorse Computing
 
Getting testy with Perl
Getting testy with PerlGetting testy with Perl
Getting testy with Perl
Workhorse Computing
 
Getting Testy With Perl6
Getting Testy With Perl6Getting Testy With Perl6
Getting Testy With Perl6
Workhorse Computing
 
Os Treat
Os TreatOs Treat
Os Treat
oscon2007
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
Rafael Dohms
 

What's hot (20)

Effective Benchmarks
Effective BenchmarksEffective Benchmarks
Effective Benchmarks
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
 
Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
 
Productivity tips for developers
Productivity tips for developersProductivity tips for developers
Productivity tips for developers
 
plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with Ruby
 
Eat my data
Eat my dataEat my data
Eat my data
 
2010/7/31 LTの虎@LL Tiger
2010/7/31 LTの虎@LL Tiger2010/7/31 LTの虎@LL Tiger
2010/7/31 LTの虎@LL Tiger
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
 
Publishing a Perl6 Module
Publishing a Perl6 ModulePublishing a Perl6 Module
Publishing a Perl6 Module
 
Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6
 
Getting testy with Perl
Getting testy with PerlGetting testy with Perl
Getting testy with Perl
 
Getting Testy With Perl6
Getting Testy With Perl6Getting Testy With Perl6
Getting Testy With Perl6
 
Os Treat
Os TreatOs Treat
Os Treat
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
 

Viewers also liked

Webhooks
WebhooksWebhooks
Ironmq slides
Ironmq slidesIronmq slides
Ironmq slides
Mikko Koivunalho
 
Iron.io Technical Overview
Iron.io Technical OverviewIron.io Technical Overview
Iron.io Technical Overview
Chad Arimura
 
Building Event Driven API Services Using Webhooks
Building Event Driven API Services Using WebhooksBuilding Event Driven API Services Using Webhooks
Building Event Driven API Services Using Webhooks
Cloud Elements
 
Web Hooks
Web HooksWeb Hooks
Web Hooks
Jeff Lindsay
 
APIs That Make Things Happen
APIs That Make Things HappenAPIs That Make Things Happen
APIs That Make Things Happen
Jeff Lindsay
 
WebHooks in 10 Minutes
WebHooks in 10 MinutesWebHooks in 10 Minutes
WebHooks in 10 Minutes
Jeff Lindsay
 

Viewers also liked (7)

Webhooks
WebhooksWebhooks
Webhooks
 
Ironmq slides
Ironmq slidesIronmq slides
Ironmq slides
 
Iron.io Technical Overview
Iron.io Technical OverviewIron.io Technical Overview
Iron.io Technical Overview
 
Building Event Driven API Services Using Webhooks
Building Event Driven API Services Using WebhooksBuilding Event Driven API Services Using Webhooks
Building Event Driven API Services Using Webhooks
 
Web Hooks
Web HooksWeb Hooks
Web Hooks
 
APIs That Make Things Happen
APIs That Make Things HappenAPIs That Make Things Happen
APIs That Make Things Happen
 
WebHooks in 10 Minutes
WebHooks in 10 MinutesWebHooks in 10 Minutes
WebHooks in 10 Minutes
 

Similar to Git::Hooks

Rugged Driven Development with Gauntlt
Rugged Driven Development with GauntltRugged Driven Development with Gauntlt
Rugged Driven Development with Gauntlt
James Wickett
 
Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13
Rafael Dohms
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
John Anderson
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
Pablo Godel
 
Sprockets
SprocketsSprockets
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL
John Anderson
 
Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as code
Julian Simpson
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
Rowan Merewood
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
Ben Lin
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf Conference
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
Arto Artnik
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
Leo Lorieri
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con Gitlab
Software Guru
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
Michele Orselli
 
EC2
EC2EC2
Composer: putting dependencies on the score
Composer: putting dependencies on the scoreComposer: putting dependencies on the score
Composer: putting dependencies on the score
Rafael Dohms
 
Composer
ComposerComposer
Composer
Tom Corrigan
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
Alexandre Salomé
 
GitGot: The Swiss Army Chainsaw of Git Repo Management
GitGot: The Swiss Army Chainsaw of Git Repo ManagementGitGot: The Swiss Army Chainsaw of Git Repo Management
GitGot: The Swiss Army Chainsaw of Git Repo Management
John Anderson
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to android
Owen Hsu
 

Similar to Git::Hooks (20)

Rugged Driven Development with Gauntlt
Rugged Driven Development with GauntltRugged Driven Development with Gauntlt
Rugged Driven Development with Gauntlt
 
Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Sprockets
SprocketsSprockets
Sprockets
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL
 
Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as code
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con Gitlab
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
 
EC2
EC2EC2
EC2
 
Composer: putting dependencies on the score
Composer: putting dependencies on the scoreComposer: putting dependencies on the score
Composer: putting dependencies on the score
 
Composer
ComposerComposer
Composer
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
GitGot: The Swiss Army Chainsaw of Git Repo Management
GitGot: The Swiss Army Chainsaw of Git Repo ManagementGitGot: The Swiss Army Chainsaw of Git Repo Management
GitGot: The Swiss Army Chainsaw of Git Repo Management
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to android
 

Recently uploaded

SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
kalichargn70th171
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 

Recently uploaded (20)

SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 

Git::Hooks

  • 1. Safe Git::Hooks Installation Git Hooks with Plenv and Carton Mikko Koivunalho NORDIC PERL WORKSHOP 2014 Nov 17th, 2014 / Helsinki
  • 2. Outline Introduction Our Problem Solution Our Tools Last Questions SubGit
  • 3. Git and Perl Git and Perl go hand-in-hand. I some parts of Git are made with Perl.
  • 4. Git Hooks I Common to many Version Control Systems, also Git has a way to
  • 5. re o custom scripts when certain important actions occur. These are called hooks. I There are two groups of these hooks: client-side and server-side. Client-side hooks are triggered by operations such as committing and merging, while server-side hooks run on network operations such as receiving pushed commits. I We want to use the hooks mechanism to some actions! I De
  • 6. ne our needs: 1. Only client side hooks. 2. Must be expandable. 3. Must not touch the client's system (speci
  • 8. Solution? I We need a solution which is: expandable Easy to develop further and easy to deploy improments to it. friendly Easy for user to take into use. maintainable Automatically install new versions into client's system. invisible Cover our tracks, i.e. hide Perl away.
  • 9. Go on. . . Let's build that!
  • 10. Git::Hooks Framework for Git Hooks I CPAN: Git::Hooks I Framework for implementing Git (and Gerrit) hooks I Author: Gustavo L. de M. Chaves gnustavo@cpan.org I https://metacpan.org/release/Git-Hooks I Git::Hooks provides several hooks out-of-the-package. We just need to get Git::Hooks running.
  • 11. Plenv I Plenv I Perl binary manager. (Create virtual Perl environments: Installs any Perl version and keeps the Perls and their corresponding CPAN installations from getting mixed.) I Author: Tokuhiro Matsuno I https://github.com/tokuhirom/plenv/ I Installation: Clone the Git repository and set global path. I Alternative installation: Use anyenv from https://github.com/riywo/anyenv.git. Get Ruby, Python, Java, Lua, Go environments in the bargain.
  • 12. Carton I Carton I Perl module dependency manager. Download and install CPAN modules locally in directory 'local'. Isolate the installation so you always run the same versions. I Author: Tatsuhiko Miyagawa I https://metacpan.org/pod/Carton I Installation: Install via plenv. I Alternative installation: Use anyenv from https://github.com/riywo/anyenv.git. Get Ruby, Python, Java, Lua, Go environments in the bargain.
  • 13. Repo Layout Our empty repository contains: / .git .git-repo-admin .perl-version........................................17 cpanfile.............................................246 cpanfile.snapshot................................58165 local...................| ../.git/git-hooks-carton-local/
  • 14. Starting Files .perl-version (the name of the perl to install with plenv.): 5.18.4 g i thooks cpan
  • 16. le): # At l e a s t t h i s Pe r l v e r s i o n ( can be h i g h e r ) : r e q u i r e s ' p e r l ' , ' 5 . 1 8 . 4 ' ; # The o n l y package we r e a l l y need . r e q u i r e s ' Gi t : : Hooks ' , ' 1 . 3 . 0 ' ; # P e r l C r i t i c f o r c h e c k i n g the Pe r l code (most r e l a t e d to Gi t hooks ) . r e q u i r e s ' Pe r l : : C r i t i c ' , ' 1.122 ' ; Install: cd . . # Step out o f the . p e r l v e r s i o n c o n t r o l l e d ' space ' p l e n v i n s t a l l 5 . 1 8 . 4 as=5.18.4 g i thooks p l e n v i n s t a l l cpanm ; p l e n v r e h a s h cpanm Car ton ; c a r t o n i n s t a l l
  • 17. Carton at work I Running carton install I
  • 18. lls the directory 'local' with installed CPAN modules. I It also creates a new
  • 21. le contains a snapshot of the whole 'local' directory: modules, their dependencies, the exact versions. I Commit both
  • 24. le.snapshot' to the repository. I When installing to a virgin environment, run carton install {deployment I and Carton will not use the seed
  • 26. le' but instead the snapshot
  • 27. le to restore the exact same environment.
  • 28. An Isolated Perl I An isolated Perl environment maintained by
  • 29. les '.perl-version' (plenv) and directory 'local' (carton). I Uses only plenv installed modules. I You can even limit yourself to Carton installed modules: I Run carton exec perl-program.pl I Carton has already installed Git::Hooks. Now let's set it up.
  • 30. Hooking into Git I The actual Git hooks are located in the '.git/hooks' subdirectory in the repo root. Create a symbolic link from every hook you want to activate to the '.git-repo-admin' directory. E.g. ln -s .git-repo-admin/git-hooks.sh .git/hooks/commit-msg I Link the Git con
  • 33. g' to
  • 35. g hooks.local': I Add the following rows to
  • 38. g hooks I and create a symbolic link from the
  • 40. g hooks' to the corresponding
  • 42. g hooks.local': ln -s .git-repo-admin/con
  • 44. g hooks I Use the
  • 46. g hooks.local' like a normal Git con
  • 47. g
  • 48. le. Add it to the version control and thereby make it every client's con
  • 49. g
  • 52. git-hooks.sh: Bash Part #! / u s r / b i n / env bash REPO DIR=$ (pwd) HOOK NAME=$fBASH SOURCEg # Ac t u a l l y hooks/hook name SOURCE=$fBASH SOURCE[ 0 ] g wh i l e [ h $SOURCE ] ; do # r e s o l v e $SOURCE u n t i l the f i l e i s no l o n g e r a s yml i n k DIR=$ ( cd P $ ( di rname $SOURCE ) pwd ) SOURCE=$ ( r e a d l i n k $SOURCE ) [ [ $SOURCE != / ] ] SOURCE=$DIR/$SOURCE # i f $SOURCE was a r e l a t i v e s yml ink , we need to r e s o l v e i t r e l a t i v e to the path where the s yml i n k f i l e was l o c a t e d done THIS SCRIPT=$fSOURCEg DIR=$ ( cd P $ ( di rname $SOURCE ) pwd ) cd $fDIRg i f [ e g i thookshook . sh ] ; then s o u r c e . / g i thookshook . sh ; f i CMD= e x e c c a r t o n e x e c p e r l x $fTHIS SCRIPTg $fREPO DIRg $f HOOK NAMEg $@ i f [ $VERBOSE = 1 ] ; then echo CMD=$fCMDg ; f i $fCMDg # End o f Bash s c r i p t
  • 53. git-hooks.sh: Perl Part # S t a r t o f Pe r l s c r i p t #! / u s r / b i n / env p e r l us e s t r i c t ; us e wa rning s ; my $ v e r b o s e = 0 ; $ v e r b o s e = $ENVf 'VERBOSE ' g i f d e f i n e d $ENVf 'VERBOSE ' g ; my $ r e p o d i r = s h i f t @ARGV; my $hook name = s h i f t @ARGV; c h d i r $ r e p o d i r ; p r i n t g i thooks . sh ( p l ) now i n d i r ' $ r e p o d i r ' . n n i f ( $ v e r b o s e ) ; my $ s u b g i t c h a n g e = $hook name =~ s /n/( us e r ) ( [ ^ n / ]+) /n/ $2/ msx ; i f ( $ s u b g i t c h a n g e ) f p r i n t Thi s i s SubGi t repo , removed ' us e r ' f rom hooks name . n n i f $ v e r b o s e ; g us e Gi t : : Hooks ; p r i n t Ex e c u t i n g : run hook ( $hook name , @ARGV) nn i f ( $ v e r b o s e ) ; run hook ( $hook name , @ARGV) ;
  • 54. Small Things left I If you think it is not good to have the directory '.git-repo-admin/local' oating freely in the repository, turn it into a symbolic link and move the directory itself under '.git' directory. I Set up additional hooks into directory '.git-repo-admin/hooks.d.local'.
  • 55. con
  • 56. g hooks.local [githooks] plugin = CheckLog plugin = CheckFile hooks = hooks.d [githooks checklog] title-required = 1 title-max-widt = 50 title-period = allow spelling = 1 spelling-lang = EN [githooks check
  • 57. le] name = *.p[lm] cd .git-repo-admin; carton exec perlcritic {harsh fg
  • 58. What we Have in Repo. / .gitignore config hooks ....| ../.git-repo-admin/con
  • 59. g hooks.local hooks/commit-msg.....| ../.git-repo-admin/git-hooks.sh .git .git-repo-admin .perl-version........................................17 cpanfile.............................................246 cpanfile.snapshot................................58165 git-hooks.sh*......................................1736 config hooks.local..................................943 initialize-hooks.sh*..............................3240 InitializeHooks.pm...............................18593 local...................| ../.git/git-hooks-carton-local/ hooks.d.local commit-msg, post-merge, [...]
  • 60. Download All the Code for .git-repo-admin I .git-repo-admin I I Author: Mikko Koivunalho I https://github.com/mikkoi/.git-repo-admin I Installation: Clone the Git repository and copy the '.git-repo-admin' directory to your own repositories.
  • 61. Questions Questions? And maybe answers
  • 62. SubGit For People Who Need to Hide Their Liking of Git. . . SubGit http://www.subgit.com I SubGit is a tool for a smooth, stress-free Svn to Git migration. I Create a writable Git mirror of a local or remote Subversion repository and use both Subversion and Git. I Bidirectional Subversion to Git replication! I When using remote synchronization Subversion is not even aware of it being synchronized with a Git repository.