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

2
00:00:02,270 --> 00:00:05,000
implementing client side Get hooks. So

3
00:00:05,000 --> 00:00:06,590
over the course of this demo, here's what

4
00:00:06,590 --> 00:00:08,960
we're gonna do. First, we'll be verifying

5
00:00:08,960 --> 00:00:10,770
our version of get again because there are

6
00:00:10,770 --> 00:00:12,200
some things we will be leveraging that

7
00:00:12,200 --> 00:00:14,680
require a specific version of Get Well,

8
00:00:14,680 --> 00:00:16,560
then be reviewing a sample project with

9
00:00:16,560 --> 00:00:19,240
testing and lynching integrated into it.

10
00:00:19,240 --> 00:00:21,460
We will then create a pre commit hook to

11
00:00:21,460 --> 00:00:24,000
run tests and talent are files will then

12
00:00:24,000 --> 00:00:26,030
update config to include hooks within the

13
00:00:26,030 --> 00:00:29,390
repositories. So first, I'm going to check

14
00:00:29,390 --> 00:00:31,730
the version of Get that I'm using. Now I'm

15
00:00:31,730 --> 00:00:34,430
on get version 2.22. Now, in this case

16
00:00:34,430 --> 00:00:36,680
will be using a config variable that is

17
00:00:36,680 --> 00:00:38,980
only available and get version 2.9 and

18
00:00:38,980 --> 00:00:41,080
later. So I'm fine here. You should be

19
00:00:41,080 --> 00:00:43,880
passed version 2.9 as well. Next, we're

20
00:00:43,880 --> 00:00:45,870
gonna be cloning a sample. JavaScript

21
00:00:45,870 --> 00:00:48,880
Project depository. Now that we have that

22
00:00:48,880 --> 00:00:50,340
in place, we're going to change into the

23
00:00:50,340 --> 00:00:53,330
directory now from here were first going

24
00:00:53,330 --> 00:00:55,270
to run in P. M installed to pull in some

25
00:00:55,270 --> 00:00:59,580
of the project dependencies. Now I'm gonna

26
00:00:59,580 --> 00:01:03,310
open this in V s code now from here. I'm

27
00:01:03,310 --> 00:01:05,760
gonna go in and view the terminal. Now,

28
00:01:05,760 --> 00:01:07,390
the first thing that we need to do is make

29
00:01:07,390 --> 00:01:09,200
sure that our index dot Js file is

30
00:01:09,200 --> 00:01:12,760
executed. Next, we're going to run this

31
00:01:12,760 --> 00:01:14,340
script, and the script is a relatively

32
00:01:14,340 --> 00:01:16,720
simple one. It will simply calculate all

33
00:01:16,720 --> 00:01:18,860
of the prime numbers between one and the

34
00:01:18,860 --> 00:01:20,920
number that we pass in. So in this case

35
00:01:20,920 --> 00:01:24,070
will choose to pass in 100 and we can see

36
00:01:24,070 --> 00:01:26,160
that it found 25 prime numbers between

37
00:01:26,160 --> 00:01:28,980
zero and 100. Now, the next thing we're

38
00:01:28,980 --> 00:01:30,780
going to do is we're going to highlight

39
00:01:30,780 --> 00:01:32,300
the different capabilities that we have

40
00:01:32,300 --> 00:01:34,570
built into this repositories. So first, we

41
00:01:34,570 --> 00:01:36,550
do have a test suite that is configured in

42
00:01:36,550 --> 00:01:39,000
packaged up Jason so we can run in P m

43
00:01:39,000 --> 00:01:41,830
test. And when we do, we see that we do

44
00:01:41,830 --> 00:01:44,410
have to passing tests, its first test to

45
00:01:44,410 --> 00:01:46,600
be sure that it is returning 25 primes

46
00:01:46,600 --> 00:01:48,720
between zero and 100. And then we're

47
00:01:48,720 --> 00:01:50,330
checking to be sure that it is returning

48
00:01:50,330 --> 00:01:52,760
the correct prime numbers. Now, the next

49
00:01:52,760 --> 00:01:54,320
thing I want to highlight is that we also

50
00:01:54,320 --> 00:01:56,080
have lynching integrated into this

51
00:01:56,080 --> 00:01:58,770
repositories and So in this case, we can

52
00:01:58,770 --> 00:02:02,070
run in P M Ron lint and will now use E s

53
00:02:02,070 --> 00:02:03,880
lint to check over the files that we pass

54
00:02:03,880 --> 00:02:05,970
in. Now, in this case, we have no lynching

