github

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxRetries = 3
View Source
const GITHUB_CLONE_DEPTH_ENV = "TFBUDDY_GITHUB_CLONE_DEPTH"

Variables

This section is empty.

Functions

func ResolveOwnerName

func ResolveOwnerName(owner *gogithub.User) (string, error)

ResolveOwnerName is a helper func to find a name for the repo owner, which could be in the `Name` field or `Login.

func String

func String(str string) *string

Types

type Client

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

func NewGithubClient

func NewGithubClient(cfg config.Config) *Client

func (*Client) AddMergeRequestDiscussionReply

func (c *Client) AddMergeRequestDiscussionReply(ctx context.Context, prID int, fullName, discussionID, comment string) (vcs.MRNote, error)

func (*Client) CloneMergeRequest

func (c *Client) CloneMergeRequest(ctx context.Context, project string, mr vcs.MR, dest string) (vcs.GitRepo, error)

func (*Client) CreateMergeRequestComment

func (c *Client) CreateMergeRequestComment(ctx context.Context, prID int, fullName string, comment string) error

func (*Client) CreateMergeRequestCommentWithID added in v0.7.1

func (c *Client) CreateMergeRequestCommentWithID(
	ctx context.Context,
	prID int,
	fullName,
	comment string,
) (int64, error)

func (*Client) CreateMergeRequestDiscussion

func (c *Client) CreateMergeRequestDiscussion(ctx context.Context, prID int, fullName string, comment string) (vcs.MRDiscussionNotes, error)

func (*Client) GetAuthenticatedAccountName added in v0.7.1

func (c *Client) GetAuthenticatedAccountName(ctx context.Context) (string, error)

func (*Client) GetCommitJobStatuses added in v0.6.0

func (c *Client) GetCommitJobStatuses(ctx context.Context, projectWithNS string, commitSHA string) ([]vcs.CommitJobStatus, error)

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, owner *gogithub.User, repo string, issueId int) (*gogithub.Issue, error)

func (*Client) GetMergeRequest

func (c *Client) GetMergeRequest(ctx context.Context, prID int, fullName string) (vcs.DetailedMR, error)

func (*Client) GetMergeRequestApprovals

func (c *Client) GetMergeRequestApprovals(ctx context.Context, id int, project string) (vcs.MRApproved, error)

func (*Client) GetMergeRequestModifiedFiles

func (c *Client) GetMergeRequestModifiedFiles(ctx context.Context, prID int, fullName string) ([]string, error)

func (*Client) GetOldRunUrls added in v0.2.0

func (c *Client) GetOldRunUrls(ctx context.Context, prID int, fullName string, rootCommentID int, runID string, workspace string, action string) (string, error)

GetOldRunUrls crawls PR comments authored by the bot, collects previous TFC run URLs into a collapsible block, and (when TFBUDDY_DELETE_OLD_COMMENTS is set) deletes old comments that belong to the same workspace+action combination. Comments for other workspaces or actions are left untouched.

GitHub has no threads: the run's starting comment (rootCommentID) and each of its status updates are separate comments. Old comments are those posted before the starting comment, and the run's own status updates, found by runID. The starting comment itself is kept until a newer run cleans up.

Two runs of one workspace can overlap, for example a push and a `tfc plan` comment in the same minute. A comment posted after the starting comment by another run is left alone: it belongs to a newer run, or to an older run that is still posting. When a newer run has already deleted this run's starting comment, the run is superseded: it only deletes its own status updates and returns vcs.ErrRunSuperseded, so it does not post a stale result after the newer one. PostRunResult covers a newer run that replaces this one after this check.

func (*Client) GetPipelinesForCommit

func (c *Client) GetPipelinesForCommit(ctx context.Context, projectWithNS string, commitSHA string) ([]vcs.ProjectPipeline, error)

func (*Client) GetProjectSettings added in v0.6.0

func (c *Client) GetProjectSettings(ctx context.Context, projectWithNS string) (vcs.ProjectSettings, error)

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, fullName string, prID int) (*GithubPR, error)

func (*Client) GetRepoFile

func (c *Client) GetRepoFile(ctx context.Context, fullName string, file string, ref string) ([]byte, error)

func (*Client) ListRepoDirectories added in v0.8.3

func (c *Client) ListRepoDirectories(ctx context.Context, fullName, dir, ref string) ([]string, error)

ListRepoDirectories returns every directory below dir at ref, recursively, relative to the repo root. A dir that does not exist at ref yields nothing.

func (*Client) MergeMR added in v0.3.0

func (c *Client) MergeMR(ctx context.Context, mrIID int, project string) error

func (*Client) MergeMRAtSHA added in v0.7.0

func (c *Client) MergeMRAtSHA(ctx context.Context, mrIID int, project, _ string) error

MergeMRAtSHA satisfies the shared VCS interface. GitHub auto-merge does not use the GitLab-only aggregate coordinator, so preserve its existing behavior.

func (*Client) PostIssueComment

func (c *Client) PostIssueComment(ctx context.Context, prId int, fullName string, body string) (*gogithub.IssueComment, error)

PostIssueComment adds a comment to an existing Pull Request

func (*Client) PostPullRequestComment

func (c *Client) PostPullRequestComment(ctx context.Context, owner, repo string, prId int, body string) error

PostPullRequestComment adds a review comment to an existing PullRequest

func (*Client) PostRunResult added in v0.8.6

func (c *Client) PostRunResult(ctx context.Context, prID int, fullName string, rootCommentID int, body string) error

PostRunResult posts a run's final comment. GetOldRunUrls only checks that the run is current before the result is posted: a newer run of the same workspace, handled on another replica, can delete this run's starting comment (rootCommentID) and post its own result in between. So once the result is posted, the starting comment is checked again. If it is gone, the result is stale and is deleted again, keeping the newer run's result last, and vcs.ErrRunSuperseded is returned.

func (*Client) ResolveMergeRequestDiscussion

func (c *Client) ResolveMergeRequestDiscussion(ctx context.Context, s string, i int, s2 string) error

func (*Client) ResolveMergeRequestDiscussions added in v0.7.0

func (c *Client) ResolveMergeRequestDiscussions(context.Context, string, int, string, string) error

func (*Client) SetCommitStatus

func (c *Client) SetCommitStatus(ctx context.Context, projectWithNS string, commitSHA string, status vcs.CommitStatusOptions) (vcs.CommitStatus, error)

func (*Client) SetWorkspaceStatus added in v0.8.0

func (c *Client) SetWorkspaceStatus(ctx context.Context, status vcs.WorkspaceStatus) error

SetWorkspaceStatus is intentionally a no-op. GitHub commit statuses are not implemented (see SetCommitStatus above), so TFBuddy surfaces skipped and failed workspaces on GitHub through pull request comments instead.

func (*Client) SupportsAggregateAutoMerge added in v0.7.0

func (c *Client) SupportsAggregateAutoMerge() bool

func (*Client) UpdateMergeRequestComment added in v0.7.1

func (c *Client) UpdateMergeRequestComment(
	ctx context.Context,
	_ int,
	noteID int64,
	fullName,
	comment string,
) error

func (*Client) UpdateMergeRequestDiscussionNote

func (c *Client) UpdateMergeRequestDiscussionNote(ctx context.Context, mrIID, noteID int, project, discussionID, comment string) (vcs.MRNote, error)

type GithubPR

type GithubPR struct {
	*gogithub.PullRequest
}

func (*GithubPR) GetAuthor

func (gm *GithubPR) GetAuthor() vcs.MRAuthor

func (*GithubPR) GetInternalID

func (gm *GithubPR) GetInternalID() int

func (*GithubPR) GetSourceBranch

func (gm *GithubPR) GetSourceBranch() string

func (*GithubPR) GetState added in v0.3.7

func (gm *GithubPR) GetState() string

func (*GithubPR) GetTargetBranch

func (gm *GithubPR) GetTargetBranch() string

func (*GithubPR) GetTitle

func (gm *GithubPR) GetTitle() string

func (*GithubPR) GetWebURL

func (gm *GithubPR) GetWebURL() string

func (*GithubPR) HasConflicts

func (gm *GithubPR) HasConflicts() bool

func (*GithubPR) IsApproved

func (gm *GithubPR) IsApproved() bool

func (*GithubPR) IsDraft added in v0.8.3

func (gm *GithubPR) IsDraft() bool

type GithubPRAuthor

type GithubPRAuthor struct {
	*gogithub.User
}

func (*GithubPRAuthor) GetUsername

func (ga *GithubPRAuthor) GetUsername() string

type GithubPRIssueComment

type GithubPRIssueComment struct {
	*gogithub.IssueComment
}

func (*GithubPRIssueComment) GetDiscussionID

func (c *GithubPRIssueComment) GetDiscussionID() string

func (*GithubPRIssueComment) GetMRNotes

func (c *GithubPRIssueComment) GetMRNotes() []vcs.MRNote

type IssueComment

type IssueComment struct {
	*gogithub.IssueComment
}

func (*IssueComment) GetDiscussionID

func (c *IssueComment) GetDiscussionID() string

func (*IssueComment) GetMRNotes

func (c *IssueComment) GetMRNotes() []vcs.MRNote

func (*IssueComment) GetNoteID

func (c *IssueComment) GetNoteID() int64

type PRApproved

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

func (*PRApproved) IsApproved

func (p *PRApproved) IsApproved() bool

type RunEventsWorker

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

func NewRunEventsWorker

func NewRunEventsWorker(cfg config.Config, client *Client, rs runstream.StreamClient, tfc tfc_api.ApiClient) *RunEventsWorker

func (*RunEventsWorker) Close

func (w *RunEventsWorker) Close()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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