Documentation
¶
Overview ¶
Package gitclient provides a simple Git client for updating files in remote repositories using in-memory operations.
It uses go-git and go-billy's memfs to perform all git operations (clone, update, commit, push) without writing to disk. This is useful for ephemeral or serverless environments, or when you want to avoid filesystem side effects.
Example usage:
func main() {
client := &GitClient{
RepoURL: "https://github.com/youruser/yourrepo.git",
Branch: "main",
Token: "<your-git-token>",
}
err := client.UpdateFile("path/to/file.txt", "new file content", "Update file.txt via automation")
if err != nil {
panic(err)
}
fmt.Println("File updated and pushed successfully!")
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitClient ¶
func NewGitClient ¶
func (*GitClient) UpdateFile ¶
UpdateFile clones the repo into an in-memory filesystem, updates a file, commits, and pushes the change. No files are written to disk; all operations are performed in memory using go-billy/memfs.
Arguments:
filePath: Path to the file to update (relative to repo root) newContent: New content to write to the file commitMsg: Commit message for the change
Returns an error if any git operation fails.
Click to show internal directories.
Click to hide internal directories.