Documentation ¶
Overview ¶
Package vcweb serves version control repos for testing the go command.
It is loosely derived from golang.org/x/build/vcs-test/vcweb, which ran as a service hosted at vcs-test.golang.org.
When a repository URL is first requested, the vcweb Server dynamically regenerates the repository using a script interpreted by a script.Engine. The script produces the server's contents for a corresponding root URL and all subdirectories of that URL, which are then cached: subsequent requests for any URL generated by the script will serve the script's previous output until the script is modified.
The script engine includes all of the engine's default commands and conditions, as well as commands for each supported VCS binary (bzr, fossil, git, hg, and svn), a "handle" command that informs the script which protocol or handler to use to serve the request, and utilities "at" (which sets environment variables for Git timestamps) and "unquote" (which unquotes its argument as if it were a Go string literal).
The server's "/" endpoint provides a summary of the available scripts, and "/help" provides documentation for the script environment.
To run a standalone server based on the vcweb engine, use:
go test cmd/go/internal/vcweb/vcstest -v --port=0
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ScriptNotFoundError ¶
type ScriptNotFoundError struct {
// contains filtered or unexported fields
}
A ScriptNotFoundError indicates that the requested script file does not exist. (It typically wraps a "stat" error for the script file.)
func (ScriptNotFoundError) Error ¶
func (e ScriptNotFoundError) Error() string
func (ScriptNotFoundError) Unwrap ¶
func (e ScriptNotFoundError) Unwrap() error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server serves cached, dynamically-generated version control repositories.
func NewServer ¶
NewServer returns a Server that generates and serves repositories in workDir using the scripts found in scriptDir and its subdirectories.
A request for the path /foo/bar/baz will be handled by the first script along that path that exists: $scriptDir/foo.txt, $scriptDir/foo/bar.txt, or $scriptDir/foo/bar/baz.txt.
func (*Server) HandleScript ¶
HandleScript ensures that the script at scriptRelPath has been evaluated with its current contents.
If the script completed successfully, HandleScript invokes f on the handler with the script's result still read-locked, and waits for it to return. (That ensures that cache invalidation does not race with an in-flight handler.)
Otherwise, HandleScript returns the (cached) error from executing the script.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements http.Handler for version-control repositories.
type ServerNotInstalledError ¶
type ServerNotInstalledError struct {
// contains filtered or unexported fields
}
A ServerNotInstalledError indicates that the server binary required for the indicated VCS does not exist.
func (ServerNotInstalledError) Error ¶
func (v ServerNotInstalledError) Error() string