Effective PyCharm Transcripts
Chapter: Source control
Lecture: PyCharm git flow and PRs
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Let's begin our exploration of this git flow in PyCharm by creating an issue. Let's suppose one of the problems is our little podcast downloader thing
0:11
it doesn't get the latest episodes, potentially, there's actually no way for it to know what the latest episodes are the way that we created the api.
0:20
I'm going to come over here and say add latest episode tracking that's not a great word for it,
0:29
but we'll go with that the latest episode tracking for downloader. I'll assign it to myself, I'm going to label that as an enhancement.
0:38
This is the description, so we'll come back to that later. We have our issue being created, and our issue is a number 2, remember that number.
0:52
So we'll go over to PyCharm, and first of all, notice we have no pending check in changes and we can also update to make sure we have the latest,
1:00
we're on master, all files are up to date, great. Now what we want to do is, I would like to work with that work flow
1:08
I would actually like PyCharm to know about not just git but github and the issues— how do I do that? Well, it's not anything I've shown you yet
1:16
it's hiding up here under tools, not under version control. So if we go to tools Tasks & Contexts, we can go over here and configure servers
1:25
this is a lot not obvious, but this is how you do it, you go to servers and you say, I'm configuring—
1:31
look at all those bug tracking things, YouTrack, Jira, FogBugz, Trello, GitLab, but we're going to add github.
1:43
So I'm going to come over here and I am going to put my username and then we need the repository name, so that is this part right there
1:53
I am going to put that there, and now what I need to do is put an api token in there and I could press create
1:58
but this is actually kind of sensitive, so I'm not going to show you this. Okay, I pressed okay, and notice up here,
2:08
I was kind of hiding that, played with it a bit, this little default task thing has appeared, and if I go under tools, task, I can now open a task
2:18
either way I could do it here or there, but if i click on this notice that I get some stuff right here,
2:25
we have random common things that we've done recently, these are like check ins and stuff or I can hit open.
2:31
Now, if you wait for a second, this will download the various issues so these are basically repository name-issue number 2
2:42
so add the latest episode tracking for downloader, yes that's what we want to do, let's do that. So I click it and it says okay great,
2:48
what we're going to do is we can clear the current context, we're going to create a change list for all the changes
2:54
we could even shelve pending changes, if I had them; create a new branch, I don't like this name here
2:59
so I like to do this in mickeckennedy username something about the issue so we'll say 2-track feature, or let's call it track latest.
3:10
Okay, notice we're going to branch it from master here or we could actually use an existing branch if we want but I'm going do this git work flow
3:20
go to the issue, create a branch, a feature branch for it, base it on master so when we merge it back
3:25
it's going to go back into master and we'll go from there. So immediately notice down here, we're in this new local branch that's getting checked out
3:33
up here it tells us what we're working on, things like that and we'll just go do our work.
3:38
So let's go down here, and the reason that we don't really know the ending, is if we look at this api in this thing there's really only two functions,
3:48
there's download and then there's get_an_episode, give it the id and you get it back, maybe.
3:53
So, notice that here's a dictionary and it contains the keys the episode id so let's say get count, or let's say get latest show id
4:10
down here we'll just do something like return max of episode_data.keys all right, we'll probably test if that works
4:21
let's go up here, do a quick little print, print working with total format service. now we should have get our latest show id,
4:39
and then we'll use this again down at the bottom, so instead of going to random, we'll do that plus one so we're always working on the latest.
4:48
Let's go and give this a run and see if it's working. Hey look at that, if we go at the top we're working with 140 episodes, let's see if that's right.
5:00
Go to the episodes, 140, beautiful, so it looks like that is working and we're happy with it right, we've tested it, we made all of our changes.
5:12
Okay, so what we're ready to do, notice, we have pending changes, both these were changed
5:16
and we're going to go over here and I would like to close this task tools, task say close active task
5:27
and when it says that, it's like okay what do we want to do, do we want to commit the changes, do we want to merge the branches back together;
5:33
do we want to update the issue state to make it resolved? So notice over here, if I refresh— still open. Okay, let's do it.
5:50
So we've deleted the branch, we've merged it into master, notice we're back on master here, go over here refresh the issue state is now closed,
6:05
and do we have a closed pr? No. So you can see that was all done, if we go back to our master branch,
6:18
we've got this change that happened just a minute ago, let's go look and see if it actually made the change here.
6:30
It looks like it did not, so all we have left is this sort of "random gets" so check that in, so over here we just have the two functions
6:36
we have download and get episode so we're missing or get link because we have not yet actually created the pr for this
6:46
so we got to go over here and say compare this so this fixes issue number two, notice, we even get little intellisense, thank you github.
6:57
So we can go create this pr, maybe someone else or even me will come along and say, oh look there's an open pull request I need to deal with it,
7:06
in here and I can merge it, confirm my merge, change if I really want I could delete that branch if we go back to master,
7:26
we now have this check in here, not the greatest name but if we look at service, we have our new little feature thing,
7:34
it's hard to call it much of a feature, but you know what, there it is. Now if we go over here and we look at it,
7:41
do we have it yet— yes, it is merged in locally PyCharm did that for us, but it didn't do the pr
7:48
actually, the more I think about it, probably following the git flow I don't think I would merge it locally into my branch
7:53
or close the associated issue, I think I would go over to github and do that
7:58
but if you're not working with github maybe it makes more sense to do it this way.
8:02
Either way, so if we go over here and we look to push our changes back notice, first of all, there should there be nothing to commit
8:12
other than unversioned files, if we over here and we do a push, git push we have this local merge that we did there,
8:21
I don't think that we really need to do that let's just do an update, alright, all files are up to date, now there's no change left to commit
8:34
because we kind of did it in those two places right like I said, I would do this in github rather than just in PyCharm.
8:41
Now we can go over here and just go back to our default task it says our empty change list is no longer active, that's great
8:48
so let's just get rid of it. Alright, there you have it, that's the git flow in PyCharm.