Visual Studio Code for Python Developers Transcripts
Chapter: Source Control with Git
Lecture: The GitHub PR (Pull Request) Extension

Login or purchase this course to watch this video and the rest of the course contents.
0:00 So one of the things that we want to do as developers, particularly when we're using Git, is sometimes you want to be able to create
0:07 what are called pull requests. Now with pull requests, I can create a separate branch, I can make some changes,
0:13 but I might want Brian or one of my other teammates to review it. So how do we do that? Well, I went ahead and created a pull request
0:20 and now using the GitHub pull request extension for VS Code, you can go in and install that from the extension marketplace,
0:28 and we've talked about that in previous videos. You can go ahead and create pull requests inside of VS Code, you can review them inside of VS Code,
0:35 and you can pretty much assign reviewers and do everything inside of VS Code, right? I hope you get the point there.
0:41 We're doing everything inside of VS Code, and we don't have to switch contexts going to different browsers or windows or anything of the sort.
0:48 So Brian, why don't we go ahead and take a look at that pull request I sent and show folks how we can work with those things
0:55 in the editor and then merge them and kind of keep our workflow going. - Sure. So I was just showing it in the GitHub marketplace extensions view.
1:04 If you wanted to search it that way, this is the official one from GitHub. I already have it installed. I'm gonna go over to it.
1:10 When you have it installed, you'll see the little GitHub icon in the activity bar. If it's not showing, it might be in these additional views
1:16 that you would slide down through in there to open it up. Now, once I do that, let's close this tab, you'll notice that there's pull requests
1:24 and then there's issues. And in this case, we wanna look at the pull request and automatically, if it's not showing there for you,
1:30 you can click the little refresh icon in the top of that collapsible region there, and then it should show up in all the open PRs that are there.
1:38 And now I can see Cecil's PR. I can click on the description and read it directly, guess where, inside of VS Code. I could see what the PR is about.
1:48 It's adding a custom header, the branch that's being used for that. What's really nice about this is I don't have to go to my terminal
1:55 to do the whole git commands to pull down, check out this branch, pull it, get the latest changes,
2:01 and then start being able to review it and run it locally. I can just click a button directly in this view right here.
2:07 I'm gonna do it right now, actually. It's fetching that branch, doing it for me. It might notify you to periodically run git fetch if you'd like.
2:15 I'm gonna say yes for now. And then it automatically brings me right to the changed files. This particular file, status router.py,
2:22 is what had changes that Cecil pushed to this branch and opened up the PR for. Now I can review them.
2:28 I can add comments by clicking on the little plus sign or the plus icon in the gutter area in the editor here.
2:33 And now let's close this so we get some better room. Do that again. And you can see I can start a discussion. In here I can make a suggestion.
2:41 All these things you might find familiar, if you're familiar with GitHub, and you're using that as your source control management
2:46 system and the UI on their website, a lot of, pretty much all, at least that I've had to use as a developer
2:53 operating within a project and doing things within a PR, all those capabilities that I'm used to using there
2:59 in the UI, I can just click on that and it's done. And I can see that the UI and the website are found here in VS Code,
3:03 allowing me not to have to switch contexts, and therefore just staying within my development environment.
3:11 So I can start a discussion, make a suggestion, start a review, or just add a comment on here. So I'm gonna say, hey, this is looking good to me.
3:20 Add that comment. But I'm gonna start a review. And what that does is it puts it in a pending mode
3:26 until I'm ready to officially send the review over to Cecil. I'm gonna say go to review on this. And in this case, I can say,
3:34 I can see what other comments maybe I had or as part of that review, I can send it as I wanna request changes.
3:41 There's a different statuses that you have with GitHub, right, when you're reviewing a PR. You can approve it, you can request changes,
3:47 or you can just submit a review like standalone. So in this case, I'm gonna approve it. That's great.
3:53 So you do it all right in Visual Studio Code, Cecil. Isn't that amazing? Like I don't have to jump out of anywhere.
3:57 Maybe it looks so good to me that I'm ready to merge this. I can merge it from here. I can choose what type of merge method I'm using.
4:03 Maybe it's a merge commit, a squash and merge, a rebase and merge, all that fun stuff, right in Visual Studio Code. Or you know what, Cecil?
4:10 I'm sorry, but I can't accept these changes. I'm gonna have to close the pull request, man. - No way, no. So I'm gonna have to submit another one.
4:17 Is that what you, are you gonna do that to me, for real? - Yeah, or Michael might merge it on us. - Oh. Michael, leave our PRs alone, please,
4:25 and thank you very much. But folks, hopefully you've seen how just staying within the editor, staying within VS Code allows you to work very easily
4:35 with Git, with GitHub, and you can create PRs, you could submit PRs, you could review PRs, you could look at changes and branches and pull requests,
4:43 and all these great types of things. And again, this is just additive to your workflow. If you wanna use the command line, you could still do that.
4:50 If you wanna go into the browser and use GitHub, GitLab, Bitbucket, whatever, you can still do that as well.
4:56 This is just another option for you to add. So depending on how you like to work or whatever your preferences, you could pick your poison, right?
5:03 You can kinda choose the way that you wanna do it. - Yep, and with that, folks, that will conclude this section of the course.
5:09 We'll have one more video to kinda do a rehash, recap of what we learned in this section, and then you can move on to the next one. Thanks.


Talk Python's Mastodon Michael Kennedy's Mastodon