55
00:02:05,970 --> 00:02:08,180
errors. Now, the next thing we're going to

56
00:02:08,180 --> 00:02:09,960
do is we're gonna navigate to settings for

57
00:02:09,960 --> 00:02:12,720
V s code so that we can see our dot get

58
00:02:12,720 --> 00:02:15,200
directory inside of the editor. Now,

59
00:02:15,200 --> 00:02:17,070
chances are for whatever tool you're using

60
00:02:17,070 --> 00:02:18,710
to editor code, you'll need to make this

61
00:02:18,710 --> 00:02:22,250
adjustment as well. So from here, I'm

62
00:02:22,250 --> 00:02:24,780
going to search for exclude. And then I'm

63
00:02:24,780 --> 00:02:27,040
going to make this a workspace setting.

64
00:02:27,040 --> 00:02:28,520
I'm going to remove the globe pattern that

65
00:02:28,520 --> 00:02:31,820
includes the dot get directory. Now we'll

66
00:02:31,820 --> 00:02:33,720
see that our dot get directory has shown

67
00:02:33,720 --> 00:02:37,030
up well, now close settings. Now, next,

68
00:02:37,030 --> 00:02:38,870
I'm going to open the dot get directory,

69
00:02:38,870 --> 00:02:41,540
and I'm going to open the hooks directory

70
00:02:41,540 --> 00:02:43,320
from within here. We can see that there is

71
00:02:43,320 --> 00:02:46,670
a pre commit dot sample file. This is the

72
00:02:46,670 --> 00:02:48,860
file that we're going to be using. Now.

73
00:02:48,860 --> 00:02:51,080
The pre commit file is one again that gets

74
00:02:51,080 --> 00:02:53,780
executed before we actually commit the

75
00:02:53,780 --> 00:02:55,700
file. And even before the commit message

76
00:02:55,700 --> 00:02:57,700
is generated. So in this case, we're going

77
00:02:57,700 --> 00:02:59,520
to use this to run both the tests and the

78
00:02:59,520 --> 00:03:03,260
lint ing prior to committing. And we will

79
00:03:03,260 --> 00:03:05,140
rename this and I'm going to remove the

80
00:03:05,140 --> 00:03:08,420
dot sample from the end of the file. Now,

81
00:03:08,420 --> 00:03:09,840
the next thing I'm going to do is I'm

82
00:03:09,840 --> 00:03:12,390
going to close the terminal, all then

83
00:03:12,390 --> 00:03:13,900
highlight and delete everything that's

84
00:03:13,900 --> 00:03:16,270
currently in this file and will now add in

85
00:03:16,270 --> 00:03:18,210
some additional logic that will enable us

86
00:03:18,210 --> 00:03:21,040
to run both the tests and the lynching.

87
00:03:21,040 --> 00:03:23,390
So, first of all, I've specified that this

88
00:03:23,390 --> 00:03:25,690
needs to exit with a non zero status. If

89
00:03:25,690 --> 00:03:27,260
any of the following scripts fail now,

90
00:03:27,260 --> 00:03:29,290
that's critical here because the way that

91
00:03:29,290 --> 00:03:32,060
get hooks communicate with get is based on

92
00:03:32,060 --> 00:03:34,490
that status code. So if anything fails,

93
00:03:34,490 --> 00:03:36,460
even the lynching or the test it needs to

94
00:03:36,460 --> 00:03:38,730
return a non zero status code that way,

95
00:03:38,730 --> 00:03:40,320
get will know that this failed and we

96
00:03:40,320 --> 00:03:42,720
should not accept to commit. Next, I'm

97
00:03:42,720 --> 00:03:45,920
gonna open back up the terminal, and from

98
00:03:45,920 --> 00:03:47,500
here I'm going to close our dot get

99
00:03:47,500 --> 00:03:49,250
directory, and I'm going to navigate to

100
00:03:49,250 --> 00:03:52,090
index dot Js. Now I'm going to add an

101
00:03:52,090 --> 00:03:55,630
extra tab in Now, this should cause Linton

102
00:03:55,630 --> 00:03:57,190
to fail because that's not where we would

103
00:03:57,190 --> 00:04:00,610
want this tab. So I'll save this file. And

104
00:04:00,610 --> 00:04:04,400
then now I'll try to commit this. And when

105
00:04:04,400 --> 00:04:06,450
we do, we can see that there is an error.

106
00:04:06,450 --> 00:04:08,450
The lynching air does come up, and it lets

107
00:04:08,450 --> 00:04:10,920
us know that we cannot commit Now. Next,

