ctxdetect

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ctxdetect works out what the user is looking at: a specific project, a GitLab group, or nothing in particular.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRemote

func ParseRemote(url string) (host, namespace, project string, ok bool)

ParseRemote turns a git remote URL into its host, namespace and project. It handles https, ssh:// and scp-style (git@host:path) forms. ok is false for anything that is not a recognisable remote, such as a local path.

Types

type Mode

type Mode int

Mode is what the target directory turned out to be.

const (
	ModeAccount Mode = iota
	ModeRepo
	ModeGroup
)

The three launch modes.

func (Mode) String

func (m Mode) String() string

String renders the mode for the UI breadcrumb.

type Result

type Result struct {
	Mode  Mode
	Ref   forge.Ref
	Group string
	Host  string
}

Result is the outcome of detection.

func Detect

func Detect(target string) Result

Detect classifies target:

  1. ModeRepo — target is inside a git repo with a parseable origin.
  2. ModeGroup — target's immediate children are GitLab repos sharing a common namespace prefix. Needs no configuration and self-heals as repos are cloned.
  3. ModeAccount — anything else.

Jump to

Keyboard shortcuts

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