Documentation
¶
Index ¶
- Constants
- func BuildCloneURL(repo string, protocol Protocol) (string, error)
- func ExtractOwnerAndRepo(repo string) (owner, name string, err error)
- func ExtractRepoName(repo string) string
- func GetGitHubToken() string
- func GetGitHubTokenOrError() (string, error)
- func GetSSHKeyPath() string
- func GetSSHKeyPathOrError() (string, error)
- func IsValidGitHubName(name string) bool
- func IsValidLabelName(name string) bool
- func NormalizeURL(url string) string
- func SSHKeyExists(path string) bool
- func SanitizeBranchName(input string) string
- func SanitizeLabels(labels []string) []string
- func ValidateBranchName(name string) error
- func ValidateOwnerName(name string) error
- func ValidateRepoName(name string) error
- type Protocol
- type RepoURL
Constants ¶
const ( // EnvGitHubToken is the primary GitHub token environment variable EnvGitHubToken = "GITHUB_TOKEN" // EnvGitHubToken2 is an alternative GitHub token environment variable EnvGitHubToken2 = "GH_TOKEN" // EnvGitHubAccessToken is another common GitHub token environment variable EnvGitHubAccessToken = "GITHUB_ACCESS_TOKEN" // EnvCascadeToken is the Cascade-specific GitHub token environment variable EnvCascadeToken = "CASCADE_GITHUB_TOKEN" // EnvSSHKeyPath is the environment variable for custom SSH key path EnvSSHKeyPath = "SSH_KEY_PATH" )
Environment variable names for authentication configuration.
Variables ¶
This section is empty.
Functions ¶
func BuildCloneURL ¶
BuildCloneURL constructs a cloneable git URL from a repository string. If the string is already a valid URL, returns it as-is. For shorthand formats (user/repo), constructs an HTTPS URL.
func ExtractOwnerAndRepo ¶
ExtractOwnerAndRepo extracts owner and repository name from a URL or path. Returns owner and repo name separately.
func ExtractRepoName ¶
ExtractRepoName extracts the repository name from a git URL or path.
func GetGitHubToken ¶
func GetGitHubToken() string
GetGitHubToken retrieves a GitHub token from environment variables. Checks multiple common environment variable names in order of precedence: 1. GITHUB_TOKEN 2. GH_TOKEN 3. CASCADE_GITHUB_TOKEN 4. GITHUB_ACCESS_TOKEN Returns empty string if no token is found.
func GetGitHubTokenOrError ¶
GetGitHubTokenOrError retrieves a GitHub token or returns an error if not found. This is useful when a token is required for an operation.
func GetSSHKeyPath ¶
func GetSSHKeyPath() string
GetSSHKeyPath returns the SSH key path from environment or the default location. Checks SSH_KEY_PATH environment variable first, then falls back to ~/.ssh/id_rsa.
func GetSSHKeyPathOrError ¶
GetSSHKeyPathOrError returns the SSH key path or an error if it doesn't exist.
func IsValidGitHubName ¶
IsValidGitHubName checks if a name follows GitHub naming conventions. Returns true if valid, false otherwise.
func IsValidLabelName ¶
IsValidLabelName checks if a label name follows GitHub label rules.
func NormalizeURL ¶
NormalizeURL normalizes git URLs for comparison. Removes .git suffix, converts SSH to HTTPS format, and lowercases.
func SSHKeyExists ¶
SSHKeyExists checks if an SSH key file exists at the given path.
func SanitizeBranchName ¶
SanitizeBranchName sanitizes a string to create a valid git branch name. Replaces or removes invalid characters.
func SanitizeLabels ¶
SanitizeLabels enforces GitHub label rules and deduplicates labels.
func ValidateBranchName ¶
ValidateBranchName validates a git branch name according to git rules. Returns an error if the name is invalid.
func ValidateOwnerName ¶
ValidateOwnerName validates a GitHub owner or organization name. Returns an error if the name is invalid.
func ValidateRepoName ¶
ValidateRepoName validates a GitHub repository name. Returns an error if the name is invalid.
Types ¶
type RepoURL ¶
type RepoURL struct {
// Host is the git hosting provider (e.g., github.com, gitlab.com)
Host string
// Owner is the repository owner or organization
Owner string
// Name is the repository name
Name string
// Protocol is the access protocol used in the original URL
Protocol Protocol
// CloneURL is the full clone URL in the original format
CloneURL string
// HTTPSURL is the HTTPS version of the clone URL
HTTPSURL string
// SSHURL is the SSH version of the clone URL
SSHURL string
}
RepoURL represents a parsed git repository URL with multiple access formats.
func ParseRepoURL ¶
ParseRepoURL parses a repository string into a structured RepoURL. Handles various formats: - user/repo (assumes GitHub) - github.com/user/repo - https://github.com/user/repo.git - git@github.com:user/repo.git