git_manager

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	WEBHOOK_SELECTOR_TARGET_CHECKOUT_NAME        string = "target checkout"
	WEBHOOK_SELECTOR_SOURCE_CHECKOUT_NAME        string = "source checkout"
	WEBHOOK_SELECTOR_TARGET_CHECKOUT_BRANCH_NAME string = "target branch name"

	WEBHOOK_EVENT_MERGED_ACTION_TYPE     string = "merged"
	WEBHOOK_EVENT_NON_MERGED_ACTION_TYPE string = "non-merged"
)
View Source
const DefaultRemoteName = "origin"
View Source
const GIT_AKS_PASS = "/git-ask-pass.sh"

Variables

Functions

This section is empty.

Types

type AuthMode

type AuthMode string
const (
	AUTH_MODE_USERNAME_PASSWORD AuthMode = "USERNAME_PASSWORD"
	AUTH_MODE_SSH               AuthMode = "SSH"
	AUTH_MODE_ACCESS_TOKEN      AuthMode = "ACCESS_TOKEN"
	AUTH_MODE_ANONYMOUS         AuthMode = "ANONYMOUS"
)

type BasicAuth

type BasicAuth struct {
	Username, Password string
}

type CiProjectDetails

type CiProjectDetails struct {
	GitRepository   string      `json:"gitRepository"`
	FetchSubmodules bool        `json:"fetchSubmodules"`
	MaterialName    string      `json:"materialName"`
	CheckoutPath    string      `json:"checkoutPath"`
	CommitHash      string      `json:"commitHash"`
	GitTag          string      `json:"gitTag"`
	CommitTime      time.Time   `json:"commitTime"`
	SourceType      SourceType  `json:"sourceType"`
	SourceValue     string      `json:"sourceValue"`
	Type            string      `json:"type"`
	Message         string      `json:"message"`
	Author          string      `json:"author"`
	GitOptions      GitOptions  `json:"gitOptions"`
	WebhookData     WebhookData `json:"webhookData"`
	CloningMode     string      `json:"cloningMode"`
}

func (*CiProjectDetails) GetCheckoutBranchName

func (prj *CiProjectDetails) GetCheckoutBranchName() string

type GitCliManager

type GitCliManager interface {
	Fetch(gitContext GitContext, rootDir string) (response, errMsg string, err error)
	Checkout(gitContext GitContext, rootDir string, checkout string) (response, errMsg string, err error)
	RunCommandWithCred(cmd *exec.Cmd, userName, password string) (response, errMsg string, err error)
	RunCommand(cmd *exec.Cmd) (response, errMsg string, err error)

	Init(rootDir string, remoteUrl string, isBare bool) error
	Clone(gitContext GitContext, prj CiProjectDetails) (response, errMsg string, err error)
	Merge(rootDir string, commit string) (response, errMsg string, err error)
	RecursiveFetchSubmodules(rootDir string) (response, errMsg string, error error)
	UpdateCredentialHelper(rootDir string) (response, errMsg string, error error)
	UnsetCredentialHelper(rootDir string) (response, errMsg string, error error)
	GitCheckout(gitContext GitContext, checkoutPath string, targetCheckout string, authMode AuthMode, fetchSubmodules bool, gitRepository string) (errMsg string, error error)
	// contains filtered or unexported methods
}

type GitCliManagerImpl

type GitCliManagerImpl struct {
}

func NewGitCliManager

func NewGitCliManager() *GitCliManagerImpl

func (*GitCliManagerImpl) AddRepo

func (impl *GitCliManagerImpl) AddRepo(rootDir string, remoteUrl string) error

func (*GitCliManagerImpl) Checkout

func (impl *GitCliManagerImpl) Checkout(gitContext GitContext, rootDir string, checkout string) (response, errMsg string, err error)

func (*GitCliManagerImpl) Clone

func (impl *GitCliManagerImpl) Clone(gitContext GitContext, prj CiProjectDetails) (response, errMsg string, err error)

func (*GitCliManagerImpl) Fetch

func (impl *GitCliManagerImpl) Fetch(gitContext GitContext, rootDir string) (response, errMsg string, err error)

func (*GitCliManagerImpl) GitCheckout

func (impl *GitCliManagerImpl) GitCheckout(gitContext GitContext, checkoutPath string, targetCheckout string, authMode AuthMode, fetchSubmodules bool, gitRepository string) (errMsg string, error error)

func (*GitCliManagerImpl) Init

func (impl *GitCliManagerImpl) Init(rootDir string, remoteUrl string, isBare bool) error

func (*GitCliManagerImpl) Merge

func (impl *GitCliManagerImpl) Merge(rootDir string, commit string) (response, errMsg string, err error)

setting user.name and user.email as for non-fast-forward merge, git ask for user.name and email

func (*GitCliManagerImpl) RecursiveFetchSubmodules

func (impl *GitCliManagerImpl) RecursiveFetchSubmodules(rootDir string) (response, errMsg string, error error)

func (*GitCliManagerImpl) RunCommand

func (impl *GitCliManagerImpl) RunCommand(cmd *exec.Cmd) (response, errMsg string, err error)

func (*GitCliManagerImpl) RunCommandWithCred

func (impl *GitCliManagerImpl) RunCommandWithCred(cmd *exec.Cmd, userName, password string) (response, errMsg string, err error)

func (*GitCliManagerImpl) UnsetCredentialHelper

func (impl *GitCliManagerImpl) UnsetCredentialHelper(rootDir string) (response, errMsg string, error error)

func (*GitCliManagerImpl) UpdateCredentialHelper

func (impl *GitCliManagerImpl) UpdateCredentialHelper(rootDir string) (response, errMsg string, error error)

type GitContext

type GitContext struct {
	context.Context // Embedding original Go context
	Auth            *BasicAuth
	WorkingDir      string
}

type GitManager

type GitManager struct {
	GitCliManager GitCliManager
}

func NewGitManagerImpl

func NewGitManagerImpl(gitCliManager GitCliManager) *GitManager

func (*GitManager) CloneAndCheckout

func (impl *GitManager) CloneAndCheckout(ciProjectDetails []CiProjectDetails, workingDir string) error

type GitOptions

type GitOptions struct {
	UserName      string   `json:"userName"`
	Password      string   `json:"password"`
	SshPrivateKey string   `json:"sshPrivateKey"`
	AccessToken   string   `json:"accessToken"`
	AuthMode      AuthMode `json:"authMode"`
}

type SourceType

type SourceType string
const (
	SOURCE_TYPE_BRANCH_FIXED SourceType = "SOURCE_TYPE_BRANCH_FIXED"
	SOURCE_TYPE_WEBHOOK      SourceType = "WEBHOOK"
)

type WebhookData

type WebhookData struct {
	Id              int               `json:"id"`
	EventActionType string            `json:"eventActionType"`
	Data            map[string]string `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL