devtools icon indicating copy to clipboard operation
devtools copied to clipboard

load_all with specific git ref

Open r2evans opened this issue 7 months ago • 1 comments

Is your feature request related to a problem? Please describe.

At times I need to manually step through a regression and see what commit caused the change in behavior. When the condition is easily handled programmatically, then git-bisect is a great way to go, but sometimes it's more nuanced and benefits from "human inspection".

Describe the solution you'd like

devtools::load_all("path/to/mypackage", ref="23eeb01")

It feels (to me) like this is more than what remotes:: offers, since I'm looking for the same "current environment side-effect" that devtools::load_all() provides. I imagine it might benefit from git2r if present (fallback to shell git).

Describe alternatives you've considered

(1) I tried remotes::install_git(repo, ref), but it has the undesired side-effect of installing an older version into my R library. I could use a temporary library to do this, but (1) it's a little slower, and (2) it doesn't load the package the same way that load_all() does. Further, if I had already load_all()'d (from the filesystem alone, no ref) the package into my R session, I'm "looking" at the wrong version.

(2) I was able to get the effect I wanted by using git worktrees:

$ cd path/to/mypackage
$ git worktree add _23ee 23eeb01

and in R

devtools::load_all("path/to/mypackage/_23ee")

(A more-advanced extension of this functionality would enable in-R git bisecting, perhaps iterating over head(git2r::commits(repo)), running R code after each load_all(repo, ref). While that's out of scope for this FR, I think there is value-added to be able to do that "in R" at times, even if it is not the first-stop recommendation.)

r2evans avatar Jun 09 '25 19:06 r2evans

Alternatively it would be good if when loading it reported the git branch or sha that it uses (if any). This would help to detect possible problems when loading branches from different packages in the same project.

llrs-roche avatar Jun 17 '25 15:06 llrs-roche