vcs

package
v0.22.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitFile

type CommitFile struct {
	Name string
}

func (CommitFile) GetFilename

func (f CommitFile) GetFilename() string

type CreatePullRequestOpts

type CreatePullRequestOpts struct {
	GitRepoOwner string
	GitRepoName  string

	// (optional) the base branch. If not specified, the default branch is used
	BaseBranch     *string
	Title          string
	HeadBranchName string
	Files          map[string][]byte
}

type DirectoryItem

type DirectoryItem struct {
	Type string `json:"type"`
	Name string `json:"name"`
}

type VCSBranch

type VCSBranch interface {
	GetName() string
	GetLatestRef() string
}

type VCSCheckRun

type VCSCheckRun struct {
	Name       string
	Status     VCSCheckRunStatus
	Conclusion VCSCheckRunConclusion
}

type VCSCheckRunConclusion

type VCSCheckRunConclusion string
const (
	VCSCheckRunConclusionSuccess        VCSCheckRunConclusion = "success"
	VCSCheckRunConclusionFailure        VCSCheckRunConclusion = "failure"
	VCSCheckRunConclusionCancelled      VCSCheckRunConclusion = "cancelled"
	VCSCheckRunConclusionSkipped        VCSCheckRunConclusion = "skipped"
	VCSCheckRunConclusionTimedOut       VCSCheckRunConclusion = "timed_out"
	VCSCheckRunConclusionActionRequired VCSCheckRunConclusion = "action_required"
)

type VCSCheckRunStatus

type VCSCheckRunStatus string
const (
	VCSCheckRunStatusQueued     VCSCheckRunStatus = "queued"
	VCSCheckRunStatusInProgress VCSCheckRunStatus = "in_progress"
	VCSCheckRunStatusCompleted  VCSCheckRunStatus = "completed"
)

type VCSCommitsComparison

type VCSCommitsComparison interface {
	GetFiles() []CommitFile
}

type VCSObjectID

type VCSObjectID interface {
	GetIDString() *string
	GetIDInt64() *int64
}

VCSObjectID is a generic method for retrieving IDs from the underlying VCS repository. Depending on the provider, object IDs may be int64 or strings.

Object ids are meant to be passed between methods in the same VCS repository, so they should only be read by the same VCS repository that wrote them.

func NewVCSObjectInt

func NewVCSObjectInt(id int64) VCSObjectID

func NewVCSObjectString

func NewVCSObjectString(id string) VCSObjectID

type VCSProvider

type VCSProvider interface {
	// GetVCSRepositoryFromModule returns the corresponding VCS repository for the module.
	// Callers should likely use the package method GetVCSProviderFromModule.
	GetVCSRepositoryFromWorkflow(workflow *db.WorkflowModel) (VCSRepository, error)
}

type VCSRepository

type VCSRepository interface {
	// GetKind returns the kind of VCS provider -- used for downstream integrations
	GetKind() VCSRepositoryKind

	// GetRepoOwner returns the owner of the repository
	GetRepoOwner() string

	// GetRepoName returns the name of the repository
	GetRepoName() string

	// SetupRepository sets up a VCS repository on Hatchet.
	SetupRepository(tenantId string) error

	// GetArchiveLink returns an archive link for a specific repo SHA
	GetArchiveLink(ref string) (*url.URL, error)

	// GetBranch gets a full branch (name and sha)
	GetBranch(name string) (VCSBranch, error)

	// CreateOrUpdatePullRequest creates a new pull request or updates an existing one
	CreateOrUpdatePullRequest(tenantId, workflowRunId string, opts *CreatePullRequestOpts) (*db.GithubPullRequestModel, error)

	// ReadFile returns a file by a SHA reference or path
	ReadFile(ref, path string) (io.ReadCloser, error)

	// ReadDirectory returns a list of directory items
	ReadDirectory(ref, path string) ([]DirectoryItem, error)

	// CompareCommits compares a base commit with a head commit
	CompareCommits(base, head string) (VCSCommitsComparison, error)
}

VCSRepository provides an interface to implement for new version control providers (github, gitlab, etc)

func GetVCSRepositoryFromWorkflow

func GetVCSRepositoryFromWorkflow(allProviders map[VCSRepositoryKind]VCSProvider, workflow *db.WorkflowModel) (VCSRepository, error)

GetVCSRepositoryFromWorkflow returns the corresponding VCS repository for the workflow

type VCSRepositoryKind

type VCSRepositoryKind string
const (
	// enumeration of in-tree repository kinds
	VCSRepositoryKindGithub VCSRepositoryKind = "github"
	VCSRepositoryKindGitlab VCSRepositoryKind = "gitlab"
)

type VCSRepositoryPullRequest

type VCSRepositoryPullRequest interface {
	GetRepoOwner() string
	GetVCSID() VCSObjectID
	GetPRNumber() int64
	GetRepoName() string
	GetBaseSHA() string
	GetHeadSHA() string
	GetBaseBranch() string
	GetHeadBranch() string
	GetTitle() string
	GetState() string
}

VCSRepositoryPullRequest abstracts the underlying pull or merge request methods to only extract relevant information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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