vc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Email  string
	Handle string
	Token  string
}

Author represents a commit, issue, or code change request author on a version control server.

type Comment

type Comment struct {
	ID int64
	// ChangeID is the local identifier for the code change request this comment was left on (e.g. Github PR number)
	ChangeID string
	Author   Author
	Body     string
	Position int
	FilePath string
	DiffHunk string
	URL      string
	Branch   string
	PRNumber int
}

Comment represents a comment on a code change request. TODO comments on issue?

func (Comment) String

func (c Comment) String() string

type GithubClient

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

GithubClient implements the VCClient interface.

func NewGithubClient

func NewGithubClient(ctx context.Context, log *zap.Logger, self Author, repo Repository) (*GithubClient, error)

NewGithubClient initializes a Github client and checks out a repository locally.

func (*GithubClient) CommentOnIssue

func (gc *GithubClient) CommentOnIssue(issueNumber int, comment string) error

CommentOnIssue adds a comment to the issue provided.

func (*GithubClient) ListOpenComments

func (gc *GithubClient) ListOpenComments(options ListCommentOptions) ([]Comment, error)

ListOpenComments lists unresolved comments in the Github repository.

func (*GithubClient) ListOpenIssues

func (gc *GithubClient) ListOpenIssues(options ListIssueOptions) ([]Issue, error)

ListOpenIssues lists unresolved issues in the Github repository.

func (*GithubClient) OpenCodeChangeRequest

func (gc *GithubClient) OpenCodeChangeRequest(req llm.CodeChangeRequest, res llm.CodeChangeResponse, fromBranch string) (id, url string, err error)

OpenCodeChangeRequest pushes to a new remote branch and opens a PR on Github.

func (*GithubClient) RemoveLabelFromIssue

func (gc *GithubClient) RemoveLabelFromIssue(issueNumber int, label string) error

RemoveLabelFromIssue removes the provided label from an issue if that label is applied.

func (*GithubClient) RespondToComment

func (gc *GithubClient) RespondToComment(prNumber int, commentID int64, comment string) error

RespondToComment adds a comment to the provided thread.

type Issue

type Issue struct {
	Number  int
	Subject string
	Body    string
	URL     string
	Author  Author
}

Issue represents an issue on a version control server.

func (Issue) String

func (i Issue) String() string

type IssueBody

type IssueBody struct {
	PromptBody string
	FilePaths  []string
	BaseBranch string
}

func ParseIssueBody

func ParseIssueBody(body string) IssueBody

type ListCommentOptions

type ListCommentOptions struct {
	// Handles defines the list of usernames to list comments from
	// The comment can be created by *any* user provided.
	Handles []string
}

ListCommentOptions defines options for listing comments.

type ListIssueOptions

type ListIssueOptions struct {
	// Labels defines the list of labels an issue must have in order to be listed
	// The issue must have *every* label provided.
	Labels []string
	// Handles defines the list of usernames to list issues from
	// The issue can be created by *any* user provided.
	Handles []string
}

ListIssueOptions defines options for listing issues.

type LocalGitClient

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

LocalGitClient represents a service that interacts with a local git repository.

func NewLocalGitClient

func NewLocalGitClient(log *zap.Logger, self Author, repo Repository, debugDir string) (*LocalGitClient, error)

NewLocalGitClient initializes a local git client by checking out a repository locally.

func (*LocalGitClient) CheckoutRemoteBranch

func (gc *LocalGitClient) CheckoutRemoteBranch(branchName string) (err error)

func (*LocalGitClient) FinishCommit

func (gc *LocalGitClient) FinishCommit(message string) error

FinishCommit completes a commit, after which a code change request can be opened or updated.

func (*LocalGitClient) GetLocalFile

func (gc *LocalGitClient) GetLocalFile(path string) (llm.File, error)

func (*LocalGitClient) ParseIssueAndStartCommit

func (gc *LocalGitClient) ParseIssueAndStartCommit(issue Issue) (llm.CodeChangeRequest, error)

ParseIssueAndStartCommit parses the information provided in the issue to check out the appropriate branch, get the contents of the files mentioned in the issue, and initialize the worktree.

func (*LocalGitClient) PushBranch

func (gc *LocalGitClient) PushBranch(branchName string) (err error)

func (*LocalGitClient) ReplaceOrAddLocalFile

func (gc *LocalGitClient) ReplaceOrAddLocalFile(newFile llm.File) error

ReplaceOrAddLocalFile updates or adds a file in the locally cloned repo, and applies these changes to the current git worktree.

func (*LocalGitClient) StartCommit

func (gc *LocalGitClient) StartCommit() error

type Repository

type Repository struct {
	LocalPath  string
	HostDomain string
	Name       string
	Owner      Author
	// contains filtered or unexported fields
}

Repository represents a version control repository and its local path.

func (Repository) HTTPS

func (repo Repository) HTTPS() string

HTTPS returns the HTTPS representation of the remote repository.

func (Repository) SSH

func (repo Repository) SSH() string

SSH returns the SSH connection string for the repository.

Jump to

Keyboard shortcuts

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