1package proto23import (4 "time"56 "github.com/charmbracelet/soft-serve/git"7)89// Repository is a Git repository interface.10type Repository interface {11 // ID returns the repository's ID.12 ID() int6413 // Name returns the repository's name.14 Name() string15 // ProjectName returns the repository's project name.16 ProjectName() string17 // Description returns the repository's description.18 Description() string19 // IsPrivate returns whether the repository is private.20 IsPrivate() bool21 // IsMirror returns whether the repository is a mirror.22 IsMirror() bool23 // IsHidden returns whether the repository is hidden.24 IsHidden() bool25 // UserID returns the ID of the user who owns the repository.26 // It returns 0 if the repository is not owned by a user.27 UserID() int6428 // CreatedAt returns the time the repository was created.29 CreatedAt() time.Time30 // UpdatedAt returns the time the repository was last updated.31 // If the repository has never been updated, it returns the time it was created.32 UpdatedAt() time.Time33 // Open returns the underlying git.Repository.34 Open() (*git.Repository, error)35}3637// RepositoryOptions are options for creating a new repository.38type RepositoryOptions struct {39 Private bool40 Description string41 ProjectName string42 Mirror bool43 Hidden bool44 LFS bool45 LFSEndpoint string46}4748// RepositoryDefaultBranch returns the default branch of a repository.49func RepositoryDefaultBranch(repo Repository) (string, error) {50 r, err := repo.Open()51 if err != nil {52 return "", err53 }5455 ref, err := r.HEAD()56 if err != nil {57 return "", err58 }5960 return ref.Name().Short(), nil61}