GitGot: The Swiss Army Chainsaw of Git Repo Management

96
GitGot: The Swiss Army Chainsaw of Git Repo Management John SJ Anderson Infinity Interactive @genehack OSCON'14

description

GitGot is a Perl-based tool for batch management of collections of git repos. It has a number of interesting features and acts as a force multiplier when dealing with a large varied collection of repositories. My talk will cover why you would want to use GitGot as well as how to use it effectively.

Transcript of GitGot: The Swiss Army Chainsaw of Git Repo Management

Page 1: GitGot: The Swiss Army Chainsaw of Git Repo Management

GitGot: The Swiss Army Chainsaw of Git Repo Management

John SJ Anderson • Infinity Interactive@genehack • OSCON'14

Page 2: GitGot: The Swiss Army Chainsaw of Git Repo Management

Hi, I'm John.

Page 3: GitGot: The Swiss Army Chainsaw of Git Repo Management

@genehack

Page 4: GitGot: The Swiss Army Chainsaw of Git Repo Management

Sammy

Page 5: GitGot: The Swiss Army Chainsaw of Git Repo Management

@sammygenehack

Page 6: GitGot: The Swiss Army Chainsaw of Git Repo Management

Two kids

Page 7: GitGot: The Swiss Army Chainsaw of Git Repo Management

A Wife

Page 8: GitGot: The Swiss Army Chainsaw of Git Repo Management

long-suffering conference widow

A Wife

Page 9: GitGot: The Swiss Army Chainsaw of Git Repo Management

photobomber isnot impressed.

A Wife

long-suffering conference widow

Page 10: GitGot: The Swiss Army Chainsaw of Git Repo Management

Job

Page 11: GitGot: The Swiss Army Chainsaw of Git Repo Management

Hobbies

Page 12: GitGot: The Swiss Army Chainsaw of Git Repo Management

Hobbies

Page 13: GitGot: The Swiss Army Chainsaw of Git Repo Management

Hobbies

Page 14: GitGot: The Swiss Army Chainsaw of Git Repo Management

Lots of Hobbies

Page 15: GitGot: The Swiss Army Chainsaw of Git Repo Management

I've got a lot of balls in the air

Page 16: GitGot: The Swiss Army Chainsaw of Git Repo Management

Revision control $HOME

Page 17: GitGot: The Swiss Army Chainsaw of Git Repo Management

Why bother?

Page 18: GitGot: The Swiss Army Chainsaw of Git Repo Management

say automation again

Page 19: GitGot: The Swiss Army Chainsaw of Git Repo Management

Ingy döt Net

Page 20: GitGot: The Swiss Army Chainsaw of Git Repo Management

Things I wanted to steal

Page 21: GitGot: The Swiss Army Chainsaw of Git Repo Management

Things I wanted to add

Page 22: GitGot: The Swiss Army Chainsaw of Git Repo Management

App::AYCABTU?!?!‽

Page 23: GitGot: The Swiss Army Chainsaw of Git Repo Management

GitGot

Page 24: GitGot: The Swiss Army Chainsaw of Git Repo Management

Whirlwind Tour

Page 25: GitGot: The Swiss Army Chainsaw of Git Repo Management

got add

Page 26: GitGot: The Swiss Army Chainsaw of Git Repo Management

% got add Name: foo URL: Path: /Users/genehack/foo Tags: bar

Page 27: GitGot: The Swiss Army Chainsaw of Git Repo Management

got add -D

Page 28: GitGot: The Swiss Army Chainsaw of Git Repo Management

got clone <REPO URL>

Page 29: GitGot: The Swiss Army Chainsaw of Git Repo Management

got clone -D <REPO URL>

Page 30: GitGot: The Swiss Army Chainsaw of Git Repo Management

got fork <GITHUB URL>

Page 31: GitGot: The Swiss Army Chainsaw of Git Repo Management

~/.gitgot