108
00:04:10,920 --> 00:04:12,510
I'll reset the repositories to get rid of

109
00:04:12,510 --> 00:04:14,700
this change. Now, next, I'm going to

110
00:04:14,700 --> 00:04:17,080
navigate in the lib directory to find

111
00:04:17,080 --> 00:04:19,490
primes dot Js. Now, this is the function

112
00:04:19,490 --> 00:04:21,380
that is actually being tested by the test

113
00:04:21,380 --> 00:04:23,600
suite. So in this case, I'm going to

114
00:04:23,600 --> 00:04:26,040
change. Instead of returning the output,

115
00:04:26,040 --> 00:04:27,530
which would include the prime numbers that

116
00:04:27,530 --> 00:04:29,440
it has detected, I'm going to return a

117
00:04:29,440 --> 00:04:33,480
fixed array. Well, now, save the file. Now

118
00:04:33,480 --> 00:04:35,020
from here will now try to commit this

119
00:04:35,020 --> 00:04:38,110
change as well. And now we can see that we

120
00:04:38,110 --> 00:04:41,110
do have a failure. In this case, we're not

121
00:04:41,110 --> 00:04:42,860
returning the correct primes and we're not

122
00:04:42,860 --> 00:04:45,080
returning the correct number of primes. So

123
00:04:45,080 --> 00:04:47,010
we have failed our tests and because of

124
00:04:47,010 --> 00:04:49,610
that, it is failing to let us commit. So

125
00:04:49,610 --> 00:04:51,730
in this case will now go back in and we

126
00:04:51,730 --> 00:04:54,710
will reset the repositories. Now All of

127
00:04:54,710 --> 00:04:56,450
this has worked well so far, except

128
00:04:56,450 --> 00:04:59,090
there's a problem. Our dot get directory

129
00:04:59,090 --> 00:05:01,810
is our config for our repositories. This

130
00:05:01,810 --> 00:05:03,380
is not information that is going to get

131
00:05:03,380 --> 00:05:05,190
populated for any of the members of my

132
00:05:05,190 --> 00:05:07,740
team. Luckily, get provides a config

133
00:05:07,740 --> 00:05:09,600
option, and it's been around since. Get

134
00:05:09,600 --> 00:05:12,390
2.9 that allows us to use a different

135
00:05:12,390 --> 00:05:14,030
directory within the repositories,

136
00:05:14,030 --> 00:05:16,350
historic at hooks. So I'll go ahead and

137
00:05:16,350 --> 00:05:18,670
set this value and this is core dot hooks

138
00:05:18,670 --> 00:05:20,740
path, and I'm going to set this to be dot

139
00:05:20,740 --> 00:05:23,300
get hooks. So next I'm going to actually

140
00:05:23,300 --> 00:05:26,200
make this directory, and then I'm going to

141
00:05:26,200 --> 00:05:28,360
move the pre commit file into that

142
00:05:28,360 --> 00:05:31,190
directory now just isn't note here. This

143
00:05:31,190 --> 00:05:33,200
file is already executed ble, But if

144
00:05:33,200 --> 00:05:34,770
you're creating this file from scratch,

145
00:05:34,770 --> 00:05:36,560
you want to take the extra step to be sure

146
00:05:36,560 --> 00:05:38,720
that you do make it execute a ble before

147
00:05:38,720 --> 00:05:40,640
you actually attempt to commit. Now the

148
00:05:40,640 --> 00:05:42,040
next thing I'm going to do is I'm going to

149
00:05:42,040 --> 00:05:44,880
navigate back into my index dot Js file. I

150
00:05:44,880 --> 00:05:47,640
will add in a few misplaced tabs again,

151
00:05:47,640 --> 00:05:50,110
I'll save the file and now I'll attempt to

152
00:05:50,110 --> 00:05:52,230
commit this, and in this case we do see

153
00:05:52,230 --> 00:05:55,100
that it failed yet again. So in this case,

154
00:05:55,100 --> 00:05:57,340
this failed not because of a hook in our

155
00:05:57,340 --> 00:05:59,750
dot get directory, but because of a hook

156
00:05:59,750 --> 00:06:01,850
within our dot get Hooks directory. And

157
00:06:01,850 --> 00:06:03,910
that is a directory that will be included

158
00:06:03,910 --> 00:06:06,120
within our depository. And as long as our

159
00:06:06,120 --> 00:06:08,180
teammates have the correct config value

160
00:06:08,180 --> 00:06:09,940
set for where they're get hooks directory

161
00:06:09,940 --> 00:06:16,000
is, it will automatically integrate in with the get hooks that we have created.

