scm

package
v1.11.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceSSHHostname added in v1.11.8

func ReplaceSSHHostname(sshURL string, newHostname string) string

ReplaceSSHHostname replaces the hostname in an SSH clone URL with a custom hostname. This allows users to leverage SSH configs with multiple host aliases. For example: git@gitlab.com:org/repo.git -> git@my-gitlab-alias:org/repo.git

func SupportedClients

func SupportedClients() []string

SupportedClients return list of all supported clients

func ToSlug added in v1.9.13

func ToSlug(title string) string

ToSlug converts a title into a URL-friendly slug.

Types

type Bitbucket

type Bitbucket struct {
	// extend the bitbucket client
	*bitbucket.Client
	// contains filtered or unexported fields
}

func (Bitbucket) GetOrgRepos

func (c Bitbucket) GetOrgRepos(targetOrg string) ([]Repo, error)

GetOrgRepos gets org repos

func (Bitbucket) GetType

func (_ Bitbucket) GetType() string

func (Bitbucket) GetUserRepos

func (c Bitbucket) GetUserRepos(targetUser string) ([]Repo, error)

GetUserRepos gets user repos from bitbucket

func (Bitbucket) NewClient

func (_ Bitbucket) NewClient() (Client, error)

NewClient create new bitbucket scm client

type Client

type Client interface {
	NewClient() (Client, error)

	GetUserRepos(targetUsername string) ([]Repo, error)
	GetOrgRepos(targetOrg string) ([]Repo, error)

	GetType() string
}

Client define the interface a scm client has to have

func GetClient

func GetClient(cType string) (Client, error)

type GitLabSnippet added in v1.9.13

type GitLabSnippet struct {
	// GitLab ID of the snippet
	ID string
	// Title of the snippet
	Title string
	// URL of the repo that snippet was made on
	URLOfRepo string
	// Name of the repo that the snippet was made on
	NameOfRepo string
}

type Gitea

type Gitea struct {
	// extend the gitea client
	*gitea.Client
	// contains filtered or unexported fields
}

func (Gitea) GetOrgRepos

func (c Gitea) GetOrgRepos(targetOrg string) ([]Repo, error)

GetOrgRepos fetches repo data from a specific group with parallel pagination

func (Gitea) GetType

func (_ Gitea) GetType() string

func (Gitea) GetUserRepos

func (c Gitea) GetUserRepos(targetUsername string) ([]Repo, error)

GetUserRepos gets all of a users gitea repos with parallel pagination

func (Gitea) NewClient

func (_ Gitea) NewClient() (Client, error)

NewClient create new gitea scm client

type Github

type Github struct {
	// extend the github client
	*github.Client
	// contains filtered or unexported fields
}

func (Github) GetOrgRepos

func (c Github) GetOrgRepos(targetOrg string) ([]Repo, error)

GetOrgRepos gets org repos with parallel pagination for performance

func (Github) GetType

func (_ Github) GetType() string

func (Github) GetUserRepos

func (c Github) GetUserRepos(targetUser string) ([]Repo, error)

GetUserRepos gets user repos with parallel pagination for performance

func (Github) NewClient

func (_ Github) NewClient() (Client, error)

NewClient create new github scm client

func (Github) SetTokensUsername added in v1.9.4

func (c Github) SetTokensUsername()

Sets the GitHub username tied to the github token to the package variable tokenUsername Then if https clone method is used the clone url will be https://username:token@github.com/org/repo.git The username is now needed when using the new fine-grained tokens for github

type Gitlab

type Gitlab struct {
	// extend the gitlab client
	*gitlab.Client
}

func (Gitlab) GetGroupRepos added in v1.7.1

func (c Gitlab) GetGroupRepos(targetGroup string) ([]Repo, error)

GetGroupRepos fetches repo data from a specific group with parallel pagination

func (Gitlab) GetOrgRepos

func (c Gitlab) GetOrgRepos(targetOrg string) ([]Repo, error)

GetOrgRepos fetches repo data from a specific group

func (Gitlab) GetSnippets added in v1.9.13

