Documentation ¶
Index ¶
- Constants
- Variables
- func GetGitPushCommandPipe(proto ProtoHelper) ([]byte, error)
- func GetLoginFromEmail(email string) string
- func GetProxyFromGitConfig() (*url.URL, error)
- func ReplaceMacros(s string, macros map[string]string) string
- type AGitProtoHelper
- type DefaultProtoHelper
- type ExternalProtoHelper
- func (v ExternalProtoHelper) GetDownloadRef(cr, patch string) (string, error)
- func (v ExternalProtoHelper) GetGitPushCommand(o *config.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.
func GetProxyFromGitConfig ¶ added in v0.7.6
GetProxyFromGitConfig returns http proxy url through http.proxy
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(id, patch string) (string, error)
GetDownloadRef returns reference name of the specific code review.
func (AGitProtoHelper) GetGitPushCommand ¶
func (v AGitProtoHelper) GetGitPushCommand(o *config.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 *config.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 *config.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 *config.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(*config.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 { // PushURL gives the URL prefix of the repository to push. // Macro "<email>" and "<login>" can be used as the user part of PushURL. PushURL string `json:"pushurl,omitempty"` // If PushURL is not defined, will try to compose a SSH URL for push // using the host, port and user provided. Macro "{email}" and "{login}" // can be used in the user part. Host string `json:"host,omitempty"` Port int `json:"port,omitempty"` User string `json:"user,omitempty"` // Proto type and version for the protocol, such as "gerrit", "agit", etc. ProtoType string `json:"type,omitempty"` ProtoVersion int `json:"version,omitempty"` // ReviewRefPattern is used to compose the refname for the the specifc code review. // Macro {id}, {patch}, {id:left:N}, {id:right:N} can be used in this pattern. ReviewRefPattern string `json:"review_ref,omitempty"` Expire int64 `json:"-"` }
SSHInfo stands for Smart Submit Handler information. Hold data returned from ssh_info API
func (SSHInfo) GetReviewRef ¶ added in v0.7.7
GetReviewRef gets review ref from ReviewRefPattern.
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.