git_info

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPathGitManagementRoot

func IsPathGitManagementRoot(path string) (bool, error)

func IsPathUnderGitManagement

func IsPathUnderGitManagement(path string) bool

IsPathUnderGitManagement

@Description: IsPathUnderGitManagement check path is under git management

func RepositoryConfigPath

func RepositoryConfigPath(path string) (*gitConfig.Config, error)

RepositoryConfigPath

cfg, err := git_tools.RepositoryConfigPath(projectRootPath)
if err != nil {
	t.Fatal(err)
}
t.Logf("config: %v", cfg.Remotes["origin"].URLs[0])

more use See https://github.com/go-git/go-git/blob/v5.7.0/config/config_test.go#L18

func RepositoryHeadByPath

func RepositoryHeadByPath(path string) (*plumbing.Reference, error)

func RepositoryNowBranchByPath

func RepositoryNowBranchByPath(path string) (string, error)

Types

type GitRemoteInfo

type GitRemoteInfo struct {
	UrlStr   string
	Scheme   string
	Host     string
	Hostname string
	Port     string
	UserInfo *url.Userinfo
	User     string
	Repo     string
}

func RepositoryFistRemoteInfo

func RepositoryFistRemoteInfo(path string, remote string) (*GitRemoteInfo, error)

RepositoryFistRemoteInfo

url, err := git_tools.RepositoryFistRemoteInfo(projectRootPath, "origin")
if err != nil {
	t.Fatal(err)
}
t.Logf("url.Host: %s", url.Host)
t.Logf("url.User: %s", url.User)
t.Logf("url.Repo: %s", url.Repo)

See: https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-clone.html

Jump to

Keyboard shortcuts

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