Skip to contents

Serves one folder until a launcher stops it with POST api/v1/shutdown (or the process is killed). Unlike open_repo() it blocks, never opens a browser, needs an explicit port, and prints one line to standard output once the socket is bound:

Usage

gitneighbr_serve(
  repo,
  port,
  git,
  api_token,
  host = "127.0.0.1",
  base_path = "/",
  shutdown_token = NULL,
  features = "local",
  git_config = NULL,
  policy_file = NULL,
  pass_env = character(),
  git_exec_path = NULL
)

Arguments

repo

The folder to serve.

port

Loopback port to listen on.

git

Absolute path to the git executable to run.

api_token

Token required on every request except health.

host

Loopback host: "127.0.0.1" (default) or "localhost".

base_path

The URL path a reverse proxy serves the app under.

shutdown_token

Token that POST api/v1/shutdown must carry in the X-Gitneighbr-Shutdown-Token header. Without it there is no shutdown route.

features

Comma-separated features to offer (see Details). Always includes "local".

git_config

The only Git configuration file read besides the repository's own, and where the identity form saves a name and email. A launcher passes a file it owns, outside the folder. Without it a temporary file is used and identity lasts for this session only.

policy_file

A launcher policy file (JSON, outside the folder): how to group files, which paths no action may change, which need extra review before sending, and suggested .gitignore rules to offer when the folder is first set up. See vignette("launcher").

pass_env

Names of environment variables (besides a small fixed set such as HOME, PATH and the locale) to pass to Git unchanged.

git_exec_path

Git's helper folder, for a Git build that needs it named (one that isn't relocatable on its own). Must be an absolute folder.

Value

Invisibly, 0L once the server has stopped.

Details

GITNEIGHBR_READY {"url":"http://127.0.0.1:<port><base_path>",...}

The session token is never placed in a URL. A launcher's reverse proxy passes it on every request in the X-Gitneighbr-Token header; the page itself never sees it.

inst/scripts/serve.R is the command-line form of this function; see vignette("launcher").

Git in a managed session

Git runs with none of the computer's or the user's own configuration (on Windows, gitneighbr supplies Git for Windows' defaults for line endings and certificate checks instead), no inherited GIT_* or SSH_* variables, hooks, fsmonitor, pagers, signing and credential helpers switched off, external diff and text-conversion programs off, and HTTPS as the only transport. A repository whose own settings or attributes need anything else (a filter such as Git LFS, an include, an unknown setting), that lives inside another repository, or that reads from outside its folder is shown as unsupported and can't be changed.