-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account for "Git: ... no available repositories" in rstudioapi::executeCommand("vcsRefresh")
#2697
Comments
I've looked into this a bit more and I suspect @hadley's hypothesis of a race condition is correct: Changing the definition of rstudio_git_tickle <- function() {
if (uses_git() && rstudioapi::hasFun("executeCommand")) {
rstudioapi::executeCommand("vcsRefresh")
}
invisible()
} So now I think I may be wrong about this having (only?) to do with |
This comes up, as described in #4002, when you run |
Goes along with posit-dev/ark#449 I was thinking about how to address #2697 and have a proposed approach in this PR plus the accompanying PR for ark. I looked at how various extensions (like the git extension, etc) check for whether we are in a git repo in the workspace and all that checking is typically based on context keys. In an extension specifically, you can check those keys with a ["when" clause](https://code.visualstudio.com/api/references/when-clause-contexts) and I realized that approach (i.e. a string) could work well as an OpenRPC method and would be flexible for other context keys we will need to check when we are not in the main thread. Alternatively, we could add methods to return more specific info (are we in a git repo? etc etc etc) but I like the idea of using "when" clauses for this, like an extension could directly for commands, etc. ### QA Notes Evaluating code like this in R should show the correct results for your situation: ```r .ps.ui.evaluateWhenClause("isLinux || isWindows") .ps.ui.evaluateWhenClause("isMac") .ps.ui.evaluateWhenClause("gitOpenRepositoryCount >= 1") ``` --------- Signed-off-by: Julia Silge <[email protected]>
To verify this, there are a couple of options but probably the most direct/easy is to run |
Verified Fixed
Test scenario(s)rstudioapi::executeCommand("vcsRefresh") in a git repo and a plain folder. Link(s) to TestRail test cases run or created: |
Reported in private beta: https://github.com/posit-dev/positron-beta/discussions/63
Apparently,
rstudioapi::executeCommand("vcsRefresh")
is a silent no-op in RStudio if the current project is not a Git repo.However, in Positron, this creates a pop-up (which can just be dismissed, but it's still distracting/confusing):
usethis calls its internal
rstudio_git_tickle()
often to force RStudio to refresh its git pane. This was done in reaction to confusion if "Git facts" have changed on the ground, but the RStudio UI didn't reflect that.It seems like
vcsRefresh
might require a bit more wrapping in our rstudioapi shim, i.e. do some sort of pre-check.https://github.com/r-lib/usethis/blob/9e64daf13ac1636187d59e6446d9526a414d8ba6/R/rstudio.R#L184-L189
The text was updated successfully, but these errors were encountered: