https://github.com/ropensci-training/saperlipopette
Exercises (playgrounds) to go with ohshitgit and beyond, for R users
https://github.com/ropensci-training/saperlipopette
git rstats rstats-package
Last synced: 4 months ago
JSON representation
Exercises (playgrounds) to go with ohshitgit and beyond, for R users
- Host: GitHub
- URL: https://github.com/ropensci-training/saperlipopette
- Owner: ropensci-training
- License: other
- Created: 2023-12-15T14:04:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-02-18T15:27:04.000Z (5 months ago)
- Last Synced: 2026-02-18T19:22:55.736Z (5 months ago)
- Topics: git, rstats, rstats-package
- Language: R
- Homepage: https://docs.ropensci.org/saperlipopette/
- Size: 5.06 MB
- Stars: 32
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - maelle/saperlipopette - Exercises (playgrounds) to go with ohshitgit and beyond, for R users (R)
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# saperlipopette
[](https://github.com/ropensci-training/saperlipopette/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/ropensci-training/saperlipopette)
The goal of saperlipopette is to hold functions creating Git exercises,
that users solve using their local and usual tools.
## Installation
You can install the development version of saperlipopette like so, from R-universe:
```r
install.packages(
'saperlipopette',
repos = c('https://packages.ropensci.org', 'https://cloud.r-project.org')
)
```
Or from GitHub:
``` r
# install.packages("pak")
pak::pak("ropensci-training/saperlipopette")
```
You'll also need
- a [Git installation](https://happygitwithr.com/install-git), but if you made it here you probably already use Git at least a bit.
- [basic Git knowledge](#recommended-resources-about-git), in particular being able to examine the Git history, be it with [git log](https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History) or a tool in your IDE.
- a directory where to store the exercises folder. In all examples we use a temporary directory but if you prefer, you could use a dedicated "scratch directory".
## Why this name?
This package is intended to be a companion to https://ohshitgit.com/,
so its name had to honour the exclamation.
"saperlipopette" is an [old-fashioned French exclamation](https://en.wiktionary.org/wiki/saperlipopette).
You can say "Saperlipopette, Git!".
## Example
```{r example}
library("saperlipopette")
parent_path <- withr::local_tempdir()
path <- exo_one_small_change(parent_path)
# what's in path
fs::dir_tree(path)
# with Git in a command line: git log
# or the gert R package
gert::git_log(repo = path)
```
At this stage, the user would open the newly created R project and launch an R session,
where messages would indicate them what to do,
and which URL to follow, to find, in this case, the corresponding ohshitgit entry.
In practice here the user would change a file, then Git add it, then run `git commit --amend --no-edit`.
The user would examine the [Git history](https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History) before and after this.
```{r, echo=FALSE}
source(system.file(
"exo_one_small_change-Rprofile.en.R",
package = "saperlipopette"
))
```
If they need more instructions than what is initially provided, the user can run:
```{r}
tip()
```
That interface relies on adding an `.Rprofile` to the newly created project,
with instructions formatted with the cli package.
We've set the Git author, committer and date so that the automatic commits get the same
hashes, which can be useful when teaching a group: everyone should be looking at the same hashes on their machine, except for those commits they create themselves.
Below we use `gert::git_log()`, as opposed to `git log` in a command line, because that integrates better with R Markdown that we use for building documentation.
```{r example2}
parent_path <- withr::local_tempdir()
path <- exo_one_small_change(parent_path)
gert::git_log(repo = path)
parent_path2 <- withr::local_tempdir()
path2 <- exo_one_small_change(parent_path2)
gert::git_log(repo = path2)
```
### Multilingual!
The saperlipopette can create messages in English (default) but also in French and Spanish.
Example in French:
```{r example-fr}
library("saperlipopette")
withr::local_language("fr")
parent_path <- withr::local_tempdir()
path <- exo_one_small_change(parent_path)
# what's in path
fs::dir_tree(path)
# with Git in a command line: git log
# or the gert R package
gert::git_log(repo = path)
```
```{r, echo=FALSE}
source(system.file(
"exo_one_small_change-Rprofile.fr.R",
package = "saperlipopette"
))
```
```{r}
tip()
```
## Exercises
Consult the [reference](https://docs.ropensci.org/saperlipopette/reference/index.html).
Exercises cover:
- Oh Shit, Git!: exercises inspired by https://ohshitgit.com/ by Katie Sylor-Miller.
- Clean history: exercises on how to get a clean Git history, for instance using rebase interactive.
- Use history: exercises on how to use the Git history, for instance using blame.
As an individual learner, pick what you want to learn or try out!
As an instructor, you can mix and match exercises: for instance focussing the session on solving common mistakes (Oh Shit, Git!) or on why and how to create a clean Git history (exercises from "Use history" then exercises from "Clean history").
Feel free to suggest new exercises by opening a GitHub [issue](https://github.com/ropensci-training/saperlipopette/issues).
## Recommended resources about Git
For beginners:
- [Happy Git with R](https://happygitwithr.com/)
- [Learn Git branching](https://learngitbranching.js.org/)
For users less new to Git:
- [Git in Practice by Mike McQuaid](https://masalmon.eu/2023/11/01/reading-notes-git-in-practice/)
- [Pro Git by Scott Chacon](https://masalmon.eu/2024/01/19/pro-git-scott-chacon-reading-notes/)