open

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultProviders = []Provider{
	{
		BaseURL:      "https://github.com",
		CommitPrefix: "commit",
		PathPrefix:   "tree",
	},
	{
		BaseURL:      "https://gitlab.com",
		CommitPrefix: "-/commit",
		PathPrefix:   "-/tree",
	},
	{
		BaseURL:      "https://bitbucket.org",
		CommitPrefix: "commits",
		PathPrefix:   "src",
	},
}

DefaultProviders are a list of supported Providers

Functions

func GetURL

func GetURL(arg string) (string, error)

GetURL returns the URL to open based on the arg provided

func InBrowser

func InBrowser(url string) error

InBrowser opens a URL in the default browser

Types

type Provider

type Provider struct {
	BaseURL      string
	CommitPrefix string
	PathPrefix   string
}

Provider represents the Git platforms domain and URL pathing.

func LoadProviders added in v0.2.0

func LoadProviders() []Provider

LoadProviders returns a slice of Provider from the global Git config.

The Git config structure includes a base URL as an argument, and commit prefix and path prefix keys and values.

[open "https://git.mydomain.dev"]
  commitprefix = commit
  pathprefix = tree

func (Provider) CommitURL

func (p Provider) CommitURL(repo, commitSHA string) string

CommitURL returns URL of a commit as a string

func (Provider) PathURL

func (p Provider) PathURL(repo, ref, path string) string

PathURL returns URL of a file as a string

func (Provider) RootURL

func (p Provider) RootURL(repo string) string

RootURL returns URL of the root repository as a string

type Type

type Type int

Type represents the type of Git URL to open

const (
	// Folder is a specific commit in the repository
	Commit Type = iota

	// Path is a file, folder or path in the repository
	Path

	// Root is the root of the repository
	Root
)

Jump to

Keyboard shortcuts

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