
"Hey I'd like to split these changes to the same file into several commits!"
Source:R/exo-split-changes.R
exo_split_changes.RdI made many edits to a file, in different places.
This is too much for a commit, since small commits are best practice.
I need to add the changes to Git bit by bit.
The tool for that is git add --patch, also available as git add -p.
If all your changes are presented to you as one chunk by git add --patch,
choose the "s" option for splitting.
See https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging#_staging_patches.
Note that patch is also an option for git commit, if you prefer so.
Workflow
Running the function will create the exercise as a new folder in parent_path.
If called from RStudio or Positron, the function will open a new R session in
that IDE.
If not, the user will need to navigate to the path returned by the function,
and launch an R session from there.
The new R session will display messages about what challenge to solve,
and running the tip() function from that new R session will display
additional guiance.
Examples
if (FALSE) { # interactive()
parent_path <- withr::local_tempdir()
path <- exo_split_changes(parent_path = parent_path)
}