NBISweden / module-rstudio-intro-dm-practices

https://nbisweden.github.io/module-rstudio-intro-dm-practices/
Other
0 stars 0 forks source link

Configure RStudio to use GitHub Desktop #2

Open wna-se opened 2 months ago

wna-se commented 2 months ago

The following could be used to get the path for the git binary included with GitHub Desktop for macOS:

find_github_desktop_bin <- function() {
  apple_script = "use framework \"Foundation\"
  use framework \"AppKit\"

  set bundleID to id of application \"GitHub Desktop\"
  set theWorkspace to current application's NSWorkspace's sharedWorkspace()
  set thePath to ((theWorkspace's URLForApplicationWithBundleIdentifier:bundleID)'s |path|()) as text
  return thePath"

  github_desktop_base <- system(paste('osascript','-e', shQuote(apple_script)), intern = TRUE)
  github_desktop_bin <- paste(github_desktop_base, '/Contents/Resources/app/git/bin/git', sep='')
  return(github_desktop_bin)
}

The following can be used to set the configuration in RStudio: rstudioapi::writeRStudioPreference('git_exe_path', find_github_desktop_bin())

wna-se commented 2 months ago

Could probably be combined with

Sys.info()["sysname"]=="Darwin" # "Windows", "Linux" ?

And the the Windows location seems to be %LOCALAPPDATA%\GitHubDesktop\app-[gfw-version]\resources\app\git\cmd\git.exe. There might be some commands [1, 2, 3] to locate program executable?

wna-se commented 2 months ago

The git version embedded in GitHub Desktop does not support the commands that RStudio use for pushing or pulling. Other than that the functions for adding, committing and reverting files seems to work.