Chapter: 6 Putting It All Together
6.1 The Workflow
6.1.1 Before we start coding, let’s make sure were up to date.
6.1.2 Create a branch to work on a new feature or bugfix
6.1.3 Load the devtools
library
6.1.4 Abide by the Repeaded Amend strategy
We should make commits often. We should make amends even more often, so
if our code ever breaks in horrible ways, we can easily discard our work since
the last amend with git reset --hard
First: Make a small change to your code.
Next:
# When you want to test the changes you've made by running code, first execute ...
load_all()
# ... in your console. This function **simulates** that your updated code has been added to your package
# so you can play aroud with it without actually building the changes into all of your package files.
# This means you can load_all (as opposed to build) at any time in development without having to
# rebuild after correcting a mistake
# [VERIFY YOUR UPDATED CODE WORKS (by running code or test cases)]
commit add <files> <you> <just> <updated>
# This next bit goes one of two ways
# 1. If you haven't created a new commit yet...
commit -m "Describe the feature or bugfix"
# 2. If you want to add more changes on top of a commit you've already started...
commit --amend
Finally: Repeat until you’ve correctly implemented a new functionality.
6.1.5 Integrate Changes with the Package
The check()
function does three things for us: it updates our roxygen
documentation, it runs our testthat
test files,
and it checks for a bunch of things that make sure we’ve implemented our code well.
- Run the
devtools::check(cleanup=TRUE)
function - Fix the first error or warning
- Repeat steps (1) and (2) until all errors and warnings are resolved.
git commit --amend
one last time. Make sure to include all those files produced or updated by the check function, even if you didn’t write it yourself.
6.1.6 Incorperate Upstream Changes
Before you create a pull request, you’ll want to make sure you’ve incorperated upstream changes into your feature branch.
6.1.7 Congratulations!
You have successfully create a feature, and you may submit a pull request :blush: