orbinit

package
v1.0.48340 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package orbinit scaffolds a new orb project for "circleci orb init". It downloads the CircleCI Orb-Template repository, extracts it, rewrites the template placeholders, and initializes a local git repository. It performs no CircleCI API calls; the orb command layer owns those.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTemplate

func ApplyTemplate(orbPath, projectName, org, orbName, namespace string) error

ApplyTemplate rewrites the placeholder tokens in every template file under orbPath with the given project details.

func CheckoutAlpha

func CheckoutAlpha(w *git.Worktree) error

CheckoutAlpha creates and switches to the "alpha" branch.

func FetchTemplate

func FetchTemplate(ctx context.Context, orbPath string) (err error)

FetchTemplate downloads the latest release of the orb template repository and extracts it into orbPath. The GitHub zipball nests everything under a top-level directory; that wrapper directory is stripped during extraction so the template lands directly in orbPath.

func InitRepo

func InitRepo(orbPath, remoteURL, branch string) (*git.Repository, *git.Worktree, error)

InitRepo prepares the git repository at orbPath for the orb's initial commit: it stages every file and commits. It returns the repository and its worktree.

An existing repository is adopted rather than refused. remoteURL and branch are only applied to what is missing — a repository that already has an origin keeps it, and one that already has commits keeps its current branch. Cloning an empty repository and initialising the orb into it is a reasonable way to work, and is the only way when repository creation is restricted to admins.

func IsRepo

func IsRepo(orbPath string) bool

IsRepo reports whether orbPath already holds a git repository.

func ProjectNameFromRemote

func ProjectNameFromRemote(remoteURL string) string

ProjectNameFromRemote derives a project name from a git remote URL by taking the last path segment and trimming any ".git" suffix.

func RemovePrivateLicense

func RemovePrivateLicense(orbPath string) error

RemovePrivateLicense deletes the MIT LICENSE file from a private orb project. A missing file is not an error.

func Substitute

func Substitute(contents, projectName, org, orbName, namespace string) string

Substitute replaces the orb template placeholder tokens in a file's contents.

Types

type ExistingRepo

type ExistingRepo struct {
	// RemoteURL is origin's URL, empty if there is no origin remote.
	RemoteURL string
	// Branch is the checked-out branch, empty if HEAD cannot be resolved.
	Branch string
}

ExistingRepo describes a git repository that is already present at the orb path. Both fields are best-effort: a freshly cloned empty repository has an origin but no commits, so no branch can be resolved from HEAD.

func InspectRepo

func InspectRepo(orbPath string) (ExistingRepo, error)

InspectRepo reads what is already configured in the repository at orbPath, so orb init can adopt it instead of asking for details that are on disk.

Cloning an empty repository and running `orb init .` inside it is the obvious way to use this command when only admins may create repositories — and it is the case that used to dead-end.

Jump to

Keyboard shortcuts

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