Documentation
¶
Overview ¶
Package dalgo2ghingitdb provides a DALgo database adapter for reading inGitDB repositories from GitHub using the GitHub API. It supports read-only access to public repositories with no authentication required. Future versions will support authentication and write operations for private repositories.
Index ¶
Constants ¶
const DatabaseID = "ingitdb-github"
Variables ¶
This section is empty.
Functions ¶
func NewGitHubDB ¶
NewGitHubDB creates a GitHub repository adapter. Note: Definition is required for most operations, so prefer NewGitHubDBWithDef.
func NewGitHubDBWithDef ¶
Types ¶
type Config ¶
type Config struct {
Owner string
Repo string
Ref string
Token string
APIBaseURL string
HTTPClient *http.Client
}
Config defines connection settings for reading an inGitDB repository from GitHub.
type FileReader ¶
type FileReader interface {
ReadFile(ctx context.Context, path string) (content []byte, found bool, err error)
ListDirectory(ctx context.Context, dirPath string) (entries []string, err error)
}
FileReader reads repository files by path from GitHub.
func NewGitHubFileReader ¶
func NewGitHubFileReader(cfg Config) (FileReader, error)
type TreeChange ¶ added in v1.1.0
TreeChange describes a single path modification within a tree. Content nil means "delete the file at Path"; non-nil Content means "set the file at Path to this content" (creating it if absent).
type TreeWriter ¶ added in v1.1.0
type TreeWriter struct {
// contains filtered or unexported fields
}
TreeWriter performs atomic multi-file commits on a remote GitHub repository via the Git Data API (blobs / trees / commits / refs). Unlike the per-file Contents API used by FileReader.writeFile / deleteFile (which each produce their own commit), TreeWriter bundles arbitrary file modifications into a single commit — satisfying spec REQ:one-commit-per-write for multi-file operations such as `drop collection`.
func NewTreeWriter ¶ added in v1.1.0
func NewTreeWriter(cfg Config) (*TreeWriter, error)
NewTreeWriter builds a TreeWriter for the given Config. It does not perform any network I/O; the first request fires on the first method call.
func (*TreeWriter) CommitChanges ¶ added in v1.1.0
func (w *TreeWriter) CommitChanges(ctx context.Context, message string, changes []TreeChange) (string, error)
CommitChanges atomically applies the given changes in a single commit on the target branch and returns the new commit SHA. The repository ends in exactly one of two states: either every change is applied as part of the new commit, or no change is applied at all (the previous head is unchanged).
Changes with nil Content delete the path; non-nil Content creates or updates a blob at the path with that content. Mode is set to "100644" (non-executable file) for all non-delete entries.
func (*TreeWriter) ListFilesUnder ¶ added in v1.1.0
ListFilesUnder returns the paths of every blob in the current tree of the target branch whose path equals dir or has dir+"/" as a prefix. Empty dir returns every blob in the tree. Returned paths are relative to the repo root. Used to enumerate the files to delete when dropping a collection.
Errors if the upstream tree is truncated (too large to fetch in one call); drop semantics require an atomic view of the directory.