class: center, middle, inverse, title-slide # Uncoast Unconf Preparation ## usethis ### 2019-04-07 --- class: inverse ## Welcome Back! ### Review - We want to be ready to collaborate when we get to Des Moines! -- - If you're happy with your setup, no need to do anything. -- - If you haven't gone through the past three weeks, please do so. -- - Reference: [What They Forgot to Teach You About R](https://whattheyforgot.org/index.html) by Jenny Bryan and Jim Hester. -- - If you have any questions: - you can file a [GitHub issue](https://github.com/uncoast-unconf/uu-2019-day-zero/issues/12), or email ian [dot] lyttle [at] se [dot] com --- ## usethis - There’s a lot repetitive things package-development (and in project workflows), but painful if it gets messed-up. -- - This is the motivation behind the usethis package. -- - Just had a CRAN release (thanks to Jenny Bryan and her coworkers for the excellent timing)! - This week, everything in the Console pane: ```r install.packages(c("usethis", "reprex")) ``` - You may wish to load the package for the next few steps: ```r library("usethis") ``` --- ### How can I find out about my git and GitHub setup? - There’s a function for that: ```r git_sitrep() ``` ``` Git user * Name: <unset> * Email: <unset> * Vaccinated: FALSE usethis + git2r * Default usethis protocol: <unset> * git2r supports SSH: TRUE * Credentials: '<usethis + git2r default behaviour>' GitHub * Personal access token: <unset> ``` -- ---- - Your response may look different; that's OK. - First we look for: `Git user` > `Vaccinated` --- ### How to I stay safe with git? - Want to prevent committing stuff to git that can contain credentials. - `git_vaccinate()` adds files to your global git-ignore file. ```r git_vaccinate() ``` --- ### How to I stay safe with git? ```r git_sitrep() ``` -- ``` Git user * Name: <unset> * Email: <unset> * Vaccinated: TRUE usethis + git2r * Default usethis protocol: <unset> * git2r supports SSH: TRUE * Credentials: '<usethis + git2r default behaviour>' GitHub * Personal access token: <unset> ``` -- ---- `Git user`: - ✅ `Vaccinated: TRUE` Next we look for: `Git user` > `Name` and `Email` --- ### How do I configure my git? - Git and GitHub use your name and email address to keep track of who commits what. - Your email has to be an email you have registered with GitHub. - To remind yourself what emails you set at GitHub: `https://github.com/settings/emails` If you need to set or update these: ```r use_git_config(user.name = "Ian Lyttle", user.email = "ian.lyttle@schneider-electric.com") ``` --- ### How do I configure my git? ```r git_sitrep() ``` -- ``` Git user * Name: 'Ian Lyttle' * Email: 'ian.lyttle@schneider-electric.com' * Vaccinated: TRUE usethis + git2r * Default usethis protocol: <unset> * git2r supports SSH: TRUE * Credentials: '<usethis + git2r default behaviour>' GitHub * Personal access token: <unset> ``` -- ---- `Git user`: - ✅ `Vaccinated: TRUE` - ✅ `Name:` is correct - ✅ `Email:` is correct Next we look for: `GitHub` > `Personal access token` --- ### How do we make it easy to authenticate to GitHub? - GitHub personal access-token (PAT) - treat this like a username + password -- - Prepare by opening your `.Renviron` file: - single known-place we can keep things like credentials - if you work with a firewall, you might use for proxy settings -- ```r edit_r_environ() ``` - Use this [starter file](https://gist.github.com/ijlyttle/dee4a89c8528cd4a0a319bb7b8cdd51a): - If you already have a `.Renviron` file, save a backup copy, then pick-and-choose useful bits from the starter for your `.Renviron` file. - If you don't have a `.Renviron` file (empty), copy the starter entirely. - Modify the value of `GITHUB_PAT`; you will need to get your own. --- ### How do we make it easy to authenticate to GitHub? - Next, we need to get a PAT. - Use `browse_github_pat()`: - you may wish associate the PAT with the computer - should the computer go away, delete the PAT for that computer -- ```r browse_github_pat(description = "your-custom-name-here") ``` - This opens a browser page to generate a GitHub PAT: - you may need your GitHub credentials - generate the PAT - save it to your clipboard -- - Copy the PAT into your `.Renviron` file: - up to you if you want to surround the PAT in quotes -- - Make sure `.Renviron` ends with a newline! - Restart your R session. --- ### How do we make it easy to authenticate to GitHub? ```r usethis::git_sitrep() ``` -- ``` Git user * Name: 'Ian Lyttle' * Email: 'ian.lyttle@schneider-electric.com' * Vaccinated: TRUE usethis + git2r * Default usethis protocol: <unset> * git2r supports SSH: TRUE * Credentials: '<usethis + git2r default behaviour>' GitHub * Personal access token: '<found in env var>' * User: 'ijlyttle' * Name: 'Ian Lyttle' ``` -- ---- `GitHub`: - ✅ `Personal access token: '<found in env var>'` - ✅ `User:` is correct - ✅ `Name:` is correct --- ### How do I make sure I use the git protocol that I expect to? -- - What?!? -- - There are two ways we can access a remote repository using git: - `https` - `ssh` - They are both good, but `https` can be easier to set up for the first time. - If things are working for you using `ssh`, that's fine - please proceed. -- - We set this preference in the `.Rprofile` file. - `.Renviron` helps us be **safe** - `.Rprofile` helps us be **lazy** --- ### How do I make sure I use the git protocol that I expect to? ```r usethis::edit_r_profile() ``` Use this [starter file](https://gist.github.com/ijlyttle/dee4a89c8528cd4a0a319bb7b8cdd51a): - If you already have a `.Rprofile` file, save a backup copy, then pick-and-choose useful bits from the starter for your `.Rprofile` file: - in `options()`, set `usethis.protocol = "https"` - if you have set up ssh, and want to keep using it, set to `"ssh"` - other options and startup packages may be interesting - If you don't have a `.Rprofile` file (empty), copy the starter entirely. - change to your name, email address, etc. Make sure `.Rprofile` ends with a newline! When you're done editing `.Rprofile`, save it, then restart R. --- ### How do I make sure I use the git protocol that I expect to? ```r git_sitrep() ``` -- ``` Git user * Name: 'Ian Lyttle' * Email: 'ian.lyttle@schneider-electric.com' * Vaccinated: TRUE usethis + git2r * Default usethis protocol: 'https' * git2r supports SSH: TRUE * Credentials: '<usethis + git2r default behaviour>' GitHub * Personal access token: '<found in env var>' * User: 'ijlyttle' * Name: 'Ian Lyttle' ``` -- ---- `usethis + git2r`: - ✅ `Default usethis protocol:` either `'https'` or `'ssh'` (your choice) --- ### Verify ```r git_sitrep() ``` `Git user`: - ✅ `Vaccinated: TRUE` - ✅ `Name:` is correct - ✅ `Email:` is correct `usethis + git2r`: - ✅ `Default usethis protocol:` either `'https'` or `'ssh'` (your choice) `GitHub`: - ✅ `Personal access token: '<found in env var>'` - ✅ `User:` is correct - ✅ `Name:` is correct --- class: inverse ### 🎉 🥳 We have finished our preparations! 🎉 🎉 -- - If you have any questions: - you can file a [GitHub issue](https://github.com/uncoast-unconf/uu-2019-day-zero/issues/12), or email ian [dot] lyttle [at] se [dot] com -- ### Thanks for your patience! -- ### See you in Des Moines! 🚗 ✈️