files

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package files provides file browsing and content retrieval for Git repositories.

Package files provides file browsing and content retrieval for Git repositories.

Package files provides file browsing and content retrieval for Git repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectLanguage

func DetectLanguage(filename string, content []byte) string

DetectLanguage detects the programming language of a file. Uses go-enry which is GitHub's linguist library ported to Go.

func MapToCodeMirrorMode

func MapToCodeMirrorMode(language string) string

MapToCodeMirrorMode maps enry language names to CodeMirror mode names.

Types

type BlobResponse

type BlobResponse struct {
	Content  string `json:"content"`
	Path     string `json:"path"`
	Size     int64  `json:"size"`
	Language string `json:"language"`
	Binary   bool   `json:"binary"`
}

BlobResponse represents file content.

type FederatedClient

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

FederatedClient handles proxying file requests to the correct indexer shard.

func NewFederatedClient

func NewFederatedClient(indexerService string, indexerPort, totalShards int) *FederatedClient

NewFederatedClient creates a client for federated file access.

func (*FederatedClient) GetBlob

func (c *FederatedClient) GetBlob(
	ctx context.Context,
	repoName, path, ref string,
) (*BlobResponse, error)

GetBlob proxies a blob request to the correct shard.

func (*FederatedClient) GetBranches

func (c *FederatedClient) GetBranches(ctx context.Context, repoName string) ([]string, error)

GetBranches proxies a branch listing request to the correct shard.

func (*FederatedClient) GetRawBlob

func (c *FederatedClient) GetRawBlob(
	ctx context.Context,
	repoName, path, ref string,
) (io.ReadCloser, int64, error)

GetRawBlob proxies a raw file content request to the correct shard. Returns the response body as a ReadCloser — the caller must close it.

func (*FederatedClient) GetShardForRepo

func (c *FederatedClient) GetShardForRepo(repoName string) int

GetShardForRepo returns which shard should handle a repo.

func (*FederatedClient) GetTags

func (c *FederatedClient) GetTags(ctx context.Context, repoName string) ([]string, error)

GetTags proxies a tag listing request to the correct shard.

func (*FederatedClient) ListTree

func (c *FederatedClient) ListTree(
	ctx context.Context,
	repoName, path, ref string,
) ([]TreeEntry, error)

ListTree proxies a tree listing request to the correct shard.

func (*FederatedClient) RepoExists

func (c *FederatedClient) RepoExists(ctx context.Context, repoName string) (bool, error)

RepoExists checks if a repository exists on its assigned shard.

type FileSymbol

type FileSymbol struct {
	Name      string `json:"name"`
	Kind      string `json:"kind"`
	Line      int    `json:"line"`
	Column    int    `json:"column"`
	Signature string `json:"signature,omitempty"`
	Parent    string `json:"parent,omitempty"`
}

FileSymbol represents a symbol found in a file.

func ExtractSymbols

func ExtractSymbols(content, language string) []FileSymbol

ExtractSymbols extracts symbols from file content based on language.

type Service

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

Service provides file browsing operations for repositories.

func NewService

func NewService(reposPath string) *Service

NewService creates a new file service.

func (*Service) GetBlob

func (s *Service) GetBlob(ctx context.Context, repoName, path, ref string) (*BlobResponse, error)

GetBlob returns the content of a file in a repository.

func (*Service) GetBranches

func (s *Service) GetBranches(ctx context.Context, repoName string) ([]string, error)

GetBranches returns all branches for a repository.

func (*Service) GetRawBlob

func (s *Service) GetRawBlob(
	ctx context.Context,
	repoName, path, ref string,
) (io.ReadCloser, int64, error)

GetRawBlob returns a reader for raw file content (including binary files).

func (*Service) GetRepoPath

func (s *Service) GetRepoPath(repoName string) string

GetRepoPath returns the local path to a cloned repository (public version).

func (*Service) GetTags

func (s *Service) GetTags(ctx context.Context, repoName string) ([]string, error)

GetTags returns all tags for a repository.

func (*Service) ListTree

func (s *Service) ListTree(ctx context.Context, repoName, path, ref string) ([]TreeEntry, error)

ListTree returns the directory listing for a given path in a repository.

func (*Service) RepoExists

func (s *Service) RepoExists(repoName string) bool

RepoExists checks if a repository exists locally.

type TreeEntry

type TreeEntry struct {
	Name     string `json:"name"`
	Type     string `json:"type"` // "file" or "dir"
	Path     string `json:"path"`
	Size     int64  `json:"size,omitempty"`
	Language string `json:"language,omitempty"`
}

TreeEntry represents a file or directory in a repository tree.

Jump to

Keyboard shortcuts

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