infra

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ItemTypeDir = "dir"

Variables

This section is empty.

Functions

func IsFileExist

func IsFileExist(workdir, filename string) bool

func NewDirWalker

func NewDirWalker() repository.DirWalker

func NewFileWalker

func NewFileWalker() repository.FileWalker

func NewGitHubDirWalker

func NewGitHubDirWalker(
	ctx context.Context,
	client *GitHubClient,
	owner, repo string,
) repository.DirWalker

NewGitHubDirWalker creates a new GitHubDirWalker instance

func Run

func Run(workdir, cmd string, args ...string) (string, string, int, error)

Types

type DirWalker

type DirWalker struct{}

func (*DirWalker) Walk

func (dw *DirWalker) Walk(
	_ context.Context, function repository.WalkDirFunc, prefixFunc repository.WalkDirNextPrefixFunc,
	prefix, path string, ignoreDot bool, maxDepth int,
) error

type FileWalker

type FileWalker struct{}

func (*FileWalker) Walk

func (fw *FileWalker) Walk(
	ctx context.Context, function repository.WalkFileFunc, path, extension string, ignoreDot bool,
) error

type GitHubClient

type GitHubClient struct {
	*github.Client
}

func NewGitHubClient

func NewGitHubClient() (*GitHubClient, error)

func (*GitHubClient) GetContent

func (c *GitHubClient) GetContent(ctx context.Context, owner, repo, path string) (string, error)

GetContent retrieves the content of a file or directory in a GitHub repository using the GitHub API. If path points to a file, it returns the file content. If path points to a directory, it returns a formatted directory listing.

func (*GitHubClient) WalkContents

func (c *GitHubClient) WalkContents(
	ctx context.Context,
	owner, repo, startPath string,
	fn WalkContentsFunc,
) error

WalkContents walks the directory tree of a GitHub repository. It calls the provided WalkContentsFunc for each file or directory in the tree. The function is called first with the start path, and then with each file or directory found. If the start path is a file, the function is called only for that file. If the start path is a directory, the function is called for that directory and all files and directories in it.

type GitHubDirWalker

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

GitHubDirWalker implements the repository.DirWalker interface for GitHub repositories

func (*GitHubDirWalker) Walk

func (w *GitHubDirWalker) Walk(
	ctx context.Context,
	function repository.WalkDirFunc,
	prefixFunc repository.WalkDirNextPrefixFunc,
	prefix, path string,
	ignoreDot bool,
	maxDepth int,
) error

Walk implements the repository.DirWalker interface for GitHub repositories

type HttpClient

type HttpClient struct{}

func NewHttpClient

func NewHttpClient() *HttpClient

func (*HttpClient) HttpGet

func (c *HttpClient) HttpGet(url string) (io.ReadCloser, error)

type WalkContentsFunc

type WalkContentsFunc func(path string, isDir bool, depth int) error

WalkContentsFunc is the function called for each file or directory visited by WalkContents. The path argument contains the path to the file or directory. The isDir argument is true if the path is a directory and false if it is a file. The depth argument indicates how deep in the tree the current item is. If the function returns an error, walking is stopped.

Jump to

Keyboard shortcuts

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