repo

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneOrUpdate

func CloneOrUpdate(opts CloneOptions) error
func CreateLink(target, linkPath string) error

func EnsureGitignore

func EnsureGitignore(projectDir string) error

func EnsureRemote

func EnsureRemote(repoPath, remoteURL string) error

func FormatAddResult

func FormatAddResult(result *AddResult, duration time.Duration) string

func FormatSummaryForCLI

func FormatSummaryForCLI(langStats []SCCLanguageStat) string

FormatSummaryForCLI 生成终端输出的汇总表格

func FormatSummaryForWiki

func FormatSummaryForWiki(langStats []SCCLanguageStat) string

FormatSummaryForWiki 生成 reference.md 中的代码概览

func FormatTopFilesForCLI

func FormatTopFilesForCLI(files []SCCFileStat, topN int) string

FormatTopFilesForCLI 生成终端输出的 top 文件表格

func FormatTopFilesForWiki

func FormatTopFilesForWiki(langStats []SCCLanguageStat, files []SCCFileStat, topN int) string

FormatTopFilesForWiki 生成 scc.md,包含语言汇总和 top 文件排名

func GetRemoteURL

func GetRemoteURL(repoPath string) (string, error)

func GetRepoMeta

func GetRepoMeta(repoPath string) (branch, commit string, commitTime *time.Time, err error)

func NormalizeGitURL

func NormalizeGitURL(input string) string

func PlatformShortName

func PlatformShortName(host string) string

func PurgeCache

func PurgeCache(path string) error
func ReadLink(linkPath string) (string, error)

func RefreshReferenceMap added in v0.0.2

func RefreshReferenceMap(projectDir, refDir string, indexer *RepoIndexer) error
func RemoveLink(linkPath string) error

func ResolveProxy

func ResolveProxy(appConfig *models.AppConfig) string

ResolveProxy 解析最终使用的代理地址 优先级:git_proxy > proxy > 环境变量 HTTPS_PROXY/HTTP_PROXY > 空字符串

func RunSCC

func RunSCC(repoPath string) ([]SCCLanguageStat, []SCCFileStat, error)

RunSCC 对指定路径运行代码统计,返回按语言的汇总和文件级统计

func SetupGitProxy

func SetupGitProxy(proxyURL string) (func(), error)

SetupGitProxy 根据代理 URL 创建并注册 go-git transport 返回 cleanup 函数,调用后恢复默认 transport

func ValidateLocalRepo

func ValidateLocalRepo(path string) error

Types

type AddConfig

type AddConfig struct {
	Target     string
	Local      bool
	Name       string
	Branch     string
	Depth      int
	NoUpdate   bool
	ProjectDir string
}

type AddProcessor

type AddProcessor struct {
	// contains filtered or unexported fields
}

func NewAddProcessor

func NewAddProcessor(config *AddConfig, appConfig *models.AppConfig, db *gorm.DB) *AddProcessor

func (*AddProcessor) Execute

func (p *AddProcessor) Execute(ctx context.Context) (*AddResult, error)

type AddResult

type AddResult struct {
	RefName string
	RefType models.RefType
}

type CheckItem

type CheckItem struct {
	Name    string `json:"name"`
	Status  string `json:"status"`
	Details string `json:"details"`
	Group   string `json:"group"` // core / agent
}

type CloneOptions

type CloneOptions struct {
	URL      string
	Path     string
	Branch   string
	Depth    int
	Proxy    string
	NoUpdate bool
}

type DoctorConfig

type DoctorConfig struct {
	ProjectDir string
}

type DoctorProcessor

type DoctorProcessor struct {
	// contains filtered or unexported fields
}

func NewDoctorProcessor

func NewDoctorProcessor(config *DoctorConfig, db *gorm.DB) *DoctorProcessor

func (*DoctorProcessor) Execute

func (p *DoctorProcessor) Execute(ctx context.Context) (*DoctorResult, error)

type DoctorResult

type DoctorResult struct {
	ProjectDir string      `json:"project_dir"`
	Checks     []CheckItem `json:"checks"`
	Summary    string      `json:"summary"`
}

type GitURLInfo

type GitURLInfo struct {
	OriginalURL string
	Host        string
	Namespace   string
	RepoName    string
	IsKnown     bool
	CachePath   string // host/namespace/repo 或 other/sanitized
	LinkName    string // host-namespace-repo
	WikiSubPath string // platform/namespace/repo(用于 wiki 嵌套目录)
}

func ParseGitURL

func ParseGitURL(rawURL string, reposBase string) (*GitURLInfo, error)

type InjectConfig

type InjectConfig struct {
	ProjectDir string
}

type InjectProcessor

