Documentation ¶
Overview ¶
Package svn provides client and server implementations of the SVN protocol.
Index ¶
- Constants
- func Unmarshal(item Item, v any) error
- type Client
- func (c *Client) GetFile(path string, rev *int, wantProps bool, wantContent bool) ([]PropList, []byte, error)
- func (c *Client) GetLatestRev() (int, error)
- func (c *Client) List(path string, rev *int, depth string, fields []string) ([]Dirent, error)
- func (c *Client) Stat(path string, rev *int) (Stat, error)
- type Dirent
- type Error
- type Item
- type ItemType
- type Itemizer
- type LogEntry
- type PropList
- type ReposInfo
- type Server
- type Stat
- type Token
- type TokenType
- type Tokenizer
Constants ¶
const SvnClient = "GoSVN/0.0.0"
SvnClient is the SVN client string to send to servers.
const SvnVersion = 2
SvnVersion is the SVN protocol version implemented in this package.
Variables ¶
This section is empty.
Functions ¶
func Unmarshal ¶
Unmarshal parses an Item and copies it to the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an error.
Unmarshal uses the inverse of the encodings that Marshal uses, allocating slices and pointers as necessary, with the following additional rules:
To unmarshal an Item into a pointer, Unmarshal unmarshals the Item into the value pointed at by the pointer. If the pointer is nil, Unmarshal allocates a new value for it to point to.
To unmarshal a list Item into a struct, Unmarshal matches the values in the same order as they are declared in the struct. If there are extra fields in the struct, they are ignored.
To unmarshal an Item into an interface value, Unmarshal stores one of these in the interface value:
- int, for numbers
- string, for words or strings
- []any, for lists
To unmarshal a list into a slice, Unmarshal resets the slice length to zero and then appends each element to the slice. As a special case, to unmarshal an empty list into a slice, Unmarshal replaces the slice with a new empty slice.
Types ¶
type Client ¶
type Client struct { Info ReposInfo // contains filtered or unexported fields }
A Client is a SVN client. Its zero value is not usable: you will have to create it and connect it to a server using Connect.
func Connect ¶
Connect creates a Client and establishes a connection to a SVN server, using the given address to find out know how to connect to it.
Right now, it works only with "file" and "svn+ssh" URLs, invoking "svnserve -t" (locally or remotely) to connect to a server
func (*Client) GetFile ¶
func (c *Client) GetFile(path string, rev *int, wantProps bool, wantContent bool) ([]PropList, []byte, error)
GetFile sends a "get-file" command, asking for the contents of a file.
func (*Client) GetLatestRev ¶
GetLatestRev sends a "get-latest-rev" command, asking for the latest revision number in the repository.
type Dirent ¶
type Dirent struct { Path string Kind string Size uint64 HasProps bool CreatedRev uint CreatedDate string LastAuthor string }
Dirent is the response for the "list" command (asking for list of files).
type Error ¶
Error is the reprensentation of a "failure" command response. It also implements the error interface.
type Item ¶
type Item struct { // Type specifies the type of item, and which of the next fields is used // to represent it. Type ItemType Number uint Text string List []Item }
Item represents a syntactic element in the SVN protocol.
func Marshal ¶
Marshal converts v into an Item.
Marshal traverses the value v recursively.
Floating point and integer values encode as numbers.
String values encode as words.
Bool values encode as words "true" or "false".
Array, slice and struct values encode as lists, except that []byte values encode as strings.
func ParseResponse ¶
ParseResponse expects an item following the prototype of "command response" and returns the list of params if the type is "success". It returns error otherwise.
type Itemizer ¶
type Itemizer struct {
// contains filtered or unexported fields
}
An Itemizer returns a stream of SVN Items.
func NewItemizer ¶
NewItemizer returns a new SVN Itemizer for the given Reader.
type LogEntry ¶ added in v0.1.0
type LogEntry struct { Changed []struct { Path string Mode string } Rev uint Author string Date string Message string }
LogEntry is every one of the responses for the "log" command.
type PropList ¶
PropList is one of the responses for the "get-file" command (asking for the contents of a file).
type ReposInfo ¶
ReposInfo contains the general information in a repo. It is filled after the initial connection.
type Server ¶
type Server struct { ReposInfo ReposInfo Greet func(version int, capabilities []string, url string, raclient string, client *string) (ReposInfo, error) GetLatestRev func() (int, error) Stat func(path string, rev *uint) (Dirent, error) CheckPath func(path string, rev *uint) (string, error) List func(path string, rev *uint, depth string, fields []string, pattern []string) ([]Dirent, error) GetFile func(path string, rev *uint, wantProps bool, wantContents bool) (uint, []PropList, []byte, error) Log func(paths []string, startRev uint, endRev uint, changedPaths bool) ([]LogEntry, error) Update func(rev *uint, target string, recurse bool) SetPath func(path string, rev uint, startEmpty bool) FinishReport func() ([]Item, error) }
A Server defines parameters for running a SVN server.
type Stat ¶
type Stat struct { Kind string Size uint64 HasProps bool CreatedRev uint CreatedDate string LastAuthor string }
Stat is the response for a "stat" command (asking for the status of a path in a revision).
type Token ¶
A Token describes a token in a SVN conversation. There are only 5 types of tokens: word, number, string, left and right parenthesis.
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
A Tokenizer returns a stream of SVN Tokens.
func NewTokenizer ¶
NewTokenizer returns a new SVN Tokenizer for the given Reader.
func (*Tokenizer) Scan ¶
Scan advances the Tokenizer to the next token, which will then be available through the Token method. It returns false when the scan stops, either by reaching the end of the input or an error. After Scan returns false, the Err method will return any error that occurred during scanning.