Using and Mastering Cookiecutter Transcripts
Chapter: Adding features to Cookiecutter
Lecture: Concept: Modifying cookiecutter

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Now that we've worked through actually adding a feature
0:04 or enhancement to Cookiecutter
0:07 let's go back and review the core concepts or steps that we needed.
0:10 So, we're going to start by forking the Cookiecutter repo
0:14 so
0:17 and we're going to fork that to our own repository.
0:20 Next, we want to clone that locally so we can work with the source
0:24 so git clone our cookiecutter fork- downloads and then we're ready to go,
0:30 just make sure that that is your user name not audreyr,
0:34 because if it's audreyr you probably can't make changes
0:36 and submit fixes back to the repository.
0:39 Next, we're going to create a feature branch.
0:41 This is partly optional, but I strongly recommend you create a feature branch,
0:45 and this whole PR work flow, so probably you can just go to the top of the list
0:50 I have changes on mine I had to go back a little bit
0:54 because I tweaked my fork for some other reasons
0:57 you can read them there in the list
0:59 but I went back to this one that's highlighted and I said create a branch from there
1:03 and you saw my convention, my github name / feature or fix branch name
1:08 make sure it's all underscores or something like that
1:11 so we checked it out and it was ready for us to start working on it.
1:14 Next, we have to create a virtual environment;
1:17 technically is not required but you probably don't want to run
1:21 your dev version of Cookiecutter as your main thing on your computer
1:24 maybe you do, but let's go ahead and create a virtual environment here
1:30 so we're going to make sure we have, in Python 2 we have virtualenv
1:33 remember on Windows pip2 doesn't exist,
1:35 you just have to make sure you use pip out of Python 2.
1:38 Okay, so we've installed it, next we can create the virtual environment
1:40 again making sure we're using the Python 2 version
1:43 so python2 -m virtualenv .env (-m for module)
1:48 and then we activated it, and notice how when we activated the prompt changed
1:52 okay so now we're ready to basically register the local dev package
1:58 as something we can run.
2:00 So we're going to do that when I register the dev package
2:03 so we just say python develop, not install or any of these things,
2:07 python develop, so that means
2:10 the local it's going to basically run out of our source directory
2:13 so as we make changes, those changes will immediately appear
2:16 in this virtual environment, so if we run this it does a whole bunch of work
2:19 to install the dependencies and then finally when it's done
2:21 we have cookiecutter 1.5.1 or whatever version you have
2:26 registered and ready to run from the command line.
2:29 Finally we go and make our change, we've got it ready to run locally
2:32 so we can test it, we've got our branch checked out for our feature
2:36 in our case I was really bugged by that missing by that weird pars error in YAML
2:42 and so I went and fixed that by adding a newline at the end
2:46 if there wasn't one right, it didn't really make a change to the contents of the file
2:51 but it made it parseable even if it wasn't there.
2:54 Make sure you follow the conventions that they use in Cookiecutter
2:57 and notice the u for Unicode, so we were using Python 2
3:02 because it's little less forgiving and some other the things
3:06 and it's a little easier for me, at least to remind myself
3:09 I'll put the u for Unicode rather than in Python 3 where it's not required
3:12 ok so we made our change here, then we're going to check in our change
3:17 and we're going to give it a detailed description
3:19 notice we have a detailed description for the people reviewing the PR
3:22 and were pushing the changes to mikeyckennedy/ in this case forgiving YAML fix,
3:27 whatever the name of our feature branch is.
3:30 Finally, once that's done, we go back to GitHub to our repo
3:33 click the button to create the pull request, and boom,
3:36 then our pull request is here,
3:39 one final note, notice down here at the bottom,
3:41 there is 3 checkins with my picture next to it,
3:43 it says if the YAML config file does not end with the single blank line, it has an X
3:47 now I ran the tox tests and I guess I didn't look carefully enough,
3:51 I just figured oh no, I don't have flake 8 installed or whatever,
3:54 and that didn't work, but it actually didn't work when I checked it in here,
3:57 this comes from the continuous integration, on the server, on the git repo,
4:02 that they have configured, and what happened was,
4:05 I had actually my docstring was 83 characters long
4:10 and they have a restriction that says 79 columns or fewer in any given line,
4:17 so notice I actually made another change I fixed that format in the docstring
4:22 and I just checked it back into my repo, to that branch
4:25 and it automatically updates the pull request, and finally,
4:28 it went all green everything was happy, everything passed.
4:31 Alright, do you have a great idea to make Cookiecutter better,
4:34 now you know how to develop and do contributions back to it.