Slide 1

Slide 1 text

How GitLab Works

Slide 2

Slide 2 text

Saito github.com/saitowu @saitowu

Slide 3

Slide 3 text

AIXForce

Slide 4

Slide 4 text

GitLab?

Slide 5

Slide 5 text

GitLab? Self Hosted Git Management Application

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

issues code snippet ssh & http wall ... code view wiki network graph merge request

Slide 8

Slide 8 text

happy to use it.

Slide 9

Slide 9 text

happy to use it. want to know how it works?

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

backend

Slide 12

Slide 12 text

backend repo access

Slide 13

Slide 13 text

backend repo access presentation layer

Slide 14

Slide 14 text

Backend

Slide 15

Slide 15 text

Can be backend:

Slide 16

Slide 16 text

Can be backend: protocol

Slide 17

Slide 17 text

Can be backend: file => (RW) git => (R) ssh => (RW) http => (RW) protocol

Slide 18

Slide 18 text

Can be backend: file => (RW) git => (R) ssh => (RW) http => (RW) protocol x x

Slide 19

Slide 19 text

Can be backend: file => (RW) git => (R) ssh => (RW) http => (RW) protocol x x #=> remote #=> authentication

Slide 20

Slide 20 text

SSH:

Slide 21

Slide 21 text

SSH: normal: authorized_keys

Slide 22

Slide 22 text

SSH: normal: authorized_keys

Slide 23

Slide 23 text

SSH:

Slide 24

Slide 24 text

SSH: gitosis/gitolite: authorized_keys

Slide 25

Slide 25 text

SSH: gitosis/gitolite: authorized_keys SSH magic command

Slide 26

Slide 26 text

SSH: gitosis/gitolite: authorized_keys SSH magic command

Slide 27

Slide 27 text

SSH:

Slide 28

Slide 28 text

SSH: sshd: not authorized_keys

Slide 29

Slide 29 text

SSH: sshd: not authorized_keys but patched sshd

Slide 30

Slide 30 text

SSH: sshd: not authorized_keys but patched sshd

Slide 31

Slide 31 text

SSH: sshd: not authorized_keys but patched sshd

Slide 32

Slide 32 text

SSH: sshd: not authorized_keys but patched sshd <= instead of sshd

Slide 33

Slide 33 text

SSH:

Slide 34

Slide 34 text

SSH: GitLab v1.0: gitosis #=> python

Slide 35

Slide 35 text

SSH: GitLab v1.0: gitosis #=> python GitLab v2.0: gitolite #=> perl

Slide 36

Slide 36 text

HTTP:

Slide 37

Slide 37 text

HTTP: before Git v1.6.6: dumb

Slide 38

Slide 38 text

HTTP: before Git v1.6.6: dumb after Git v1.6.6: smart!!!

Slide 39

Slide 39 text

HTTP: https://github.com/schacon/grack/blob/master/lib/git_http.rb#L10-23

Slide 40

Slide 40 text

git-upload-pack #=> send git-receive-pack #=> receive HTTP:

Slide 41

Slide 41 text

git-upload-pack #=> send git-receive-pack #=> receive HTTP: smart

Slide 42

Slide 42 text

HTTP: GitLab v2.7: smart HTTP protocol

Slide 43

Slide 43 text

Repo Access

Slide 44

Slide 44 text

Grit: command-line wrapper

Slide 45

Slide 45 text

Rugged: ruby bindings to libgit2

Slide 46

Slide 46 text

Grit vs Rugged

Slide 47

Slide 47 text

Grit vs Rugged win

Slide 48

Slide 48 text

Grit vs Rugged win lose

Slide 49

Slide 49 text

Grit vs Rugged win lose github will migrate from grit to rugged too

Slide 50

Slide 50 text

Repo Browser

Slide 51

Slide 51 text

Must Know:

Slide 52

Slide 52 text

Must Know: Git object model

Slide 53

Slide 53 text

Must Know: Git encoding strategy Git object model

Slide 54

Slide 54 text

Must Know: Git encoding strategy Ruby encoding Git object model

Slide 55

Slide 55 text

Git Object Model:

Slide 56

Slide 56 text

Git Object Model: 4 basic objects: blob tree commit tag

Slide 57

Slide 57 text

Git Object Model: 4 basic objects: blob tree commit tag stored in: .git/objects

Slide 58

Slide 58 text

Git Object Model:

Slide 59

Slide 59 text

Git Object Model: git show

Slide 60

Slide 60 text

Git Object Model: git cat-file -p git show

Slide 61

Slide 61 text

Git Object Model: http://saito.im/note/Git-Internals/

Slide 62

Slide 62 text

Git Encoding Strategy: At the core level, git is character encoding agnostic. http://www.kernel.org/pub/software/scm/git/docs/v1.5.0.2/git-log.html#_discussion

Slide 63

Slide 63 text

Git Encoding Strategy:

Slide 64

Slide 64 text

Git Encoding Strategy: filename

Slide 65

Slide 65 text

Git Encoding Strategy: filename blob contents

Slide 66

Slide 66 text

Git Encoding Strategy: filename blob contents commit message

Slide 67

Slide 67 text

Git Encoding Strategy: filename #=> tree blob blob contents commit message

