[This article was first published on Maëlle's R blog on Maëlle Salmon's personal website, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)


Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.

I got more confident with Git since reading Git in practice. This has resulted in a more enjoyable Git practice! I’m also more keen to sharing Git “tips” with others, but felt it was challenging to quickly come up with examples to demo some Git workflows. This is what motivated my creating saperlipopette, an R package containing small Git playgrounds to practice various Git commands and strategies!

What is saperlipopette?

The saperlipopette package creates Git messes, or playgrounds, that users need to solve. Part of the exercises are inspired by the wonderful website Oh Shit, Git!?! by Katie Sylor-Miller; others reflect commands that I’ve enjoyed using… or that I’d like to use one day, like git bisect, so the list is partly aspirational!

While saperlipopette itself makes good use of the gert package under the hood, the users can solve the Git messes any way they like, be it with some sort of Git interface, the command line, etc. The package provides no checking of solutions. You get a new folder with a Git mess inside, some tips, and you are the one defining success at the end of one try, by looking at your Git history. Because re-creating an exercise folder only demands your running a function, you can re-create the exercise as needed.

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. You can say “Saperlipopette, Git!”.

How to use saperlipopette?

Setup

You can install the development version of saperlipopette like so:

pak::pak("maelle/saperlipopette")

You’ll also need

  • a Git installation, but if you made it here you probably already use Git at least a bit.
  • basic Git knowledge, in particular being able to examine the Git history, be it with git log 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”.

Basic example

Let’s try the saperlipopette::exo_one_small_change() that goes with “Oh shit, I committed and immediately realized I need to make one small change!”.

library("saperlipopette")
parent_path <- withr::local_tempdir()
path <- exo_one_small_change(parent_path)
#> ℹ Follow along in /tmp/RtmpoAeVTm/file152cb747520d9/one-small-change!
# what's in path
fs::dir_tree(path)
#> /tmp/RtmpoAeVTm/file152cb747520d9/one-small-change
#> ├── R
#> └── bla
# with Git in a command line: git log
# or the gert R package
gert::git_log(repo = path)
#> # A tibble: 2 × 6
#>   commit                          author time                files merge message
#> * <chr>                           <chr>  <dttm>              <int> <lgl> <chr>
#> 1 2ff0d31f566e68ae0ee94b6028a3fa… Jane … 2023-12-15 16:25:00     1 FALSE "feat:…
#> 2 e227ecc55e421f70b6e30602e6a2ee… Jane … 2023-12-15 16:25:00     2 FALSE "First…

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 the corresponding ohshitgit entry if relevant. 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 before and after this.

#> ✖ "Oh shit, I committed and immediately realized I need to make one small change!"
#> ✖ I wanted to list 3 things in my bla file, not only two!
#> ℹ See <https://ohshitgit.com/#change-last-commit>
#> ℹ For more help use `tip()`

If they need more instructions than what is initially provided, the user can run:

tip()
#> • Add 'thing 3' to the bla file and save it.
#> • Add 'bla' file to Git.
#> • `git commit --amend --no-edit`
#> • Examine Git history.

That interface relies on adding an (.gitignored!) .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 could be useful when teaching a group: everyone should be looking at the same hashes on their machine, except for those commits they create themselves.

Feedback welcome!

In this post I introduced the saperlipopette package whose aim is to help users practice their Git skills in a safe (because throw-away) environment! I am very grateful to Jim Gardner for useful feedback and would love to hear from more users, if saperlipopette is of any interest to you.

To leave a comment for the author, please follow the link and comment on their blog: Maëlle's R blog on Maëlle Salmon's personal website.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you’re looking to post or find an R/data-science job.


Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.

Continue reading: Introducing saperlipopette, a package to practice Git!

Focusing on saperlipopette, an Innovative Package to Practice Git

In this article, we unveil the benefits and functions of saperlipopette – a package designed to enhance users’ Git skills and offer a ‘playground’ for experimenting with various Git procedures. Git is a fundamental tool in modern development workflows. Still, many developers struggle with mastering its commands and processes, creating a learning gap that saperlipopette hopes to bridge.

Understanding saperlipopette: An Intuitive Git Learning Platform

Saperlipopette is an innovatively designed R package that enables users with Git experience to practice their Git commands and strategies. Through the creation of Git messes, or problem scenarios, users have the opportunity to test their ability to solve and manage these situations. The package draws inspiration from Katie Sylor-Miller’s website, Oh Shit, Git!?! while adding new commands and strategies for users to explore.

The package doesn’t provide checks on the user’s work. Instead, it provides a new folder featuring a Git mess and some tips to help users troubleshoot issues. Users determine their success by evaluating their own Git history.

Saperlipopette is designed to complement existing resources like “Oh Shit, Git!?!” hence its aptly chosen name ‘saperlipopette’, an old-fashioned French exclamation synonmous with surprise.

Deep Dive into saperlipopette’s Usage

Saperlipopette installation and setup follows the standard R convention. A few requirements are necessary, ranging from a basic Git proficiency to a directory for exercise storage. Post-installation, using saperlipopette is as simple as running an exercise function. The exercises rely on pre-set Git authors, committers, and dates to ensure the automatic representation of the same hashes which helps greatly when teaching.

Long-term Implications and Future Developments of saperlipopette

The development of saperlipopette signals the expanding efforts to bolster the adoption and understanding of vital developer tools such as Git. This tool can provide fundamental relief for developers struggling with Git’s steep learning curve.

Potential Expansions

  • Comprehensive Lessons: While the lack of checks on user solutions provides autonomy, it might also leave room for misunderstanding or confusion. A future version of saperlipopette could potentially incorporate comprehensive lessons and checks to further guide users with less experience.
  • Broadened Command Landscape: The package today focuses on a select set of Git commands. As Git maintains a wide and frequently updated catalogue, there is an opportunity for the inclusion of further lessons covering additional commands in the future.

Actionable Advice: Enhancing your Git proficiency with saperlipopette

  1. Embrace the Playground: Use the playground provided by saperlipopette to experiment and practice Git commands diligently. It provides a safe environment, so any mess created won’t have lasting impacts.
  2. Leverage Your Resource: The https://ohshitgit.com/ website serves as a good beginner-friendly resource to learn basic Git troubleshooting. Pair it with saperlipopette for an enhanced learning experience.
  3. Review Your Progress: Remember, success in each exercise is dependant on your evaluation of your Git history. Keep a close eye on your progress and seek to grasp how different actions impact your Git history.
  4. Apply Your Knowledge: Learning isn’t just about practice; it also involves application. Apply your skills to real-life projects and see how your understanding of Git can improve your workflow efficiency.

In conclusion, saperlipopette is a promising tool for developers looking to refine their Git skills. As an industry, we should maintain supportive feedback lines with its creators to ensure its evolution in response to user demands and needs.

Final Thoughts

Remember that mastery comes with practice. Keep using your Git commands and strategies, and soon they will become second nature in your development process.

Read the original article