bitbucket

package
v0.11.5-rc2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package bitbucket implements the client for Bitbucket Cloud.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor struct {
	Type           string `json:"type"`
	User           User   `json:"user,omitempty"`
	Role           string `json:"role,omitempty"`
	Approved       *bool  `json:"approved,omitempty"`
	State          any    `json:"state,omitempty"`
	ParticipatedOn string `json:"participated_on,omitempty"`
}

Actor is a Bitbucket actor.

type Branch

type Branch struct {
	Name                 string   `json:"name"`
	MergeStrategies      []string `json:"merge_strategies"`
	DefaultMergeStrategy string   `json:"default_merge_strategy"`
}

Branch is a Bitbucket branch.

type Client

type Client struct {
	// BaseURL is the base URL used to construct the final URL of endpoints.
	// For Bitbucket Cloud, it should be https://api.bitbucket.org/2.0
	BaseURL string

	// HTTPClient is the HTTP client used to make requests.
	// if not set, a new http.Client is used on each request.
	HTTPClient *http.Client

	// Token is the Bitbucket Cloud token.
	Token string

	// Workspace is the Bitbucket Cloud workspace.
	Workspace string

	// RepoSlug is the Bitbucket Cloud repository slug.
	RepoSlug string
}

Client is a Bitbucket Cloud client.

func (*Client) GetCommit

func (c *Client) GetCommit(ctx context.Context, commit string) (Commit, error)

GetCommit fetches a commit by its hash.

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(id int) (pr PR, err error)

GetPullRequest fetches a pull request by its ID.

func (*Client) GetPullRequestsByCommit

func (c *Client) GetPullRequestsByCommit(ctx context.Context, commit string) (prs []PR, err error)

GetPullRequestsByCommit fetches a list of pull requests that contain the given commit. TODO: implement pagination.

type Commit

type Commit struct {
	ShortHash string `json:"hash"`

	// Note: this is not part of the Bitbucket API response.
	// This is fetched from the commit API and stored here for convenience.
	SHA string
}

Commit is a Bitbucket commit.

type Links struct {
	Self *struct {
		Href string `json:"href,omitempty"`
	} `json:"self"`
	HTML *struct {
		Href string `json:"href,omitempty"`
	} `json:"html"`
	Avatar *struct {
		Href string `json:"href,omitempty"`
	} `json:"avatar"`
}

Links is a collection of Bitbucket links.

type PR

type PR struct {
	Type              string       `json:"type"`
	ID                int          `json:"id"`
	Title             string       `json:"title"`
	Rendered          Rendered     `json:"rendered"`
	Summary           Summary      `json:"summary"`
	State             string       `json:"state"`
	Author            User         `json:"author"`
	Source            TargetBranch `json:"source"`
	Destination       TargetBranch `json:"destination"`
	MergeCommit       Commit       `json:"merge_commit"`
	CommentCount      int          `json:"comment_count"`
	TaskCount         int          `json:"task_count"`
	CloseSourceBranch bool         `json:"close_source_branch"`
	ClosedBy          *Actor       `json:"closed_by,omitempty"`
	Reason            string       `json:"reason"`
	CreatedOn         string       `json:"created_on"`
	UpdatedOn         string       `json:"updated_on"`
	Reviewers         []Actor      `json:"reviewers"`
	Participants      []Actor      `json:"participants"`
	Links             Links        `json:"links"`
}

PR is a Bitbucket Pull Request.

type PRs

type PRs []PR

PRs is a list of Bitbucket Pull Requests.

type PullRequestResponse

type PullRequestResponse struct {
	Size     int    `json:"size"`
	Page     int    `json:"page"`
	PageLen  int    `json:"pagelen"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
	Values   []PR   `json:"values"`
}

PullRequestResponse is the response of a pull request list.

type Rendered

type Rendered struct {
	Title       RenderedContent `json:"title"`
	Description RenderedContent `json:"description"`
	Reason      RenderedContent `json:"reason"`
}

Rendered is the rendered version of the PR metadata.

type RenderedContent

type RenderedContent struct {
	Raw    string `json:"raw"`
	Markup string `json:"markup"`
	HTML   string `json:"html"`
}

RenderedContent is the rendered version of the PR content.

type Summary

type Summary RenderedContent

Summary is a Bitbucket Pull Request summary.

type TargetBranch

type TargetBranch struct {
	Repository struct {
		Type string `json:"type"`
	}
	Branch Branch `json:"branch"`
	Commit Commit `json:"commit"`
}

TargetBranch is the source or destination branch of a pull request.

type User

type User struct {
	Type        string `json:"type"`
	DisplayName string `json:"display_name"`
	Links       *Links `json:"links"`
	UUID        string `json:"uuid"`
	AccountID   string `json:"account_id"`
	Nickname    string `json:"nickname"`
}

User is a Bitbucket user.

Jump to

Keyboard shortcuts

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