Skip to contents

Launches a local, loopback-only web server for the Git repository at path and (by default) opens it in the browser. Returns immediately: the server runs in an independent background process, so the R console is never blocked. Stop it later with session$stop() or stop_session().

Usage

open_repo(
  path = ".",
  browse = interactive(),
  host = getOption("gitneighbr.host", "127.0.0.1"),
  port = getOption("gitneighbr.port", 0L),
  git = getOption("gitneighbr.git", unname(Sys.which("git")))
)

Arguments

path

Path inside the Git working tree to serve. Defaults to the current directory.

browse

Whether to open the app in the default browser. Defaults to TRUE in interactive sessions.

host

Loopback host to bind to. Only "127.0.0.1"/"localhost" are supported.

port

Port to bind to, or 0L (the default) to pick a free port.

git

Path to the git executable.

Value

A gitneighbr_session object, invisibly-printable and safe to discard (the server keeps running; recover it later with stop_session() using the port).

Details

path need not already be a Git repository: if it isn't, the app opens to a guided onboarding screen that can initialize a new repository there or clone an existing GitHub repository into it (spec Sec 22, 0.2.0). A bare repository (no working tree) is still refused outright, since there is no in-app story for one.

Examples

if (FALSE) { # \dontrun{
session <- open_repo()
session$stop()
} # }