utils

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckGitPresence

func CheckGitPresence() bool

func ErrCheck

func ErrCheck(err error)

func ErrReturn

func ErrReturn(err error) error

func FindDotGit

func FindDotGit(repoPath string) (path string, err error)

func GitDiff

func GitDiff(staged bool, args []string) string

if not staged, it will accept a list of strings to be passed to git as arguments

func ProceedEditor

func ProceedEditor(title, target string) (string, error)

func ProceedSelector

func ProceedSelector(title string, choices []string) (string, error)

func ShowVersion

func ShowVersion(version string)

Types

type Autommit

type Autommit struct {
	Version      string
	OpenAiApiKey string
	Context      context.Context
	OpenAiClient openai.Client
	PgpKeyPath   string
	CommitInfo   Commit
	Type         string
	MaxChars     int
	GitConfig    GitConfig
}

func NewAutommit

func NewAutommit(version, openAiApiKey, commitType, path, pgpKeyPath, gitConfig string, maxChars int) (*Autommit, error)

func (*Autommit) CheckForStagedFiles

func (a *Autommit) CheckForStagedFiles() (exist bool, fileNames []string)

CheckForStagedFiles checks if there are any staged files if there are, it will return true, and list them

func (*Autommit) CreateCompletionRequest

func (a *Autommit) CreateCompletionRequest(prompt string) (string, error)

func (*Autommit) GeneratePrompt

func (a *Autommit) GeneratePrompt(gitDiff string, footer string) string

function GeneratePrompt generates a prompt for the OpenAI API @param gitDiff string @param footer string @return string

func (*Autommit) GetOpenPGPKeyring

func (a *Autommit) GetOpenPGPKeyring() (err error)

func (*Autommit) GitAddDialogue

func (a *Autommit) GitAddDialogue()

func GitAddDialogue will ask the user to select files to add to the commit if no files are available to select and no files are already staged, it will exit the program if no files are available to select but some files are already staged, it will proceed to the commit dialogue

func (*Autommit) GitCommit

func (a *Autommit) GitCommit() error

func (*Autommit) GitCommitDialogue

func (a *Autommit) GitCommitDialogue() (regenerate bool)

func GitCommitDialogue will walk the user through git the git commit dialogue and return a boolean indicating whether the commit message is accepted by the user or not if the user selects "regenerate", it will return false, prompting the program to regenerate the commit message

func (*Autommit) GitPush

func (a *Autommit) GitPush() error

func (*Autommit) NewOpenAiClient

func (a *Autommit) NewOpenAiClient() *openai.Client

func (*Autommit) ParseStringAsJson

func (a *Autommit) ParseStringAsJson(strSrc string) error

func (*Autommit) PopulateFileList

func (a *Autommit) PopulateFileList() ([]string, error)

PopulateFileList populates the file list for the add prompt selector

func (*Autommit) PopulateGitUserInfo

func (a *Autommit) PopulateGitUserInfo() error

func PopulateGitUserInfo() will parse a .gitconfig file and populate the Autommit struct with the user's name and email

func (*Autommit) UnstageFiles

func (a *Autommit) UnstageFiles() error

UnstageFiles unstages all files

type Commit

type Commit struct {
	Message       string   `json:"commit_message"`
	MessageLong   string   `json:"commit_message_long"`
	FilesAffected []string `json:"files_affected"`
}

type GitConfig

type GitConfig struct {
	Author     string
	AuthorMail string
	RepoPath   string
	FilePath   string
	Repo       *git.Repository
	Worktree   *git.Worktree
	HeadRef    *plumbing.Reference
	PGPKeyRing openpgp.EntityList
}

Jump to

Keyboard shortcuts

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