vcsutils

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 18 Imported by: 8

Documentation

Index

Constants

View Source
const (
	TagPrefix              = "refs/tags/"
	NumberOfCommitsToFetch = 50
	ErrNoCommentsProvided  = "could not add a pull request review comment, no comments were provided"
)
View Source
const (
	RemoteName = "origin"
)

Variables

This section is empty.

Functions

func AddBranchPrefix added in v1.4.0

func AddBranchPrefix(branch string) string

AddBranchPrefix adds a branchPrefix to a branch name if it is not already present.

func CheckResponseStatusWithBody added in v1.5.0

func CheckResponseStatusWithBody(resp *http.Response, expectedStatusCodes ...int) error

func CreateDotGitFolderWithRemote added in v1.5.0

func CreateDotGitFolderWithRemote(path, remoteName, remoteUrl string) error

CreateDotGitFolderWithRemote creates a .git folder inside path with remote details of remoteName and remoteUrl

func CreateToken

func CreateToken() string

CreateToken create a random UUID

func DefaultIfNotNil added in v1.4.0

func DefaultIfNotNil[T any](val *T) T

DefaultIfNotNil checks: 1. If the pointer is nil, return the zero value of the type 2. If the pointer isn't nil, return the value of the pointer.

func DiscardResponseBody added in v1.1.0

func DiscardResponseBody(resp *http.Response) error

DiscardResponseBody prepare http response body for closing

func GenerateResponseError added in v1.5.0

func GenerateResponseError(status, body string) error

func GetPullRequestFilePath added in v1.14.0

func GetPullRequestFilePath(filePath string) string

func GetZeroValue added in v1.4.0

func GetZeroValue[T any]() T

GetZeroValue returns the zero value of type T

func MapPullRequestState added in v1.8.0

func MapPullRequestState(state *PullRequestState) *string

func PointerOf added in v1.6.0

func PointerOf[T any](v T) *T

PointerOf returns pointer to the provided value if it is not nil.

func RemapFields added in v1.7.1

func RemapFields[T any](src any, tagName string) (T, error)

RemapFields creates an instance of the T type and copies data from src parameter to it by mapping fields based on the tags with tagName (if not provided 'mapstructure' tag is used) using 'mapstructure' library.

func RemoveDirContents added in v1.12.1

func RemoveDirContents(dirPath string) (err error)

RemoveDirContents removes the contents of the directory, without removing the directory itself. If it encounters an error before removing all the files, it stops and returns that error.

func RemoveTempDir added in v1.12.1

func RemoveTempDir(dirPath string) error

func Untar

func Untar(destDir string, reader io.Reader, shouldRemoveBaseDir bool) (err error)

Untar a file to the given destination destDir - Destination folder reader - Reader for the tar.gz file shouldRemoveBaseDir - True if should remove the base directory

func Unzip added in v1.4.0

func Unzip(zipFileContent []byte, destinationToUnzip string) (err error)

Unzip a file to dest path

Types

type PullRequestState added in v1.8.0

type PullRequestState string
const (
	Open   PullRequestState = "open"
	Closed PullRequestState = "closed"
)

type VcsProvider

type VcsProvider int

VcsProvider is an enum represents the VCS provider type

const (
	// GitHub VCS provider
	GitHub VcsProvider = iota
	// GitLab VCS provider
	GitLab
	// BitbucketServer VCS provider
	BitbucketServer
	// BitbucketCloud VCS provider
	BitbucketCloud
	// AzureRepos VCS provider
	AzureRepos
)

func (VcsProvider) String added in v1.1.0

func (v VcsProvider) String() string

String representation of the VcsProvider

type WebhookEvent

type WebhookEvent string

WebhookEvent is the event type of the incoming webhook

const (
	// PrRejected the pull request is rejected
	PrRejected WebhookEvent = "PrRejected"
	// PrEdited the pull request is edited
	PrEdited WebhookEvent = "PrEdited"
	// PrMerged the pull request is merged
	PrMerged WebhookEvent = "PrMerged"
	// PrOpened a pull request is opened
	PrOpened WebhookEvent = "PrOpened"
	// Push a commit is pushed to the source branch
	Push WebhookEvent = "Push"
	// TagPushed a new tag is pushed
	TagPushed WebhookEvent = "TagPushed"
	// TagRemoved a tag is removed
	TagRemoved WebhookEvent = "TagRemoved"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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