Page 32: GitGot: The Swiss Army Chainsaw of Git Repo Management

- name: App-Amylase path: /Users/genehack/proj/App-Amylase repo: [email protected]:genehack/App-Amylase.git type: git - name: Git-Wrapper path: /Users/genehack/proj/Git-Wrapper repo: [email protected]:genehack/Git-Wrapper.git tags: git type: git - name: HiD path: /Users/genehack/proj/HiD repo: [email protected]:genehack/HiD.git type: git - name: Perl-Build path: /opt/plenv/plugins/perl-build repo: git://github.com/tokuhirom/Perl-Build.git type: git

Page 33: GitGot: The Swiss Army Chainsaw of Git Repo Management

But now what?

Page 34: GitGot: The Swiss Army Chainsaw of Git Repo Management

got list

Page 35: GitGot: The Swiss Army Chainsaw of Git Repo Management

got ls

Page 36: GitGot: The Swiss Army Chainsaw of Git Repo Management

1) App-Amylase git [email protected]:genehack/App-Amylase.git 2) Git-Wrapper git [email protected]:genehack/Git-Wrapper.git 3) HiD git [email protected]:genehack/HiD.git 4) Perl-Build git git://github.com/tokuhirom/Perl-Build.git 5) Perl-Critic git [email protected]:genehack/Perl-Critic.git 6) STAMPS git [email protected]:genehack/STAMPS.git 7) advanced-moose-class git ssh://[email protected]/train/advanced-moose-class.git 8) app-gitgitr git [email protected]:genehack/app-gitgitr.git 9) app-gitgot git [email protected]:genehack/app-gitgot.git

Page 37: GitGot: The Swiss Army Chainsaw of Git Repo Management

got ls -q

Page 38: GitGot: The Swiss Army Chainsaw of Git Repo Management

1) App-Amylase 2) Git-Wrapper 3) HiD 4) Perl-Build 5) Perl-Critic 6) STAMPS 7) advanced-moose-class 8) app-gitgitr 9) app-gitgot

Page 39: GitGot: The Swiss Army Chainsaw of Git Repo Management

got ls [repos]

Page 40: GitGot: The Swiss Army Chainsaw of Git Repo Management

got ls 5

Page 41: GitGot: The Swiss Army Chainsaw of Git Repo Management

5) Perl-Critic

Page 42: GitGot: The Swiss Army Chainsaw of Git Repo Management

got ls 5-8

Page 43: GitGot: The Swiss Army Chainsaw of Git Repo Management

5) Perl-Critic 6) STAMPS 7) advanced-moose-class 8) app-gitgitr

Page 44: GitGot: The Swiss Army Chainsaw of Git Repo Management

got ls HiD

Page 45: GitGot: The Swiss Army Chainsaw of Git Repo Management

3) HiD

Page 46: GitGot: The Swiss Army Chainsaw of Git Repo Management

got ls -t git

Page 47: GitGot: The Swiss Army Chainsaw of Git Repo Management

2) Git-Wrapper 8) app-gitgitr 9) app-gitgot

Page 48: GitGot: The Swiss Army Chainsaw of Git Repo Management

got ls 5-8 HiD 21 -t git

Page 49: GitGot: The Swiss Army Chainsaw of Git Repo Management

2) Git-Wrapper 3) HiD 5) Perl-Critic 6) STAMPS 7) advanced-moose-class 8) app-gitgitr 9) app-gitgot 21) etc

Page 50: GitGot: The Swiss Army Chainsaw of Git Repo Management

got status

Page 51: GitGot: The Swiss Army Chainsaw of Git Repo Management

got st

Page 52: GitGot: The Swiss Army Chainsaw of Git Repo Management

1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : OK 4) Perl-Build : OK 5) Perl-Critic : OK 6) STAMPS : OK 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK

Page 53: GitGot: The Swiss Army Chainsaw of Git Repo Management

