scm

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceSSHHostname

func ReplaceSSHHostname(cloneURL string) string

ReplaceSSHHostname replaces the hostname in an SSH clone URL with the custom hostname from GHORG_SSH_HOSTNAME. Only applies to SSH URLs (git@host:...).

func SupportedClients

func SupportedClients() []string

SupportedClients return list of all supported clients

func ToSlug

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

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) GetUserGists

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

GetUserGists gets all gists for a GitHub user

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

func (c Github) SetTokensUsername()

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

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

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

func (Gitlab) GetTopLevelGroups

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/blairham/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
	// IsGitHubGist is set to true when the data is for a github gist
	IsGitHubGist 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
	// SyncedDefaultBranch is set to true when the default branch was successfully synced
	SyncedDefaultBranch bool
}

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

type RepoCommits

type RepoCommits struct {
	CountPrePull  int
	CountPostPull int
	CountDiff     int
}

type ServerProjectResponse

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

type ServerRepository

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"`
}

ServerRepository represents the Bitbucket Server API repository structure

type Sourcehut

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

func (Sourcehut) GetOrgRepos

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

func (Sourcehut) GetType() string

func (Sourcehut) GetUserRepos

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

GetUserRepos gets all of a users sourcehut repos

func (Sourcehut) NewClient

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