Slide 68

Slide 68 text

Git Encoding Strategy: filename #=> tree blob blob contents #=> blob commit message

Slide 69

Slide 69 text

Git Encoding Strategy: filename #=> tree blob blob contents #=> blob commit message #=> commit tag

Slide 70

Slide 70 text

Git Encoding Strategy:

Slide 71

Slide 71 text

Git Encoding Strategy: no need #=> blob contents

Slide 72

Slide 72 text

Git Encoding Strategy: no need #=> blob contents need #=> commit message, filename

Slide 73

Slide 73 text

Git Encoding Strategy: no need #=> blob contents need #=> commit message, filename IMHO: #=> hg hybird strategy & svn

Slide 74

Slide 74 text

Ruby Encoding: detect encoding:

Slide 75

Slide 75 text

Ruby Encoding: detect encoding:the longer the better

Slide 76

Slide 76 text

Ruby Encoding: detect encoding:the longer the better filename

Slide 77

Slide 77 text

Ruby Encoding: detect encoding:the longer the better filename blob contents

Slide 78

Slide 78 text

Ruby Encoding: detect encoding:the longer the better filename blob contents commit message

Slide 79

Slide 79 text

Ruby Encoding: detect encoding:the longer the better #=> too short filename blob contents commit message

Slide 80

Slide 80 text

Ruby Encoding: detect encoding:the longer the better #=> too short #=> good to detect filename blob contents commit message

Slide 81

Slide 81 text

Ruby Encoding: detect encoding:the longer the better #=> too short #=> good to detect #=> not long enough filename blob contents commit message

Slide 82

Slide 82 text

Ruby Encoding: Character encoding detection:

Slide 83

Slide 83 text

Ruby Encoding: Character encoding detection: charlock_holmes

Slide 84

Slide 84 text

Ruby Encoding: Character encoding detection: charlock_holmes rchardet19

Slide 85

Slide 85 text

Ruby Encoding: Character encoding detection: charlock_holmes #=> libicu rchardet19

Slide 86

Slide 86 text

Ruby Encoding: Character encoding detection: charlock_holmes #=> libicu rchardet19 #=> pure ruby

Slide 87

Slide 87 text

Ruby Encoding:

Slide 88

Slide 88 text

Ruby Encoding: blob contents:

Slide 89

Slide 89 text

Ruby Encoding: blob contents: filename and commit message:

Slide 90

Slide 90 text

Ruby Encoding: blob contents: filename and commit message: detect and encode

Slide 91

Slide 91 text

Ruby Encoding: blob contents: filename and commit message: detect and encode hard to deal with

Slide 92

Slide 92 text

Ruby Encoding:

Slide 93

Slide 93 text

Ruby Encoding: CSI

Slide 94

Slide 94 text

Ruby Encoding: CSI #=> Character Set Independent

Slide 95

Slide 95 text

Ruby Encoding: CSI USC #=> Character Set Independent

Slide 96

Slide 96 text

Ruby Encoding: CSI USC #=> Character Set Independent #=> Universal Character Set

Slide 97

Slide 97 text

Ruby Encoding: CSI USC #=> Ruby #=> Character Set Independent #=> Universal Character Set

Slide 98

Slide 98 text

Ruby Encoding: CSI USC #=> Ruby #=> Java Python Perl #=> Character Set Independent #=> Universal Character Set

Slide 99

Slide 99 text

Ruby Encoding:

Slide 100

Slide 100 text

Ruby Encoding: MRI 1.8:

Slide 101

Slide 101 text

Ruby Encoding: MRI 1.8: defective encoding

Slide 102

Slide 102 text

Ruby Encoding: MRI 1.8: MRI 1.9: defective encoding

Slide 103

Slide 103 text

Ruby Encoding: MRI 1.8: MRI 1.9: defective encoding Encoding Class

Slide 104

Slide 104 text

Ruby Encoding: MRI 1.8: MRI 1.9: defective encoding pros: regexp length Encoding Class

Slide 105

Slide 105 text

Ruby Encoding: MRI 1.8: MRI 1.9: defective encoding pros: regexp length cons: incompatible character encodings Encoding Class

Slide 106

Slide 106 text

Hooks

Slide 107

Slide 107 text

Post-receive:

Slide 108

Slide 108 text

Post-receive: push event to redis

Slide 109

Slide 109 text

Post-receive: push event to redis resque it

Slide 110

Slide 110 text

scalability : Web Hooks Post-receive:

Slide 111

Slide 111 text

interoperability : API Post-receive:

Slide 112

Slide 112 text

interoperability : API based on grape Post-receive:

Slide 113

Slide 113 text

More

Slide 114

Slide 114 text

Git: pull-request

Slide 115

Slide 115 text

Git: pull-request git format-patch
..

Slide 116

Slide 116 text

Git: git apply --check pull-request git format-patch
..

Slide 117

Slide 117 text

Git: git apply --check pull-request git format-patch
..
git am

Slide 118

Slide 118 text

Git: git cherry-pick cherry-pick

Slide 119

Slide 119 text

One More Thing

Slide 120

Slide 120 text

Gitlab CI

Slide 121

Slide 121 text

Thanks