1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : Dirty 4) Perl-Build : OK 5) Perl-Critic : OK 6) STAMPS : OK 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK

Dirty

Page 54: GitGot: The Swiss Army Chainsaw of Git Repo Management

1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : OK 4) Perl-Build : OK 5) Perl-Critic : OK 6) STAMPS : OK Ahead by 1 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK

1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : OK 4) Perl-Build : Dirty 5) Perl-Critic : OK 6) STAMPS : OK 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK

Dirty

1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : OK 4) Perl-Build : OK 5) Perl-Critic : OK 6) STAMPS : OK Ahead by 1 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK

Ahead by 1

Page 55: GitGot: The Swiss Army Chainsaw of Git Repo Management

got st -q

Page 56: GitGot: The Swiss Army Chainsaw of Git Repo Management

got st -q 3) HiD : Dirty

6) STAMPS : OK Ahead by 1

Dirty

Ahead by 1

Page 57: GitGot: The Swiss Army Chainsaw of Git Repo Management

got update

Page 58: GitGot: The Swiss Army Chainsaw of Git Repo Management

got up

Page 59: GitGot: The Swiss Army Chainsaw of Git Repo Management

1) App-Amylase : Up to date 2) Git-Wrapper : Up to date 3) HiD : Up to date 4) Perl-Build : Updated Updating 7f25f89..72587c8 Fast-forward lib/Perl/Build.pm | 14 +++++++++++++- script/perl-build | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) 5) Perl-Critic : Up to date

Updated

Page 60: GitGot: The Swiss Army Chainsaw of Git Repo Management

got update_status

Page 61: GitGot: The Swiss Army Chainsaw of Git Repo Management

got upst

Page 62: GitGot: The Swiss Army Chainsaw of Git Repo Management

got upst -q

Page 63: GitGot: The Swiss Army Chainsaw of Git Repo Management

How much would you pay?

Page 64: GitGot: The Swiss Army Chainsaw of Git Repo Management

Wait, don't answer yet

Page 65: GitGot: The Swiss Army Chainsaw of Git Repo Management

got fetch

Page 66: GitGot: The Swiss Army Chainsaw of Git Repo Management

got push

Page 67: GitGot: The Swiss Army Chainsaw of Git Repo Management

got gc

Page 68: GitGot: The Swiss Army Chainsaw of Git Repo Management

got this

Page 69: GitGot: The Swiss Army Chainsaw of Git Repo Management

got that

Page 70: GitGot: The Swiss Army Chainsaw of Git Repo Management

got chdir

Page 71: GitGot: The Swiss Army Chainsaw of Git Repo Management

got cd

Page 72: GitGot: The Swiss Army Chainsaw of Git Repo Management

got tmux

Page 73: GitGot: The Swiss Army Chainsaw of Git Repo Management

got tmux -s

Page 74: GitGot: The Swiss Army Chainsaw of Git Repo Management

How much would

you paynow

Page 75: GitGot: The Swiss Army Chainsaw of Git Repo Management

Good news!

It's free!

Page 76: GitGot: The Swiss Army Chainsaw of Git Repo Management

Works on any perl from the last 5 years

Page 77: GitGot: The Swiss Army Chainsaw of Git Repo Management

cpan App::GitGot

Page 78: GitGot: The Swiss Army Chainsaw of Git Repo Management

cpanm App::GitGot

Page 79: GitGot: The Swiss Army Chainsaw of Git Repo Management

Find me at OSCON and I'll help you install!

Page 80: GitGot: The Swiss Army Chainsaw of Git Repo Management

Easy to extend

Page 81: GitGot: The Swiss Army Chainsaw of Git Repo Management

