Documentation
¶
Index ¶
- func ConvertToMap(keysAndValues []interface{}) map[string]interface{}
- func Execute(params *ExecuteParams) error
- func GenerateRandomString() string
- func GetCurrentShortHash(gitRepo string) (string, error)
- func GetUntrackedFiles(gitRepo string) (git.Status, error)
- func IsExecutableFile(file string) (bool, error)
- func NewLogger() *logrus.Logger
- func ReadFileAsBase64(file string) (string, error)
- func ReadTextFile(file string) (string, error)
- func ToCommitActionOptions(filepath string, status *git.FileStatus) (*gitlab.CommitActionOptions, error)
- type AcceptMergeRequestParams
- type BranchSuffix
- type CommitFilesParams
- type CreateMergeRequestParams
- type CustomLogger
- type ExecuteParams
- type GitLab
- func (g *GitLab) AcceptMergeRequest(params *AcceptMergeRequestParams) error
- func (g *GitLab) CommitFiles(params *CommitFilesParams) error
- func (g *GitLab) CreateMergeRequest(params *CreateMergeRequestParams) (*gitlab.MergeRequest, error)
- func (g *GitLab) GetUserID(username string) (int64, error)
- func (g *GitLab) GetUserIDs(usernames []string) ([]int64, error)
- func (g *GitLab) IsExistsBranch(params *IsExistsBranchParams) (bool, error)
- type GitLabParams
- type IsExistsBranchParams
- type SourceBranch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToMap ¶ added in v0.3.0
func ConvertToMap(keysAndValues []interface{}) map[string]interface{}
ConvertToMap convert from `[]interface{}` to `map[string]interface{}`
func GenerateRandomString ¶ added in v0.1.1
func GenerateRandomString() string
GenerateRandomString generate random string
func GetCurrentShortHash ¶ added in v0.1.1
GetCurrentShortHash returns short hash of current revision
func GetUntrackedFiles ¶
GetUntrackedFiles returns untracked files
func IsExecutableFile ¶ added in v0.2.3
IsExecutableFile checks whether a file is executable
func NewLogger ¶ added in v0.4.3
NewLogger returns a logger configured for timestamped output to stdout.
func ReadFileAsBase64 ¶ added in v0.2.2
ReadFileAsBase64 reads a file and returns its contents as BASE64
func ReadTextFile ¶ added in v0.2.2
ReadTextFile reads a text file
func ToCommitActionOptions ¶
func ToCommitActionOptions(filepath string, status *git.FileStatus) (*gitlab.CommitActionOptions, error)
ToCommitActionOptions convert git.FileStatus to gitlab.CommitActionOptions
Types ¶
type AcceptMergeRequestParams ¶ added in v0.2.0
AcceptMergeRequestParams represents parameters of AcceptMergeRequest
type BranchSuffix ¶ added in v0.1.1
type BranchSuffix int
BranchSuffix represents branch suffix format
const ( // None doesn't append suffix to branches None BranchSuffix = iota // Random append a random string to the branch name specified in `--source-branch`. (e.g. `create-merge-request/patch-xxxxxxx`) Random // Timestamp append an Unix Epoch Time to the branch name specified in `--source-branch`. (e.g. `create-merge-request/patch-1719675225`) Timestamp // ShortCommitHash append a git short hash to the branch name specified in `--source-branch`. (e.g. `create-merge-request/patch-123abcd`) ShortCommitHash )
func ToBranchSuffix ¶ added in v0.1.1
func ToBranchSuffix(str string) (BranchSuffix, error)
ToBranchSuffix returns BranchSuffix from string
func (BranchSuffix) String ¶ added in v0.1.1
func (i BranchSuffix) String() string
type CommitFilesParams ¶
type CommitFilesParams struct {
ProjectName string
NewBranch string
StartBranch string
AuthorEmail string
AuthorName string
CommitMessage string
Files git.Status
}
CommitFilesParams represents parameters of CommitFiles
type CreateMergeRequestParams ¶
type CreateMergeRequestParams struct {
ProjectName string
SourceBranch string
TargetBranch string
Title string
Description string
Labels []string
Assignees []string
Reviewers []string
}
CreateMergeRequestParams represents parameters of CreateMergeRequest
type CustomLogger ¶ added in v0.3.0
type CustomLogger struct {
// contains filtered or unexported fields
}
CustomLogger adapts logrus to the LeveledLogger interface
func NewCustomLogger ¶ added in v0.3.0
func NewCustomLogger(logLevel string) (*CustomLogger, error)
NewCustomLogger returns new CustomLogger instance
logLevel : DEBUG, INFO, WARN, ERROR
func (*CustomLogger) Debug ¶ added in v0.3.0
func (l *CustomLogger) Debug(msg string, keysAndValues ...interface{})
Debug print debug log
func (*CustomLogger) Error ¶ added in v0.3.0
func (l *CustomLogger) Error(msg string, keysAndValues ...interface{})
Error print error log
func (*CustomLogger) Info ¶ added in v0.3.0
func (l *CustomLogger) Info(msg string, keysAndValues ...interface{})
Info print info log
func (*CustomLogger) Warn ¶ added in v0.3.0
func (l *CustomLogger) Warn(msg string, keysAndValues ...interface{})
Warn print warn log
type ExecuteParams ¶
type ExecuteParams struct {
GitLabParams GitLabParams
ProjectName string
SourceBranch SourceBranch
// commit params
AuthorEmail string
AuthorName string
CommitMessage string
// MR params
TargetBranch string
Title string
Description string
Labels []string
Assignees []string
Reviewers []string
AutoMerge bool
}
ExecuteParams represents parameters of Execute
type GitLab ¶
type GitLab struct {
// contains filtered or unexported fields
}
GitLab represents GitLab client
func NewGitLab ¶
func NewGitLab(params *GitLabParams) (*GitLab, error)
NewGitLab returns new GitLab instance
func (*GitLab) AcceptMergeRequest ¶ added in v0.2.0
func (g *GitLab) AcceptMergeRequest(params *AcceptMergeRequestParams) error
AcceptMergeRequest set auto-merge to MergeRequest
ref. https://docs.gitlab.com/ee/api/merge_requests.html#merge-a-merge-request
func (*GitLab) CommitFiles ¶
func (g *GitLab) CommitFiles(params *CommitFilesParams) error
CommitFiles commit files
ref. https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions
func (*GitLab) CreateMergeRequest ¶
func (g *GitLab) CreateMergeRequest(params *CreateMergeRequestParams) (*gitlab.MergeRequest, error)
CreateMergeRequest create MergeRequest
ref. https://docs.gitlab.com/ee/api/merge_requests.html#create-mr
func (*GitLab) GetUserIDs ¶
GetUserIDs returns userIDs from usernames
func (*GitLab) IsExistsBranch ¶ added in v0.1.1
func (g *GitLab) IsExistsBranch(params *IsExistsBranchParams) (bool, error)
IsExistsBranch check whether branch is existing
ref. https://docs.gitlab.com/ee/api/branches.html#get-single-repository-branch
type GitLabParams ¶
type GitLabParams struct {
APIEndpoint string
PrivateToken string
HTTPClient *http.Client
LogLevel string
}
GitLabParams represents parameters of NewGitLab
type IsExistsBranchParams ¶ added in v0.1.1
IsExistsBranchParams represents parameters of IsExistsBranch
type SourceBranch ¶ added in v0.1.1
type SourceBranch struct {
Name string
Suffix BranchSuffix
}
SourceBranch represents source branch options
func (*SourceBranch) GenerateBranchName ¶ added in v0.1.1
func (s *SourceBranch) GenerateBranchName(gitRepo string) (string, error)
GenerateBranchName returns source branch name from Name and Suffix