Documentation
¶
Overview ¶
Package gitremote resolves the CircleCI project slug for the current working directory. Resolution prefers the per-checkout .circleci/info.yml recorded by `circleci project link` (so repository renames and standalone projects stay addressable), falling back to parsing the git remote URL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectNamespace ¶
DetectNamespace returns the organization name (namespace) from the git remote. For a slug like "gh/myorg/myrepo" it returns "myorg".
func SlugFromRemote ¶
SlugFromRemote is exported for testing.
Types ¶
type ProjectInfo ¶
type ProjectInfo struct {
// Slug is the CircleCI project slug, e.g. "gh/myorg/myrepo".
Slug string
// Branch is the current git branch name.
Branch string
// DefaultBranch is the default branch name.
DefaultBranch string
}
ProjectInfo holds the information needed to identify a CircleCI project.
func Detect ¶
func Detect() (*ProjectInfo, error)
Detect resolves the CircleCI project for the current working directory.
Resolution priority:
- .circleci/info.yml in the working directory (written by `circleci project link`). When this file carries both project_id and organization_id, the canonical "circleci/<orgID>/<projectID>" slug is returned so lookups survive VCS-side renames; otherwise the file's stored slug is returned verbatim.
- The git remote "origin" URL.
The branch is always read from git (best-effort when info.yml supplied the slug, since the branch is per-checkout and never persisted in info.yml).
func DetectFromRemote ¶
func DetectFromRemote() (*ProjectInfo, error)
DetectFromRemote resolves the project from the git "origin" remote without consulting .circleci/info.yml. Use this from the `project link` command itself — reading info.yml there would short-circuit the very write that link is about to perform.