gitremote

package
v8.98.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gitremote reads which GitHub repository a git checkout belongs to from its origin remote.

Index

Constants

View Source
const Owner = "giantswarm"

Owner is the GitHub organization of the repositories devctl generates files for.

Variables

This section is empty.

Functions

func OriginURL

func OriginURL(ctx context.Context, dir string) (string, error)

OriginURL returns the URL of the origin remote of the git checkout in dir, as `git remote get-url origin` prints it.

func RepoName

func RepoName(ctx context.Context, dir string) (string, error)

RepoName returns the name of the giantswarm repository the git checkout in dir belongs to, read from its origin remote. It fails when the checkout has no origin remote or the remote is not a giantswarm repository. The name of the directory is never consulted: a worktree or a second clone is rarely named after its repository.

Types

type Repo

type Repo struct {
	Host  string
	Owner string
	Name  string
}

Repo is the GitHub repository a remote URL points to.

func Parse

func Parse(remoteURL string) (Repo, error)

Parse returns the repository a git remote URL points to. It reads the <owner>/<name> path of a URL (https://github.com/giantswarm/devctl, ssh://git@github.com/giantswarm/devctl.git) and of git's scp-like syntax (git@github.com:giantswarm/devctl.git), a trailing .git stripped. The error never repeats the URL: an https remote may carry a token.

func (Repo) String

func (r Repo) String() string

String names the repository as host/owner/name, without the credentials the remote URL may carry.

Jump to

Keyboard shortcuts

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