type InjectProcessor struct {
	// contains filtered or unexported fields
}

func NewInjectProcessor

func NewInjectProcessor(config *InjectConfig, db *gorm.DB) *InjectProcessor

func (*InjectProcessor) Execute

func (p *InjectProcessor) Execute(ctx context.Context) (string, error)

type ListConfig

type ListConfig struct {
	ProjectDir string
}

type ListProcessor

type ListProcessor struct {
	// contains filtered or unexported fields
}

func NewListProcessor

func NewListProcessor(config *ListConfig, db *gorm.DB) *ListProcessor

func (*ListProcessor) Execute

func (p *ListProcessor) Execute(ctx context.Context) (*ListResult, error)

type ListRepoItem

type ListRepoItem struct {
	Type      string `json:"type"`
	Name      string `json:"name"`
	Source    string `json:"source"`
	CachePath string `json:"cache_path"`
	CommitAt  string `json:"commit_at"`
	Branch    string `json:"branch"`
}

type ListResult

type ListResult struct {
	Repos []ListRepoItem `json:"repos"`
}

type RemoveConfig

type RemoveConfig struct {
	Identifier string
	Purge      bool
	Clean      bool
	Yes        bool
	All        bool
	ProjectDir string
}

type RemoveProcessor

type RemoveProcessor struct {
	// contains filtered or unexported fields
}

func NewRemoveProcessor

func NewRemoveProcessor(config *RemoveConfig, appConfig *models.AppConfig, db *gorm.DB) *RemoveProcessor

func (*RemoveProcessor) Execute

func (p *RemoveProcessor) Execute(ctx context.Context) error

type RepoIndexer

type RepoIndexer struct {
	// contains filtered or unexported fields
}

func NewRepoIndexer

func NewRepoIndexer(db *gorm.DB) *RepoIndexer

func (*RepoIndexer) Add

func (idx *RepoIndexer) Add(repo *models.Repo) error

func (*RepoIndexer) Count added in v0.0.2

func (idx *RepoIndexer) Count() (int64, error)

func (*RepoIndexer) DeleteByProjectDir added in v0.0.2

func (idx *RepoIndexer) DeleteByProjectDir(projectDir string) (int64, error)

func (*RepoIndexer) Get

func (idx *RepoIndexer) Get(projectDir, linkName string) (*models.Repo, error)

func (*RepoIndexer) GetByRefName

func (idx *RepoIndexer) GetByRefName(projectDir, refName string) (*models.Repo, error)

func (*RepoIndexer) List

func (idx *RepoIndexer) List(projectDir string) ([]models.Repo, error)

func (*RepoIndexer) ListAll added in v0.0.2

func (idx *RepoIndexer) ListAll() (map[string][]models.Repo, error)

func (*RepoIndexer) ListAllCachePaths added in v0.0.2

func (idx *RepoIndexer) ListAllCachePaths() ([]string, error)

func (*RepoIndexer) ListAllProjectDirs added in v0.0.2

func (idx *RepoIndexer) ListAllProjectDirs() ([]string, error)

func (*RepoIndexer) ListAllWikiSubPaths added in v0.0.2

func (idx *RepoIndexer) ListAllWikiSubPaths() ([]string, error)

func (*RepoIndexer) ListByType

func (idx *RepoIndexer) ListByType(projectDir string, refType models.RefType) ([]models.Repo, error)

func (*RepoIndexer) Remove

func (idx *RepoIndexer) Remove(projectDir, linkName string) error

type SCCFileStat

type SCCFileStat struct {
	Type       string `json:"type,omitempty"`
	Filename   string `json:"filename"`
	Language   string `json:"language"`
	Location   string `json:"location"`
	Code       int64  `json:"code"`
	Complexity int64  `json:"complexity"`
}

type SCCLanguageStat

type SCCLanguageStat struct {
	Type       string `json:"type,omitempty"`
	Language   string `json:"languages"`
	Files      int64  `json:"files"`
	Lines      int64  `json:"lines"`
	Code       int64  `json:"code"`
	Comments   int64  `json:"comments"`
	Blanks     int64  `json:"blanks"`
	Complexity int64  `json:"complexity"`
}

type UpdateConfig

type UpdateConfig struct {
	Identifier string
	ProjectDir string
}

type UpdateProcessor

type UpdateProcessor struct {
	// contains filtered or unexported fields
}

func NewUpdateProcessor

func NewUpdateProcessor(config *UpdateConfig, appConfig *models.AppConfig, db *gorm.DB) *UpdateProcessor

func (*UpdateProcessor) Execute

func (p *UpdateProcessor) Execute(ctx context.Context) error

Jump to

Keyboard shortcuts

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