torvalds

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 7 Imported by: 0

README

What Would Linus Torvalds Say

[!WARNING] Only works on pull requests. Obviously don't use this unless you've got cash to burn since this will run on every pull request.

ChatGPT4.0 has way better results or you can try fine-tuning the model using r/linusrants or some of the examples in fixtures/fine-tuning.

Add a .github/workflows/wwlts file with the following contents:

on:
  pull_request:
    branches: [ main ]

jobs:
  review:
    runs-on: ubuntu-latest
    name: Review my patch pls
    steps:
      - name: Review
        uses: algleymi/what-would-linus-torvalds-say@v1.0.0
        env:
          GITHUB_TOKEN: ${{ github.token }}
          OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}
          OPENAI_MODEL: "gpt-3.5-turbo" # optional, works with any model the token has access to

Or use the CLI:

$ go build -o torvaldsify cmd/cli/main.go
$ ./torvaldsify <owner> <repo> <prNumber> # e.g. ./torvaldsify algleymi what-would-linus-torvalds-say 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCouldNotFindEvent = errors.New("could not find pull request event")
View Source
var ErrCouldNotFindGithubToken = errors.New("could not find github token")
View Source
var ErrDiffTooLarge = errors.New("diff too large")
View Source
var ErrNoOpenAIToken = errors.New("no openai token")

Functions

func AddCommentToPullRequest

func AddCommentToPullRequest(owner string, repositoryName string, prNumber int, comment string) error

func AskTorvalds

func AskTorvalds(diff string) (string, error)

func GetDiffFromPullRequest

func GetDiffFromPullRequest(owner string, repositoryName string, prNumber int) (string, error)

Types

type Event

type Event struct {
	Number     int        `json:"number"`
	Repository Repository `json:"repository"`
}

func ParseEventFromGithubActionsEvent

func ParseEventFromGithubActionsEvent() (*Event, error)

type Owner

type Owner struct {
	Login string `json:"login"`
}

type Repository

type Repository struct {
	Name  string `json:"name"`
	Owner Owner  `json:"owner"`
}

Directories

Path Synopsis
cmd
action command
cli command

Jump to

Keyboard shortcuts

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