1
00:00:01,040 --> 00:00:02,130
[Autogenerated] So next we're going to

2
00:00:02,130 --> 00:00:04,730
talk about get hooks and get hooks are one

3
00:00:04,730 --> 00:00:06,840
of the features of Get that allow you to

4
00:00:06,840 --> 00:00:09,300
optimize aspects of workflow. So let's

5
00:00:09,300 --> 00:00:11,500
talk about what get hooks are. So First of

6
00:00:11,500 --> 00:00:13,940
all, a get hook is a predefined script

7
00:00:13,940 --> 00:00:16,790
that is executed in response to a specific

8
00:00:16,790 --> 00:00:18,960
action that has occurred within your git

9
00:00:18,960 --> 00:00:21,260
repositories. Now, generally, we bring

10
00:00:21,260 --> 00:00:23,290
these down into two different groups. We

11
00:00:23,290 --> 00:00:25,770
first have client side hooks and these air

12
00:00:25,770 --> 00:00:27,830
hooks that would run on your machine with

13
00:00:27,830 --> 00:00:30,000
your version of the repositories based on

14
00:00:30,000 --> 00:00:32,180
things that you do to your depository. So

15
00:00:32,180 --> 00:00:34,160
next we have server side hooks and these

16
00:00:34,160 --> 00:00:36,620
air scripts that execute on the get server

17
00:00:36,620 --> 00:00:38,450
to a different set of events. That may

18
00:00:38,450 --> 00:00:40,800
happen. So let's look at the overall get

19
00:00:40,800 --> 00:00:43,290
hooks process. First of all, we're going

20
00:00:43,290 --> 00:00:45,640
to divide down the middle between client

21
00:00:45,640 --> 00:00:48,170
and server. Let's start by looking at the

22
00:00:48,170 --> 00:00:50,760
client's side, so this will include some

23
00:00:50,760 --> 00:00:53,270
but not all of the areas for integrating

24
00:00:53,270 --> 00:00:55,320
get hooks. So, first of all, we're going

25
00:00:55,320 --> 00:00:57,540
to look at pre commit now. This happens

26
00:00:57,540 --> 00:01:00,160
after the user chooses to commit, but in

27
00:01:00,160 --> 00:01:01,800
this case, the commit message. Template

28
00:01:01,800 --> 00:01:04,420
hasn't yet been generated. Then we have

29
00:01:04,420 --> 00:01:06,760
prepare commit message. And in this case,

30
00:01:06,760 --> 00:01:08,690
we do have a commit message that has been

31
00:01:08,690 --> 00:01:10,870
generated, and we can choose to customize

32
00:01:10,870 --> 00:01:13,160
it at this point. Then we have commit

33
00:01:13,160 --> 00:01:15,140
message, and this is where the user has

34
00:01:15,140 --> 00:01:17,270
entered in there. Commit message. And we

35
00:01:17,270 --> 00:01:18,810
could in this case, choose to either

36
00:01:18,810 --> 00:01:21,520
accept or reject that message, and then we

37
00:01:21,520 --> 00:01:24,100
have post commit. Now any of the get hooks

38
00:01:24,100 --> 00:01:26,580
that start with Post are generally just

39
00:01:26,580 --> 00:01:28,920
used for notifications because in this

40
00:01:28,920 --> 00:01:30,610
case, the action has already been

41
00:01:30,610 --> 00:01:32,430
completed. The committee has already been

42
00:01:32,430 --> 00:01:34,650
made, but if you wanted to tie this into

43
00:01:34,650 --> 00:01:36,710
some notification system, you could do it

44
00:01:36,710 --> 00:01:39,250
through post commit. Now, at this point,

45
00:01:39,250 --> 00:01:41,470
we're now going to say that we have pushed

46
00:01:41,470 --> 00:01:43,970
things from our client to the server to

47
00:01:43,970 --> 00:01:46,820
our remote. Now the first area forget

48
00:01:46,820 --> 00:01:49,530
hooks that we see is pre received. Now pre

49
00:01:49,530 --> 00:01:51,670
receive receives all of the refs that are

50
00:01:51,670 --> 00:01:54,130
being updated so you could have many.

51
00:01:54,130 --> 00:01:56,000
They're being pushed from the client to

52
00:01:56,000 --> 00:01:57,950
the server, and you could choose in this

53
00:01:57,950 --> 00:02:00,790
case to examine each of those and reject

54
00:02:00,790 --> 00:02:03,540
that push that is coming into the server.

55
00:02:03,540 --> 00:02:05,970
You also have update Now update will get

56
00:02:05,970 --> 00:02:07,980
called per ref that gets pushed to the

57
00:02:07,980 --> 00:02:09,880
server so you'll get a chance to look at

58
00:02:09,880 --> 00:02:11,450
each of them individually, and you could

59
00:02:11,450 --> 00:02:13,400
choose to reject some of those that are

60
00:02:13,400 --> 00:02:16,230
coming in. And just as with Post commit,

61
00:02:16,230 --> 00:02:18,580
we also have a post received, which also

62
00:02:18,580 --> 00:02:20,650
would be focused for notifications after

63
00:02:20,650 --> 00:02:23,000
things have been pushed to the server. Now

64
00:02:23,000 --> 00:02:25,040
let's talk for a minute about client side.

65
00:02:25,040 --> 00:02:27,530
Get hooks. First of all, clients I'd get

66
00:02:27,530 --> 00:02:29,520
hooks are designed to improve workflow for

67
00:02:29,520 --> 00:02:30,500
developers that are using the

68
00:02:30,500 --> 00:02:32,710
repositories. Now. I note this here that

69
00:02:32,710 --> 00:02:34,480
this is designed to improve workflow and

