gitclone

package
v0.0.0-...-399de1b Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewParameterValidationError

func NewParameterValidationError(msg string) error

NewParameterValidationError returns a new ValidationError

Types

type BranchParams

type BranchParams struct {
	Branch string
}

BranchParams are parameters to check out a given branch (In addition to the repository URL)

func NewBranchParams

func NewBranchParams(branch string) (*BranchParams, error)

NewBranchParams validates and returns a new BranchParams

type CheckoutMethod

type CheckoutMethod int

CheckoutMethod is the checkout method used

const (
	// InvalidCheckoutMethod ...
	InvalidCheckoutMethod CheckoutMethod = iota

	// CheckoutNoneMethod only adds remote, resets repo, updates submodules
	CheckoutNoneMethod

	// CheckoutCommitMethod checks out a given commit on a given branch
	CheckoutCommitMethod

	// CheckoutTagMethod checks out a given tag
	CheckoutTagMethod

	// CheckoutBranchMethod checks out a given branch's head when a commit hash is not available
	CheckoutBranchMethod

	// CheckoutPRMergeBranchMethod creates the merge result by fetching the merge ref from the destination repo (if available)
	CheckoutPRMergeBranchMethod

	// CheckoutPRDiffFileMethod  creates the merge result of a PR/MR by applying the diff manually (if available)
	CheckoutPRDiffFileMethod

	// CheckoutPRManualMergeMethod creates the merge result by merging the PR/MR branch into the destination branch
	CheckoutPRManualMergeMethod

	// CheckoutHeadBranchCommitMethod checks out the PR/MR branch head without merging it into the destination branch
	CheckoutHeadBranchCommitMethod

	// CheckoutForkCommitMethod checks out the PR from the fork repo (if accessible)
	CheckoutForkCommitMethod
)

func (CheckoutMethod) String

func (i CheckoutMethod) String() string

type CheckoutStateResult

type CheckoutStateResult struct {
	// contains filtered or unexported fields
}

type CommandRunner

type CommandRunner interface {
	RunForOutput(c *command.Model) (string, error)
	Run(c *command.Model) error
	RunWithRetry(getCommmand func() *command.Model) error
	SetPerformanceMonitoring(enable bool)
	PausePerformanceMonitoring()
	ResumePerformanceMonitoring()
}

CommandRunner ...

type CommitParams

type CommitParams struct {
	Commit        string
	BranchRef     string
	SourceRepoURL string // optional
}

CommitParams are parameters to check out a given commit (In addition to the repository URL)

func NewCommitParams

func NewCommitParams(commit, branchRef, sourceRepoURL string) (*CommitParams, error)

NewCommitParams validates and returns a new CommitParams

type Config

type Config struct {
	ShouldMergePR bool

	CloneIntoDir         string
	CloneDepth           int
	UpdateSubmodules     bool
	SubmoduleUpdateDepth int
	FetchTags            bool
	SparseDirectories    []string

	RepositoryURL         string
	Commit                string
	Tag                   string
	Branch                string
	PRDestBranch          string
	PRSourceRepositoryURL string
	PRMergeRef            string
	PRUnverifiedMergeRef  string
	PRHeadBranch          string

	ResetRepository bool
}

Config is the git clone step configuration

type DefaultRunner

type DefaultRunner struct {
	// contains filtered or unexported fields
}

DefaultRunner ...

func (*DefaultRunner) PausePerformanceMonitoring

func (r *DefaultRunner) PausePerformanceMonitoring()

func (*DefaultRunner) ResumePerformanceMonitoring

func (r *DefaultRunner) ResumePerformanceMonitoring()

func (*DefaultRunner) Run

func (r *DefaultRunner) Run(c *command.Model) error

Run ...

func (*DefaultRunner) RunForOutput

func (r *DefaultRunner) RunForOutput(c *command.Model) (string, error)

RunForOutput ...

func (*DefaultRunner) RunWithRetry

func (r *DefaultRunner) RunWithRetry(getCommand func() *command.Model) error

RunWithRetry ...

func (*DefaultRunner) SetPerformanceMonitoring

func (r *DefaultRunner) SetPerformanceMonitoring(enable bool)

type GitCloner

type GitCloner struct {
	// contains filtered or unexported fields
}

func NewGitCloner

func NewGitCloner(logger log.Logger, tracker tracker.StepTracker, cmdFactory command.Factory, patchSource bitriseapi.PatchSource, mergeRefChecker bitriseapi.MergeRefChecker, performanceMonitoring bool) GitCloner

func (GitCloner) CheckoutState

func (g GitCloner) CheckoutState(cfg Config) (CheckoutStateResult, error)

CheckoutState is the entry point of the git clone process

type OutputExporter

type OutputExporter struct {
	// contains filtered or unexported fields
}

func NewOutputExporter

func NewOutputExporter(logger log.Logger, cmdFactory command.Factory, checkoutResult CheckoutStateResult) OutputExporter

func (*OutputExporter) ExportCommitInfo

func (e *OutputExporter) ExportCommitInfo() error

type PRDiffFileParams

type PRDiffFileParams struct {
	DestinationBranch     string
	PRManualMergeStrategy checkoutStrategy
}

PRDiffFileParams are parameters to check out a Merge/Pull Request (when a diff file is available)

func NewPRDiffFileParams

func NewPRDiffFileParams(
	destBranch string,
	prManualMergeStrategy checkoutStrategy,
) (*PRDiffFileParams, error)

NewPRDiffFileParams validates and returns a new PRDiffFileParams

type PRManualMergeParams

type PRManualMergeParams struct {
	SourceBranch      string
	SourceMergeArg    string
	SourceRepoURL     string // Optional
	DestinationBranch string
}

PRManualMergeParams are parameters to check out a Merge Request using manual merge

func NewPRManualMergeParams

func NewPRManualMergeParams(sourceBranch, commit, sourceRepoURL, destBranch string) (*PRManualMergeParams, error)

NewPRManualMergeParams validates and returns a new PRManualMergeParams

type PRMergeRefParams

type PRMergeRefParams struct {
	// MergeRef contains the changes pre-merged by the git provider (eg. pull/7/merge)
	MergeRef string
	// HeadRef is the head of the PR branch (eg. pull/7/head)
	HeadRef string
}

PRMergeRefParams are parameters to check out a Merge/Pull Request's merge ref (the result of merging the 2 branches) When available, the merge ref is created by the git server and passed in the webhook. Using a merge ref is preferred over a manual merge because we can shallow-fetch the merge ref only.

func NewPRMergeRefParams

func NewPRMergeRefParams(mergeRef, headRef string) (*PRMergeRefParams, error)

NewPRMergeRefParams validates and returns a new PRMergeRefParams

type ParameterValidationError

type ParameterValidationError struct {
	ErrorString string
}

ParameterValidationError is returned when there is missing or malformed parameter for a given parameter set

func (ParameterValidationError) Error

func (e ParameterValidationError) Error() string

Error ...

type TagParams

type TagParams struct {
	Tag string
}

TagParams are parameters to check out a given tag

func NewTagParams

func NewTagParams(tag string) (*TagParams, error)

NewTagParams validates and returns a new TagParams

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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