vcsurl

package module
v0.0.0-...-d665f01 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 7 Imported by: 4

README

go-vcsurl

Go library for parsing and manipulating URLs of VCS services

Overview GoDoc

This package provides useful functions for parsing and manipulating URLs of VCS services such as GitHub, GitLab, BitBucket. It can be used to check whether a given URL points to an account, a repository, a file or a raw file. It also provides functions for converting file URLs to raw URLs and root raw URLs.

Install

go get github.com/alranel/go-vcsurl

Author

Alessandro Ranellucci

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRawFile

func GetRawFile(url *url.URL) *url.URL

GetRawFile returns the raw URL corresponding to the supplied file URL. In case the supplied file URL is already raw, it will be returned back.

func GetRawRoot

func GetRawRoot(url *url.URL, branch ...string) (*url.URL, error)

GetRawRoot returns the URL of the raw repository root containing the supplied file. Optionally you can pass a branch to hint which branch to use, if it can't be autodetected.

func GetRepo

func GetRepo(url *url.URL) *url.URL

GetRepo returns the URL of the main page of the repository (i.e. not raw nor git)

func IsAccount

func IsAccount(url *url.URL) bool

IsAccount returns true if the supplied URL points to the root page of an org or user account.

func IsBitBucket

func IsBitBucket(url *url.URL) bool

IsBitBucket returns true if the supplied URL belongs to BitBucket.

func IsFile

func IsFile(url *url.URL) bool

IsFile returns true if the supplied URL points to a file in non-raw mode.

func IsGitHub

func IsGitHub(url *url.URL) bool

IsGitHub returns true if the supplied URL belongs to GitHub.

func IsGitLab

func IsGitLab(url *url.URL) bool

IsGitLab returns true if the supplied URL belongs to BitBucket.

func IsHttpRepo

func IsHttpRepo(url *url.URL) bool

IsHttpRepo returns true if the supplied URL points to an HTTP git repository.

func IsRawFile

func IsRawFile(url *url.URL) bool

IsRawFile returns true if the supplied URL points to a raw file.

func IsRawRoot

func IsRawRoot(url *url.URL) bool

IsRawRoot returns true if the supplied URL is the root for raw files.

func IsRepo

func IsRepo(url *url.URL) bool

IsRepo returns true if the supplied URL points to the root page of a repository.

Types

This section is empty.

Jump to

Keyboard shortcuts

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