gituri

package
v0.0.0-...-75b7e41 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type URI

type URI struct {
	url.URL
}

A URI is a wrapper around url.URL that makes it easier to get and manipulate Nxpkg-specific components. All URIs are valid URLs, but Nxpkg assigns special meaning to certain URL components as described below.

Nxpkg URIs can refer to repos (at an optional revision), or a file or directory thereof.

The format is "CLONEURL?REV#PATH". For example:

git://github.com/facebook/react?master
git://github.com/gorilla/mux?HEAD
git://github.com/golang/go?0dc31fb#src/net/http/server.go
git://github.com/golang/tools?79f4a1#godoc/page.go

A Nxpkg URI is not guaranteed (or intended) to be a unique or canonical reference to a resource. A repository can be clonable at several different URLs, and any of them can be used in the URI. A given file in a repository has any number of URIs that refer to it (e.g., using the branch name vs. the commit ID, using clean vs. non-clean file paths, etc.).

func Parse

func Parse(uriStr string) (*URI, error)

Parse parses uriStr to a URI. The uriStr should be an absolute URL.

func (*URI) CloneURL

func (u *URI) CloneURL() *url.URL

CloneURL returns the repository clone URL component of the URI.

func (*URI) FilePath

func (u *URI) FilePath() string

FilePath returns the cleaned file path component of the URI (in the URL fragment). Leading slashes are removed. If it is ".", an empty string is returned.

func (*URI) Repo

func (u *URI) Repo() string

Repo returns the repository name (e.g., "github.com/foo/bar").

func (*URI) ResolveFilePath

func (u *URI) ResolveFilePath(p string) string

ResolveFilePath returns the cleaned file path component obtained by appending p to the URI's file path. It is called "resolve" not "join" because it strips p's leading slash (if any).

func (*URI) Rev

func (u *URI) Rev() string

Rev returns the repository revision component of the URI (the raw query string).

func (*URI) WithFilePath

func (u *URI) WithFilePath(p string) *URI

WithFilePath returns a copy of u with the file path p overwriting the existing file path (if any).

Jump to

Keyboard shortcuts

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