github

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const PULLREQUESTBODY = `
# {{ .Title }}

{{ if .Introduction }}
{{ .Introduction }}
{{ end }}


## Report

{{ .Report }}

## Changelog

<details><summary>Click to expand</summary>

` + "````\n{{ .Description }}\n````" + `

</details>

## Remark

This pull request was automatically created using [Updatecli](https://www.updatecli.io).

Please report any issues with this tool [here](https://github.com/updatecli/updatecli/issues/new)

`

PULLREQUESTBODY is the pull request template used as pull request description Please note that triple backticks are concatenated with the literals, as they cannot be escaped

Variables

This section is empty.

Functions

func MergeLabels added in v0.17.0

func MergeLabels(a, b []repositoryLabelApi) []repositoryLabelApi

Types

type Changelog

type Changelog struct {
	Title       string
	Description string
	Report      string
}

Changelog contains various information used to describe target changes

type Github

type Github struct {
	Spec          Spec          // Spec contains inputs coming from updatecli configuration
	HeadBranch    string        // remoteBranch is used when creating a temporary branch before opening a PR
	Force         bool          // Force is used during the git push phase to run `git push --force`.
	CommitMessage commit.Commit // CommitMessage represents conventional commit metadata as type or scope, used to generate the final commit message.
	// contains filtered or unexported fields
}

Github contains settings to interact with Github

func New added in v0.10.0

func New(s Spec) (Github, error)

New returns a new valid Github object.

func (*Github) Add

func (g *Github) Add(files []string) error

Add run `git add`.

func (*Github) Changelog

func (g *Github) Changelog(name string) (string, error)

Changelog returns a changelog description based on a release name

func (*Github) Checkout

func (g *Github) Checkout() error

Checkout create and then uses a temporary git branch.

func (*Github) Clean

func (g *Github) Clean() error

Clean deletes github working directory.

func (*Github) Clone

func (g *Github) Clone() (string, error)

Clone run `git clone`.

func (*Github) Commit

func (g *Github) Commit(message string) error

Commit run `git commit`.

func (*Github) GetChangedFiles added in v0.12.0

func (g *Github) GetChangedFiles(workingDir string) ([]string, error)

func (*Github) GetDirectory

func (g *Github) GetDirectory() (directory string)

GetDirectory returns the local git repository path.

func (*Github) GetRepositoryLabels added in v0.17.0

func (g *Github) GetRepositoryLabels() ([]repositoryLabelApi, error)

GetRepositoryLabels queries GitHub Api to retrieve every labels configured for a repository

func (*Github) Init

func (g *Github) Init(source string, pipelineID string) error

Init set default Github parameters if not set.

func (*Github) NewClient

func (g *Github) NewClient() *githubv4.Client

NewClient return a new client

func (*Github) Push

func (g *Github) Push() error

Push run `git push` then open a pull request on Github if not already created.

func (*Github) PushTag

func (g *Github) PushTag(tag string) error

PushTag push tags

func (*Github) SearchReleases

func (g *Github) SearchReleases() (releases []string, err error)

SearchReleases return every releases from the github api returned in reverse order of created time.

func (*Github) SearchTags

func (g *Github) SearchTags() (tags []string, err error)

SearchTags return every tags from the github api return in reverse order of commit tags.

func (*Github) Source

func (g *Github) Source(workingDir string) (value string, err error)

Source retrieves a specific version tag from Github Releases.

type PageInfo

type PageInfo struct {
	HasNextPage     bool
	HasPreviousPage bool
	EndCursor       string
	StartCursor     string
}

PageInfo is used for Graphql queries to iterate over pagination

type PullRequest

type PullRequest struct {
	Description string
	Report      string
	Title       string
	// contains filtered or unexported fields
}

func NewPullRequest added in v0.17.0

func NewPullRequest(spec PullRequestSpec, gh *Github) (PullRequest, error)

func (*PullRequest) CreatePullRequest added in v0.17.0

func (p *PullRequest) CreatePullRequest(title, changelog, pipelineReport string) error

func (*PullRequest) GetPullRequestLabelsInformation added in v0.17.0

func (p *PullRequest) GetPullRequestLabelsInformation() ([]repositoryLabelApi, error)

getPullRequestLabelsInformation queries GitHub Api to retrieve every labels assigned to a pullRequest

func (*PullRequest) OpenPullRequest added in v0.17.0

func (p *PullRequest) OpenPullRequest() error

OpenPullRequest creates a new pull request on Github.

type PullRequestApi added in v0.17.0

type PullRequestApi struct {
	BaseRefName string
	Body        string
	HeadRefName string
	ID          string
	State       string
	Title       string
	Url         string
	Number      int
}

PullRequest contains multiple fields mapped to Github V4 api

type PullRequestSpec added in v0.14.0

type PullRequestSpec struct {
	Title                  string   // Specify pull request title
	Description            string   // Description contains user input description used during pull body creation
	Labels                 []string // Specify repository labels used for pull request. !! They must already exist
	Draft                  bool     // Define if a pull request is set to draft, default false
	MaintainerCannotModify bool     // Define if maintainer can modify pullRequest
}

PullRequestSpec is a specific struct containing pullrequest settings provided by an updatecli configuration

type RateLimit

type RateLimit struct {
	Cost      int
	Remaining int
	ResetAt   string
}

RateLimit is a struct that contains Github Api limit information

func (*RateLimit) Show

func (a *RateLimit) Show()

Show display Github Api limit usage

type Spec added in v0.10.0

type Spec struct {
	Branch        string          // Branch specifies which github branch to work on
	Directory     string          // Directory specifies where the github repisotory is cloned on the local disk
	Email         string          // Email specifies which emails to use when creating commits
	Owner         string          // Owner specifies repository owner
	Repository    string          // Repository specifies the name of a repository for a specific owner
	Version       string          // **Deprecated** Version is deprecated in favor of `versionFilter.pattern`, this field will be removed in a future version
	VersionFilter version.Filter  //VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.
	Token         string          // Token specifies the credential used to authenticate with
	URL           string          // URL specifies the default github url in case of GitHub enterprise
	Username      string          // Username specifies the username used to authenticate with Github API
	User          string          // User specific the user in git commit messages
	PullRequest   PullRequestSpec // Deprecated since https://github.com/updatecli/updatecli/issues/260, must be clean up
}

Spec represents the configuration input

func (*Spec) SpecToPullRequestSpec added in v0.17.0

func (s *Spec) SpecToPullRequestSpec() interface{}

SpecToPullRequestSpec is a function that export the pullRequest spec from a GithubSpec to a PullRequest.Spec. It's temporary function until we totally remove the old scm configuration introduced by this https://github.com/updatecli/updatecli/pull/388

func (*Spec) Validate added in v0.10.0

func (s *Spec) Validate() (errs []error)

Validate verifies if mandatory Github parameters are provided and return false if not.

Jump to

Keyboard shortcuts

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