{"modulePath":"github.com/appleboy/CodeGPT","version":"v1.8.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package git\n\nPackage git provides functionality for working with git repositories.\n\nThis package includes constants defining template names for git hooks and initializes the templates from embedded files on package initialization.\n\nThe package embeds files from a 'templates/' directory which contain hook templates that can be used for git operations such as preparing commit messages.\n\n## Constants\n\n```go\nconst (\n\t// HookPrepareCommitMessageTemplate is the template for the prepare-commit-msg hook\n\tHookPrepareCommitMessageTemplate = \"prepare-commit-msg\"\n\t// CommitMessageTemplate is the template for the commit message\n\tCommitMessageTemplate = \"commit-msg.tmpl\"\n)\n```\n\n## Types\n\n```go\ntype Command struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc New(opts ...Option) *Command\n```\nNew creates a new Command object with the provided options. It applies each option to the config object and initializes the Command object with the configurations.\n\n```go\nfunc (c *Command) CanExecuteGitDiff(ctx context.Context) error\n```\nCanExecuteGitDiff checks if git diff can be executed in the current directory. It returns an error if the current directory is not a git repository or if git diff cannot be executed.\n\n```go\nfunc (c *Command) Commit(ctx context.Context, val string) (string, error)\n```\nCommit creates a git commit with the provided message and returns the output or an error. It uses the commit method to generate the git command and execute it.\n\n```go\nfunc (c *Command) DiffFiles(ctx context.Context) (string, error)\n```\nDiff compares the differences between two sets of data. It returns a string representing the differences and an error. If there are no differences, it returns an empty string and an error. DiffFiles compares the differences between two sets of data and returns the differences as a string and an error. It first lists the names of changed files and then shows the differences between them. If there are no staged changes, it returns an error message.\n\n```go\nfunc (c *Command) GitDir(ctx context.Context) (string, error)\n```\nGitDir to show the (by default, absolute) path of the git directory of the working tree.\n\n```go\nfunc (c *Command) InstallHook(ctx context.Context) error\n```\nInstallHook installs the prepare-commit-msg hook if it doesn't already exist. It retrieves the hooks directory path, checks if the hook file exists, and writes the hook file with executable permissions.\n\n```go\nfunc (c *Command) UninstallHook(ctx context.Context) error\n```\nUninstallHook removes the prepare-commit-msg hook if it exists. It retrieves the hooks directory path, checks if the hook file exists, and removes the hook file.\n\n```go\ntype Option interface {\n\t// contains filtered or unexported methods\n}\n```\nOption is an interface that specifies instrumentation configuration options.\n\n```go\nfunc WithDiffUnified(val int) Option\n```\nWithDiffUnified is a function that generate diffs with \\\u003cn\u003e lines of context instead of the usual three.\n\n```go\nfunc WithEnableAmend(val bool) Option\n```\nWithEnableAmend returns an Option that sets the isAmend field of a config object to the given value.\n\n```go\nfunc WithExcludeList(val []string) Option\n```\nWithExcludeList returns an Option that sets the excludeList field of a config object to the given value.\n\n","path":"github.com/appleboy/CodeGPT/git","name":"git","synopsis":"Package git provides functionality for working with git repositories.","isRedistributable":true}