package App::GitGot::Command::chdir; # ABSTRACT: open a subshell in a selected project !use Mouse; extends 'App::GitGot::Command'; use 5.010; !sub command_names { qw/ chdir cd / } !sub _execute { my( $self, $opt, $args ) = @_; ! unless ( $self->active_repos and $self->active_repos == 1 ) { say STDERR 'ERROR: You need to select a single repo'; exit(1); } ! my( $repo ) = $self->active_repos; ! chdir $repo->path or say STDERR "ERROR: Failed to chdir to repo ($!)" and exit(1); ! exec $ENV{SHELL}; } !__PACKAGE__->meta->make_immutable; 1;

Page 82: GitGot: The Swiss Army Chainsaw of Git Repo Management

package App::GitGot::Command::chdir; # ABSTRACT: open a subshell in a selected project !

use Mouse; extends 'App::GitGot::Command'; use 5.010;

Page 83: GitGot: The Swiss Army Chainsaw of Git Repo Management

sub command_names { qw/ chdir cd / } !

Page 84: GitGot: The Swiss Army Chainsaw of Git Repo Management

sub _execute { my( $self, $opt, $args ) = @_; !

unless ( $self->active_repos and $self->active_repos == 1 ) { say STDERR 'ERROR: You need to select a single repo'; exit(1); } !

my( $repo ) = $self->active_repos; !

chdir $repo->path or say STDERR "ERROR: Failed to chdir to repo ($!)" and exit(1); !

exec $ENV{SHELL}; }

Page 85: GitGot: The Swiss Army Chainsaw of Git Repo Management

package App::GitGot::Command::chdir; # ABSTRACT: open a subshell in a selected project !use Mouse; extends 'App::GitGot::Command'; use 5.010; !sub command_names { qw/ chdir cd / } !sub _execute { my( $self, $opt, $args ) = @_; ! unless ( $self->active_repos and $self->active_repos == 1 ) { say STDERR 'ERROR: You need to select a single repo'; exit(1); } ! my( $repo ) = $self->active_repos; ! chdir $repo->path or say STDERR "ERROR: Failed to chdir to repo ($!)" and exit(1); ! exec $ENV{SHELL}; } !__PACKAGE__->meta->make_immutable; 1;

Page 86: GitGot: The Swiss Army Chainsaw of Git Repo Management

Suggestions welcome!

Page 87: GitGot: The Swiss Army Chainsaw of Git Repo Management

Wait…there'smore!

Page 88: GitGot: The Swiss Army Chainsaw of Git Repo Management

App::MiseEnPlace

Page 89: GitGot: The Swiss Army Chainsaw of Git Repo Management

% cat .mise --- manage: - doc - etc - private - proj/* - src/* create: directories: - bin - proj - src - var links: - Desktop: var/tmp - Desktop: tmp

Page 90: GitGot: The Swiss Army Chainsaw of Git Repo Management

create: directories: - ~/.ssh links: - authinfo: ~/.authinfo - bash_private: ~/.bash_private - github-identity: ~/.github-identity - netrc: ~/.netrc - ssh/authorized_keys: ~/.ssh/authorized_keys - ssh/config: ~/.ssh/config - ssh/id_dsa: ~/.ssh/id_dsa - ssh/id_dsa.pub: ~/.ssh/id_dsa.pub - zsh_private: ~/.zsh_private

Page 91: GitGot: The Swiss Army Chainsaw of Git Repo Management

got

Page 92: GitGot: The Swiss Army Chainsaw of Git Repo Management

https://github.com/genehack/app-gitgot

Page 93: GitGot: The Swiss Army Chainsaw of Git Repo Management

https://github.com/genehack/app-miseenplace

Page 94: GitGot: The Swiss Army Chainsaw of Git Repo Management

Thanks Ingy döt Net

Yanick Champoux Michael Greb

Rolando PereiraChris Prather

Page 95: GitGot: The Swiss Army Chainsaw of Git Repo Management

Questions?

Page 96: GitGot: The Swiss Army Chainsaw of Git Repo Management

https://github.com/genehack/app-gitgot

!

https://github.com/genehack/app-miseenplace