Pre-commit Framework: Git Hook Scripts

Talk Python To Me
|

Automatic TRANSCRIPT

Be looking for employment after that I might turn out in my turn out your program right now you can do it. Awesome. It was always a chance the for sure you've got to give it a shot. That's awesome. Well, let's talk about this project that you've been. Working on for a while, but like I said, has gotten a little bit of traction a lot of traction lately because of tools like black in other things that have made recommit hooks awesome and exciting all the sudden. But before we talk about what you've been doing, let's talk about the idea recommit hoax in general. Sure. What is this for a lot of people who are like? Yeah I kinda what it is I kind of use that or maybe if even used like Zip. Zip and name of a date as a source of. Final one one. But yeah, the idea behind get hooked specifically the because I think that's probably the one that most people get the most interaction with. But there are a bunch of commands in get where you can register call backs as scripts to either do like validation or seen some people use it to like send emails or like close tickets all sorts of other The main focus around get hooks to me is the pre commit hook where you can do glinting. And Code Validation Code formatting you can run tests or other stuff like that I guess the pre push hook is another one that's also kind of big in that same space where you want to do validation of your changes before you send them off to like. Right. So you like maybe reject some kind of reject the get push if the formatting is wrong or the header is missing or something like that, right you can take a lot of those like. Easy validate things and do them in a kind of a quick fast manner before you would do your larger test suite or something catch a syntax era before you spend a bunch of time spinning up systems, right? Well, speaking to see I to me this seems like the next natural progression from having I, do these tests, right so there's different levels. The developer should probably be reading in running tests and making sure that the test passed they should be like formatting their code before they check it in stuff like that but when you work. On a team, my experience has been there's a wide wide range of how much people are willing to do that how much they care about those kinds of things and what that means is maybe you have CI continuous integration that runs automatically during check in once check has done and so then they might check in something might say, Oh, the bill does now broken because you didn't bother to run the test, but you broke the tests but because you didn't run them, you didn't know it. So now tree falls in a forest. Here's right. And that sort of thing, and so then you end up the situation, the people that care about the build, working half the track down the person who broke it who didn't actually care is just these layers of like annoying type of thing, and if you can make the push that validation to the location where the person is and all the people rights even if you care like, you might not want to break the build. You might rather just get a warning or just automatically have it fixed and pre-committed commit hook seemed like that's the natural place that. Kind of mentality I always had is. If I'm waiting 'til CIA to get feedback on nitpicks around commas or white space syntax or whatever that to me is way too late in the process because I've already like out you know I've pushed I've already gone off to the next thing I'm already answering my email are looking and get habitual user. Talking in slack or whatever and like I've already conduct switched to a completely different situation in I could've been. I assume do as good because. In pushed right I never make mistakes. So yeah, exactly. Zero Fault Code get pushed. The final action now you're done, right? Yeah but like it was. Frustrating. To make a push on, then have some either build system telling me that something was wrong or in view someone was like Oh awhile you could have reordered these imports. So they are alphabetical or something it's just like, yeah, this is a big waste time. Let's Kinda. Put this as far towards the developers possible such that we can be a better a better situation. The other thing I think is interesting around these ideas is. There's been studies that have shown that people are more willing to take. nitpicky advice from a computer than from human. There's like, okay. Well, the computer requires that I have this kind of white space for this kind of imitation are like this type of fort like you said, order alphabetical ordering or whatever, and when it comes from a person in a code review, it's like well, that person is just a jerk, right? I, wrote good coach. Taking this flack for this thing. So having this happen like automatically think takes away the need to review the kind of stuff. It takes away the need to complain and be that that person that does that you can even go farther with tools like black where it doesn't just complain a just goes I fixed it for you actually the way that I usually talk about this like the absolute. The worst situation that a human tells you that something is wrong the next situation that like. A CI system tells you that something's wrong better than that. Is that an automated local tool tells you that something is wrong and the Golden Standard is that an automated tool just fixes it for me I. Don't don't have to worry about it all it just makes it happen. Yeah, and it also results. You don't have this sort of like dueling alternate format style, right? Like if I like working pie chart, you'd like to work in vs code our formatting rules vary ever so slightly. Commas between parameters or there to space between the Coal Nana type annotation. We both reformatting document they cycle back and forth right and this way you can sort of just hit it with the same format. Right before goes every time. Of course I'm at also helps with things like get blame really noticing when patches or

Coming up next