func (c Gitlab) GetSnippets(cloneData []Repo, target string) ([]Repo, error)

func (Gitlab) GetTopLevelGroups added in v1.7.1

func (c Gitlab) GetTopLevelGroups() ([]string, error)

GetTopLevelGroups all top level org groups with parallel pagination

func (Gitlab) GetType

func (_ Gitlab) GetType() string

func (Gitlab) GetUserRepos

func (c Gitlab) GetUserRepos(targetUsername string) ([]Repo, error)

GetUserRepos gets all of a users gitlab repos

func (Gitlab) NewClient

func (_ Gitlab) NewClient() (Client, error)

NewClient create new gitlab scm client

type Repo

type Repo struct {
	// The ID of the repo that is assigned via the SCM provider. This is used for example with gitlab snippets on cloud gropus where we need to know the repo id to look up all he snippets it has.
	ID string
	// Name is the name of the repo https://www.github.com/gabrie30/ghorg.git the Name would be ghorg
	Name string
	// HostPath is the path on the users machine that the repo will be cloned to. Its used in all the git commands to locate the directory of the repo. HostPath is updated for wikis and snippets because the folder for the clone is appended with .wiki and .snippet
	HostPath string
	// Path where the repo is located within the scm provider. Its mostly used with gitlab repos when the directory structure is preserved. In this case the path becomes where to locate the repo in relation to gitlab.com/group/group/group/repo.git => /group/group/group/repo
	Path string
	// URL is the web address of the repo
	URL string
	// CloneURL is the url for cloning the repo, will be different for ssh vs http clones and will have the .git extention
	CloneURL string
	// CloneBranch the branch to clone. This will be the default branch if not specified. It will always be main for snippets.
	CloneBranch string
	// IsWiki is set to true when the data is for a wiki page
	IsWiki bool
	// IsGitLabSnippet is set to true when the data is for a gitlab snippet
	IsGitLabSnippet bool
	// IsGitLabRootLevelSnippet is set to true when a snippet was not created for a repo
	IsGitLabRootLevelSnippet bool
	// GitLabSnippetInfo provides additional information when the thing we are cloning is a gitlab snippet
	GitLabSnippetInfo GitLabSnippet
	Commits           RepoCommits
}

Repo represents an SCM repo, should probably be renamed to "cloneable" since we clone wikis and snippets with this

type RepoCommits added in v1.9.13

type RepoCommits struct {
	CountPrePull  int
	CountPostPull int
	CountDiff     int
}

type ServerProjectResponse added in v1.11.5

type ServerProjectResponse struct {
	Values     []ServerRepository `json:"values"`
	Size       int                `json:"size"`
	IsLastPage bool               `json:"isLastPage"`
	Start      int                `json:"start"`
}

type ServerRepository added in v1.11.5

type ServerRepository struct {
	Name    string         `json:"name"`
	Slug    string         `json:"slug"`
	Links   map[string]any `json:"links"`
	Project struct {
		Key string `json:"key"`
	} `json:"project"`
}

Bitbucket Server API structures

type Sourcehut added in v1.11.6

type Sourcehut struct {
	Client  *http.Client
	Token   string
	BaseURL string
}

func (Sourcehut) GetOrgRepos added in v1.11.6

func (c Sourcehut) GetOrgRepos(targetOrg string) ([]Repo, error)

GetOrgRepos fetches repo data from a specific group. We emulate this by checking if the repo's owner matches the current user, which is identical to GetUserRepos. It's possible in the future that this will change as the manual (https://docs.sourcehut.org/git.sr.ht/#field-repositories) states that it will. This can be addressed once the changed behaviour is observable, rather than speculative.

func (Sourcehut) GetType added in v1.11.6

func (_ Sourcehut) GetType() string

func (Sourcehut) GetUserRepos added in v1.11.6

func (c Sourcehut) GetUserRepos(targetUsername string) ([]Repo, error)

GetUserRepos gets all of a users sourcehut repos

func (Sourcehut) NewClient added in v1.11.6

func (_ Sourcehut) NewClient() (Client, error)

NewClient create new sourcehut scm client

Jump to

Keyboard shortcuts

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