Documentation
¶
Index ¶
- Constants
- Variables
- func GetGitPushCommandPipe(proto ProtoHelper) ([]byte, error)
- func GetLoginFromEmail(email string) string
- type AGitProtoHelper
- type DefaultProtoHelper
- type ExternalProtoHelper
- func (v ExternalProtoHelper) GetDownloadRef(cr, patch string) (string, error)
- func (v ExternalProtoHelper) GetGitPushCommand(o *common.UploadOptions) (*GitPushCommand, error)
- func (v ExternalProtoHelper) GetSSHInfo() *SSHInfo
- func (v ExternalProtoHelper) GetType() string
- func (v *ExternalProtoHelper) Program() string
- type GerritProtoHelper
- type GitPushCommand
- type ProtoHelper
- type SSHCmd
- type SSHInfo
- type SSHInfoQuery
- type ShellCmd
Constants ¶
const ( ProtoTypeAGit = "agit" ProtoTypeGerrit = "gerrit" )
Proto types
const ( SSHVariantAuto = iota SSHVariantSimple SSHVariantSSH SSHVariantPlink SSHVariantPutty SSHVariantTortoisePlink )
Define constants for SSH variant types.
Variables ¶
var ( UserEmailPattern = regexp.MustCompile(`^(.*?)\s*<([^@\s]+)@(\S*)>$`) EmailPattern = regexp.MustCompile(`^<?([^@\s]+)@(\S+)>?$`) )
Email patterns
var ( // NormalArgsPattern matches args which do not need to be quoted. NormalArgsPattern = regexp.MustCompile(`^[0-9a-zA-Z:/%,.@+=_-]+$`) )
Functions ¶
func GetGitPushCommandPipe ¶
func GetGitPushCommandPipe(proto ProtoHelper) ([]byte, error)
GetGitPushCommandPipe reads JSON from STDIN, pipe it to the helper, and output the result in JSON.
func GetLoginFromEmail ¶
GetLoginFromEmail gets login name from email address.
Types ¶
type AGitProtoHelper ¶
type AGitProtoHelper struct {
// contains filtered or unexported fields
}
AGitProtoHelper implements helper for AGit server.
func NewAGitProtoHelper ¶
func NewAGitProtoHelper(sshInfo *SSHInfo) *AGitProtoHelper
NewAGitProtoHelper returns AGitProtoHelper object.
func (AGitProtoHelper) GetDownloadRef ¶
func (v AGitProtoHelper) GetDownloadRef(cr, patch string) (string, error)
GetDownloadRef returns reference name of the specific code review.
func (AGitProtoHelper) GetGitPushCommand ¶
func (v AGitProtoHelper) GetGitPushCommand(o *common.UploadOptions) (*GitPushCommand, error)
GetGitPushCommand reads upload options and returns git push command.
func (AGitProtoHelper) GetSSHInfo ¶
func (v AGitProtoHelper) GetSSHInfo() *SSHInfo
GetSSHInfo returns SSHInfo object.
func (AGitProtoHelper) GetType ¶
func (v AGitProtoHelper) GetType() string
GetType returns remote server type.
type DefaultProtoHelper ¶
type DefaultProtoHelper struct {
// contains filtered or unexported fields
}
DefaultProtoHelper implements helper for unknown remote service.
func NewDefaultProtoHelper ¶
func NewDefaultProtoHelper(sshInfo *SSHInfo) *DefaultProtoHelper
NewDefaultProtoHelper returns DefaultProtoHelper object.
func (DefaultProtoHelper) GetDownloadRef ¶
func (v DefaultProtoHelper) GetDownloadRef(cr, patch string) (string, error)
GetDownloadRef returns reference name of the specific code review.
func (DefaultProtoHelper) GetGitPushCommand ¶
func (v DefaultProtoHelper) GetGitPushCommand(o *common.UploadOptions) (*GitPushCommand, error)
GetGitPushCommand reads upload options and returns git push command.
func (DefaultProtoHelper) GetSSHInfo ¶
func (v DefaultProtoHelper) GetSSHInfo() *SSHInfo
GetSSHInfo returns SSHInfo object.
func (DefaultProtoHelper) GetType ¶
func (v DefaultProtoHelper) GetType() string
GetType returns remote server type.
type ExternalProtoHelper ¶
type ExternalProtoHelper struct {
// contains filtered or unexported fields
}
ExternalProtoHelper implements helper for unknown remote service.
func NewExternalProtoHelper ¶
func NewExternalProtoHelper(sshInfo *SSHInfo) *ExternalProtoHelper
NewExternalProtoHelper returns ExternalProtoHelper object.
func (ExternalProtoHelper) GetDownloadRef ¶
func (v ExternalProtoHelper) GetDownloadRef(cr, patch string) (string, error)
GetDownloadRef returns reference name of the specific code review.
func (ExternalProtoHelper) GetGitPushCommand ¶
func (v ExternalProtoHelper) GetGitPushCommand(o *common.UploadOptions) (*GitPushCommand, error)
GetGitPushCommand reads upload options and returns git push command.
func (ExternalProtoHelper) GetSSHInfo ¶
func (v ExternalProtoHelper) GetSSHInfo() *SSHInfo
GetSSHInfo returns SSHInfo object.
func (ExternalProtoHelper) GetType ¶
func (v ExternalProtoHelper) GetType() string
GetType returns remote server type.
func (*ExternalProtoHelper) Program ¶
func (v *ExternalProtoHelper) Program() string
Program is program name of remote helper.
type GerritProtoHelper ¶
type GerritProtoHelper struct {
// contains filtered or unexported fields
}
GerritProtoHelper wraps helper for gerrit server.
func NewGerritProtoHelper ¶
func NewGerritProtoHelper(sshInfo *SSHInfo) *GerritProtoHelper
NewGerritProtoHelper returns GerritProtoHelper object.
func (GerritProtoHelper) GetDownloadRef ¶
func (v GerritProtoHelper) GetDownloadRef(cr, patch string) (string, error)
GetDownloadRef returns reference name of the specific code review.
func (GerritProtoHelper) GetGitPushCommand ¶
func (v GerritProtoHelper) GetGitPushCommand(o *common.UploadOptions) (*GitPushCommand, error)
GetGitPushCommand reads upload options and returns git push command.
func (GerritProtoHelper) GetSSHInfo ¶
func (v GerritProtoHelper) GetSSHInfo() *SSHInfo
GetSSHInfo returns SSHInfo object.
func (GerritProtoHelper) GetType ¶
func (v GerritProtoHelper) GetType() string
GetType returns remote server type.
type GitPushCommand ¶
type GitPushCommand struct { Cmd string `json:"cmd,omitempty"` Args []string `json:"args,omitempty"` Env []string `json:"env,omitempty"` GitConfig []string `json:"gitconfig,omitempty"` }
GitPushCommand holds command and args for git command.
type ProtoHelper ¶
type ProtoHelper interface { GetType() string GetSSHInfo() *SSHInfo GetGitPushCommand(*common.UploadOptions) (*GitPushCommand, error) GetDownloadRef(string, string) (string, error) }
ProtoHelper defines interface for proto helper.
func NewProtoHelper ¶
func NewProtoHelper(sshInfo *SSHInfo) ProtoHelper
NewProtoHelper returns proto helper for specific proto type.
type SSHCmd ¶
type SSHCmd struct {
// contains filtered or unexported fields
}
SSHCmd is composor for SSH command.
func NewSSHCmd ¶
func NewSSHCmd() *SSHCmd
NewSSHCmd returns SSHCmd by inspecting environments like `GIT_SSH_COMMAND`.
type SSHInfo ¶
type SSHInfo struct { Host string `json:"host,omitempty"` Port int `json:"port,omitempty"` ProtoType string `json:"type,omitempty"` ProtoVersion int `json:"version,omitempty"` User string `json:"user,omitempty"` Expire int64 `json:"-"` }
SSHInfo wraps host and port which ssh_info returned.
type SSHInfoQuery ¶
type SSHInfoQuery struct { CacheFile string Changed bool // contains filtered or unexported fields }
SSHInfoQuery wraps cache to accelerate query of ssh_info API.
func NewSSHInfoQuery ¶
func NewSSHInfoQuery(cacheFile string) *SSHInfoQuery
NewSSHInfoQuery creates new query object. file is name of the cache.
func (SSHInfoQuery) GetSSHInfo ¶
func (v SSHInfoQuery) GetSSHInfo(address string, useCache bool) (*SSHInfo, error)
GetSSHInfo queries ssh_info for address.
type ShellCmd ¶
ShellCmd is used to parse shell command.
func NewShellCmd ¶
NewShellCmd creates ShellCmd object from command line.
func NewShellCmdFromArgs ¶
NewShellCmdFromArgs creates ShellCmd from command args.
func (ShellCmd) QuoteCommand ¶
QuoteCommand quotes command args which has space.