70
00:02:34,480 --> 00:02:36,780
not to enforce policy because you cannot

71
00:02:36,780 --> 00:02:39,200
enforce policies because the users have

72
00:02:39,200 --> 00:02:40,900
their own version of the repository and

73
00:02:40,900 --> 00:02:43,010
they can reconfigure those and adjust

74
00:02:43,010 --> 00:02:44,860
those. They could even completely remove

75
00:02:44,860 --> 00:02:47,280
those get hooks. Now it's often leverage

76
00:02:47,280 --> 00:02:50,100
to run pre commit checks against code. So

77
00:02:50,100 --> 00:02:51,750
if you want to do just some simple checks

78
00:02:51,750 --> 00:02:53,970
of code before it leaves your developers

79
00:02:53,970 --> 00:02:55,760
machine, this is one of the ways that we

80
00:02:55,760 --> 00:02:57,820
would leverage clients. I'd get hooks. Now

81
00:02:57,820 --> 00:02:59,490
let's look at some of the common use

82
00:02:59,490 --> 00:03:01,710
cases. First of all, we have things like

83
00:03:01,710 --> 00:03:04,230
lynching files, checking to be sure that

84
00:03:04,230 --> 00:03:05,940
the files that the developer is going to

85
00:03:05,940 --> 00:03:07,550
commit meet the standards for your

86
00:03:07,550 --> 00:03:10,260
organization running tests. So actually

87
00:03:10,260 --> 00:03:12,760
_______ off an execution of the test suite

88
00:03:12,760 --> 00:03:14,370
to make sure that we're not injecting code

89
00:03:14,370 --> 00:03:16,640
that breaks the tests, verifying things

90
00:03:16,640 --> 00:03:18,480
like No. Two DUIs and committed code. So

91
00:03:18,480 --> 00:03:20,320
we have different ways that we can look at

92
00:03:20,320 --> 00:03:22,840
the content of those files and make sure

93
00:03:22,840 --> 00:03:24,980
that the developer is not breaking any of

94
00:03:24,980 --> 00:03:27,260
the best practices that we have defined.

95
00:03:27,260 --> 00:03:29,060
We can also use them for preparing a

96
00:03:29,060 --> 00:03:31,650
commit message so potentially providing a

97
00:03:31,650 --> 00:03:33,410
template that our users can then go in and

98
00:03:33,410 --> 00:03:35,840
edit and in some cases even cleaning up

99
00:03:35,840 --> 00:03:38,300
files after specific actions. So if there

100
00:03:38,300 --> 00:03:39,890
is some sort of compilation, depending on

101
00:03:39,890 --> 00:03:41,110
the language that were in that we would

102
00:03:41,110 --> 00:03:43,790
need to perform before we actually push,

103
00:03:43,790 --> 00:03:45,360
we could then go through, for example, and

104
00:03:45,360 --> 00:03:47,080
clean up some of those artifacts once that

105
00:03:47,080 --> 00:03:49,630
has completed. Now let's talk next about

106
00:03:49,630 --> 00:03:52,060
server side get hooks. So these are

107
00:03:52,060 --> 00:03:54,240
different because, unlike client side

108
00:03:54,240 --> 00:03:56,900
hooks, server side hooks can enforce team

109
00:03:56,900 --> 00:03:59,240
policies because our developers don't have

110
00:03:59,240 --> 00:04:01,750
the ability to go in and edit the server

111
00:04:01,750 --> 00:04:04,440
and change what those scripts are. So,

112
00:04:04,440 --> 00:04:05,830
first of all, when we're looking at the

113
00:04:05,830 --> 00:04:08,090
different opportunities to inject our get

114
00:04:08,090 --> 00:04:10,750
hooks, if we want to reject pushes overall

115
00:04:10,750 --> 00:04:13,090
based on overall policies, we would use

116
00:04:13,090 --> 00:04:15,340
pre receive if we want to look at

117
00:04:15,340 --> 00:04:17,550
individual branch pushes, this is where we

118
00:04:17,550 --> 00:04:19,760
would leverage update and for

119
00:04:19,760 --> 00:04:22,300
notifications and hooks after the commit.

120
00:04:22,300 --> 00:04:24,470
This is where we would use Post received.

121
00:04:24,470 --> 00:04:26,470
So for server side get hooks, here are

122
00:04:26,470 --> 00:04:29,020
some common use cases. We have things like

123
00:04:29,020 --> 00:04:31,590
enforcing a commit message format because

124
00:04:31,590 --> 00:04:33,680
in some cases organizations want to be

125
00:04:33,680 --> 00:04:35,620
sure that developers are referencing a

126
00:04:35,620 --> 00:04:37,320
ticket in their ticketing system with

127
00:04:37,320 --> 00:04:39,430
every commit. It could also include

128
00:04:39,430 --> 00:04:42,040
enforcing user identity information,

129
00:04:42,040 --> 00:04:43,350
making sure that they're using their

130
00:04:43,350 --> 00:04:45,710
corporate email address as the identity to

131
00:04:45,710 --> 00:04:48,090
push this to the server, enforcing the

132
00:04:48,090 --> 00:04:50,840
signing of tags and or commits. Now

133
00:04:50,840 --> 00:04:52,150
there's a lot of talk around whether or

134
00:04:52,150 --> 00:04:53,780
not there is value and actually signing

135
00:04:53,780 --> 00:04:55,900
commits. But some organizations want to

136
00:04:55,900 --> 00:04:57,620
enforce that, and that's something that

137
00:04:57,620 --> 00:05:00,790
you can do with server side get hooks. You

138
00:05:00,790 --> 00:05:03,140
can also block access for specific I P

139
00:05:03,140 --> 00:05:08,000
addresses, and you can even block specific file extensions.

