Documentation
¶
Index ¶
- func GetGitReferenceNameOrHashAndSubDirectory(url string, urlPath string) (plumbing.ReferenceName, plumbing.Hash, string, error)
- func GetGitRemoteURL(repo *git.Repository, remoteName string) (string, error)
- func GetGitRepository(dir string) (*git.Repository, error)
- func GetLatestTagOrHash(ctx context.Context, url string) (*semver.Version, error)
- func GitCloneAndCheckoutCommit(ctx context.Context, url string, commit plumbing.Hash, path string) error
- func GitCloneAndCheckoutRevision(ctx context.Context, url string, revision plumbing.Revision, path string) error
- func GitCloneOrPull(ctx context.Context, rawurl string, referenceName plumbing.ReferenceName, ...) error
- func GitListBranchesAndTags(url string) ([]plumbing.ReferenceName, error)
- func IsGitOriginURLGitHub(remoteURL string) booldeprecated
- func ParseGitRepoURL(rawurl string) (string, string, error)
- type VCSInfo
- type VCSKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGitReferenceNameOrHashAndSubDirectory ¶
func GetGitReferenceNameOrHashAndSubDirectory(url string, urlPath string) ( plumbing.ReferenceName, plumbing.Hash, string, error, )
GetGitReferenceNameOrHashAndSubDirectory returns the reference name or hash, and sub directory path. The sub directory path always uses "/" as the separator.
func GetGitRemoteURL ¶
func GetGitRemoteURL(repo *git.Repository, remoteName string) (string, error)
GetGitRemoteURL returns the remote URL for the given remoteName in the repo.
func GetGitRepository ¶
func GetGitRepository(dir string) (*git.Repository, error)
GetGitRepository returns the git repository by walking up from the provided directory. If no repository is found, will return (nil, nil).
func GetLatestTagOrHash ¶ added in v3.148.0
GetLatestTagOrHash returns the latest tag or hash in the repository. To do this, we list all the tags in the repository and try to pars them as semver. If we can't find any valid tags that are semver, we'll use the hash of the default branch. If we can't find any tags or default branches we return an error.
func GitCloneAndCheckoutCommit ¶
func GitCloneAndCheckoutCommit(ctx context.Context, url string, commit plumbing.Hash, path string) error
GitCloneAndCheckoutCommit clones the Git repository and checkouts the specified commit.
func GitCloneAndCheckoutRevision ¶ added in v3.147.0
func GitCloneAndCheckoutRevision(ctx context.Context, url string, revision plumbing.Revision, path string) error
GitCloneAndCheckoutRevision clones a Git repository, resolves the revision and checks it out.
func GitCloneOrPull ¶
func GitCloneOrPull( ctx context.Context, rawurl string, referenceName plumbing.ReferenceName, path string, shallow bool, ) error
GitCloneOrPull pulls the repo located at rawurl into the directory specified by path. If the repo already exists, it will be updated to referenceName, otherwise it will be cloned, and referenceName will be checked out. If shallow is true, a shallow clone will be performed.
func GitListBranchesAndTags ¶
func GitListBranchesAndTags(url string) ([]plumbing.ReferenceName, error)
GitListBranchesAndTags fetches a remote Git repository's branch and tag references (including HEAD), sorted by the length of the short name descending.
func IsGitOriginURLGitHub
deprecated
func ParseGitRepoURL ¶
ParseGitRepoURL returns the URL to the Git repository and path from a raw URL. For example, an input of "https://github.com/pulumi/templates/templates/javascript" returns "https://github.com/pulumi/templates.git" and "templates/javascript". Additionally, it supports nested git projects, as used by GitLab. For example, "https://github.com/pulumi/platform-team/templates.git/templates/javascript" returns "https://github.com/pulumi/platform-team/templates.git" and "templates/javascript"
Note: URL with a hostname of `dev.azure.com`, are currently treated as a raw git clone url and currently do not support subpaths.
Types ¶
type VCSInfo ¶
VCSInfo describes a cloud-hosted version control system. Cloud hosted VCS' typically have an owner (could be an organization), to whom the repo belongs.
func GetGitHubProjectForOrigin ¶
GetGitHubProjectForOrigin returns the GitHub login, and GitHub repo name if the "origin" remote is a GitHub URL.
func TryGetVCSInfo ¶
TryGetVCSInfo attempts to detect whether the provided remoteURL is an SSH or an HTTPS remote URL. It then extracts the repo, owner name, and the type (kind) of VCS from it.
type VCSKind ¶
type VCSKind = string
VCSKind represents the hostname of a specific type of VCS. For eg., github.com, gitlab.com etc.
const ( // GitLabHostName The host name for GitLab. GitLabHostName VCSKind = "gitlab.com" // GitHubHostName The host name for GitHub. GitHubHostName VCSKind = "github.com" // AzureDevOpsHostName The host name for Azure DevOps AzureDevOpsHostName VCSKind = "dev.azure.com" // BitbucketHostName The host name for Bitbucket BitbucketHostName VCSKind = "bitbucket.org" )
Constants related to detecting the right type of source control provider for git.