Documentation ¶
Overview ¶
Package ginclient augments the web package with functions to interact with GIN Gogs (https://github.com/G-Node/gogs) specifically.
Index ¶
- func Add(paths []string, addchan chan<- git.RepoFileStatus)
- func CheckoutFileCopies(commithash string, paths []string, outpath string, suffix string, ...)
- func CheckoutVersion(commithash string, paths []string) error
- func CommitIfNew() (bool, error)
- func DefaultRemote() (string, error)
- func DefaultServer() string
- func RemoveRemote(remote string) error
- func RemoveServer(alias string) error
- func SetDefaultRemote(remote string) error
- func SetDefaultServer(alias string) error
- func UnsetDefaultRemote() error
- type AccessToken
- type Client
- func (gincl *Client) AddKey(key, description string, force bool) error
- func (gincl *Client) CloneRepo(repopath string, clonechan chan<- git.RepoFileStatus)
- func (gincl *Client) CreateRepo(name, description string) error
- func (gincl *Client) DelRepo(name string) error
- func (gincl *Client) DeletePubKey(id int64) error
- func (gincl *Client) DeletePubKeyByIdx(idx int) (string, error)
- func (gincl *Client) DeletePubKeyByTitle(title string) error
- func (gincl *Client) Download(remote string) error
- func (gincl *Client) GetContent(paths []string, getcontchan chan<- git.RepoFileStatus)
- func (gincl *Client) GetRepo(repoPath string) (gogs.Repository, error)
- func (gincl *Client) GetTokens(username, password string) ([]AccessToken, error)
- func (gincl *Client) GetUserKeys() ([]gogs.PublicKey, error)
- func (gincl *Client) GitAddress() string
- func (gincl *Client) InitDir(bare bool) error
- func (gincl *Client) ListFiles(paths ...string) (map[string]FileStatus, error)
- func (gincl *Client) ListRepos(user string) ([]gogs.Repository, error)
- func (gincl *Client) LoadToken() error
- func (gincl *Client) LockContent(paths []string, lcchan chan<- git.RepoFileStatus)
- func (gincl *Client) Login(username, password, clientID string) error
- func (gincl *Client) Logout()
- func (gincl *Client) MakeSessionKey() error
- func (gincl *Client) NewToken(username, password, clientID string) error
- func (gincl *Client) RemoveContent(paths []string, rmcchan chan<- git.RepoFileStatus)
- func (gincl *Client) RequestAccount(name string) (gogs.User, error)
- func (gincl *Client) Sync(content bool) error
- func (gincl *Client) UnlockContent(paths []string, ulcchan chan<- git.RepoFileStatus)
- func (gincl *Client) Upload(paths []string, remotes []string, uploadchan chan<- git.RepoFileStatus)
- func (gincl *Client) WebAddress() string
- type FileCheckoutStatus
- type FileStatus
- type FileStatusSlice
- type GINUser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(paths []string, addchan chan<- git.RepoFileStatus)
Add updates the index with the changes in the files specified by 'paths'. The status channel 'addchan' is closed when this function returns.
func CheckoutFileCopies ¶
func CheckoutFileCopies(commithash string, paths []string, outpath string, suffix string, cochan chan<- FileCheckoutStatus)
CheckoutFileCopies checks out copies of files specified by path from the revision with the specified commithash. The checked out files are stored in the location specified by outpath. The timestamp of the revision is appended to the original filenames (before the extension).
func CheckoutVersion ¶
CheckoutVersion checks out all files specified by paths from the revision with the specified commithash.
func CommitIfNew ¶
CommitIfNew creates an empty initial git commit if the current repository is completely new. If a new commit is created and a default remote exists, the new commit is pushed to initialise the remote as well. Returns 'true' if (and only if) a commit was created.
func DefaultRemote ¶
DefaultRemote returns the name of the configured default gin remote. If a remote is not set in the config, the remote of the default git upstream is set and returned.
func DefaultServer ¶
func DefaultServer() string
DefaultServer returns the alias of the configured default gin server.
func RemoveRemote ¶
RemoveRemote removes a remote from the repository configuration.
func RemoveServer ¶
RemoveServer removes a server from the user configuration. Returns with error if no server with the given alias exists.
func SetDefaultRemote ¶
SetDefaultRemote sets the name of the default gin remote.
func SetDefaultServer ¶
SetDefaultServer sets the alias of the default gin server. Returns with error if no server with the given alias exists.
func UnsetDefaultRemote ¶
func UnsetDefaultRemote() error
UnsetDefaultRemote unsets the default gin remote in the git configuration.
Types ¶
type AccessToken ¶
AccessToken represents a API access token.
type Client ¶
Client is a client interface to the GIN server. Embeds web.Client.
func New ¶
New returns a new client for the GIN server, configured with the server referred to by the alias in the argument.
func (*Client) AddKey ¶
AddKey adds the given key to the current user's authorised keys. If force is enabled, any key which matches the new key's description will be overwritten.
func (*Client) CloneRepo ¶
func (gincl *Client) CloneRepo(repopath string, clonechan chan<- git.RepoFileStatus)
CloneRepo clones a remote repository and initialises annex. The status channel 'clonechan' is closed when this function returns.
func (*Client) CreateRepo ¶
CreateRepo creates a repository on the server.
func (*Client) DeletePubKey ¶
DeletePubKey the key with the given ID from the current user's authorised keys.
func (*Client) DeletePubKeyByIdx ¶
DeletePubKeyByIdx removes the key with the given index from the current user's authorised keys. Upon deletion, it returns the title of the key that was deleted. Note that the first key has index 1.
func (*Client) DeletePubKeyByTitle ¶
DeletePubKeyByTitle removes the key that matches the given title from the current user's authorised keys.
func (*Client) Download ¶
Download downloads changes and placeholder files in an already checked out repository.
func (*Client) GetContent ¶
func (gincl *Client) GetContent(paths []string, getcontchan chan<- git.RepoFileStatus)
GetContent downloads the contents of placeholder files in a checked out repository. The status channel 'getcontchan' is closed when this function returns.
func (*Client) GetRepo ¶
func (gincl *Client) GetRepo(repoPath string) (gogs.Repository, error)
GetRepo retrieves the information of a repository.
func (*Client) GetTokens ¶
func (gincl *Client) GetTokens(username, password string) ([]AccessToken, error)
GetTokens returns all the user's active access tokens from the GIN server.
func (*Client) GetUserKeys ¶
GetUserKeys fetches the public keys that the user has added to the auth server.
func (*Client) GitAddress ¶
GitAddress returns the full address string for the configured git server
func (*Client) InitDir ¶
InitDir initialises the local directory with the default remote and git (and annex) configuration options. Optionally initialised as a bare repository (for annex directory remotes).
func (*Client) ListFiles ¶
func (gincl *Client) ListFiles(paths ...string) (map[string]FileStatus, error)
ListFiles lists the files and directories specified by paths and their sync status.
func (*Client) ListRepos ¶
func (gincl *Client) ListRepos(user string) ([]gogs.Repository, error)
ListRepos gets a list of repositories (public or user specific)
func (*Client) LoadToken ¶
LoadToken calls the embedded UserToken.LoadToken function with the configured server alias.
func (*Client) LockContent ¶
func (gincl *Client) LockContent(paths []string, lcchan chan<- git.RepoFileStatus)
LockContent locks local files, turning them into symlinks (if supported by the filesystem). The status channel 'lockchan' is closed when this function returns.
func (*Client) Login ¶
Login requests a token from the auth server and stores the username and token to file and adds them to the Client. It also generates a key pair for the user for use in git commands. (See also NewToken)
func (*Client) Logout ¶
func (gincl *Client) Logout()
Logout logs out the currently logged in user in 3 steps: 1. Remove the public key matching the current hostname from the server. 2. Delete the private key file from the local machine. 3. Delete the user token.
func (*Client) MakeSessionKey ¶
MakeSessionKey creates a private+public key pair. The private key is saved in the user's configuration directory, to be used for git commands. The public key is added to the GIN server for the current logged in user.
func (*Client) NewToken ¶
NewToken requests a new user token from the GIN server and adds it to the Client along with the username.
func (*Client) RemoveContent ¶
func (gincl *Client) RemoveContent(paths []string, rmcchan chan<- git.RepoFileStatus)
RemoveContent removes the contents of local files, turning them into placeholders but only if the content is available on a remote. The status channel 'rmcchan' is closed when this function returns.
func (*Client) RequestAccount ¶
RequestAccount requests a specific account by name.
func (*Client) Sync ¶
Sync synchronises changes bidirectionally (uploads and downloads), optionally transferring content between remotes and the local clone.
func (*Client) UnlockContent ¶
func (gincl *Client) UnlockContent(paths []string, ulcchan chan<- git.RepoFileStatus)
UnlockContent unlocks local files turning them into normal files, if the content is locally available. The status channel 'unlockchan' is closed when this function returns.
func (*Client) Upload ¶
func (gincl *Client) Upload(paths []string, remotes []string, uploadchan chan<- git.RepoFileStatus)
Upload transfers locally recorded changes to a remote. The status channel 'uploadchan' is closed when this function returns.
func (*Client) WebAddress ¶
WebAddress returns the full address string for the configured web server
type FileCheckoutStatus ¶
FileCheckoutStatus is used to report the status of a CheckoutFileCopies() operation.
type FileStatus ¶
type FileStatus uint8
FileStatus represents the state a file is in with respect to local and remote changes.
const ( // Synced indicates that an annexed file is synced between local and remote Synced FileStatus = iota // NoContent indicates that a file represents an annexed file that has not had its contents synced yet NoContent // Modified indicatres that a file has local modifications that have not been committed Modified // LocalChanges indicates that a file has local, committed modifications that have not been pushed LocalChanges // RemoteChanges indicates that a file has remote modifications that have not been pulled RemoteChanges // Unlocked indicates that a file is being tracked and is unlocked for editing Unlocked // TypeChange indicates that a file being tracked as locked (unlocked) is now unlocked (locked) TypeChange // Removed indicates that a (previously) tracked file has been deleted or moved Removed // Untracked indicates that a file is not being tracked by neither git nor git annex Untracked )
func (FileStatus) Abbrev ¶
func (fs FileStatus) Abbrev() string
Abbrev returns the two-letter abbrevation of the file status OK (Synced), NC (NoContent), MD (Modified), LC (LocalUpdates), RC (RemoteUpdates), UL (Unlocked), TC (TypeChange), RM (Removed), ?? (Untracked)
func (FileStatus) Description ¶
func (fs FileStatus) Description() string
Description returns the long description of the file status
type FileStatusSlice ¶
type FileStatusSlice []FileStatus
FileStatusSlice is a slice of FileStatus which implements Len() and Less() to allow sorting.
func (FileStatusSlice) Len ¶
func (fsSlice FileStatusSlice) Len() int
Len is the number of elements in FileStatusSlice.
func (FileStatusSlice) Less ¶
func (fsSlice FileStatusSlice) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (FileStatusSlice) Swap ¶
func (fsSlice FileStatusSlice) Swap(i, j int)
Swap swaps the elements with intexes i and j.