Skip to content

Commit 2074e97

Browse files
authored
Update README.md
1 parent c7c73eb commit 2074e97

File tree

1 file changed

+55
-16
lines changed

1 file changed

+55
-16
lines changed

README.md

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,55 @@
1-
# gpt-pullrequest-updater
2-
3-
### Usage:
4-
main [OPTIONS]
5-
6-
### Application Options:
7-
--gh-token= GitHub token [$GITHUB_TOKEN]
8-
--openai-token= OpenAI token [$OPENAI_TOKEN]
9-
--owner= GitHub owner [$OWNER]
10-
--repo= GitHub repo [$REPO]
11-
--pr-number= Pull request number [$PR_NUMBER]
12-
--test Test mode [$TEST]
13-
--skip-files= Skip files. Comma separated list (default: go.mod,go.sum,.pb.go) [$SKIP_FILES]
14-
15-
### Help Options:
16-
-h, --help Show this help message
1+
# Pull Request Description Generator
2+
3+
This Go program automates the process of generating GitHub pull request descriptions based on the changes made in each file. It uses OpenAI's GPT-3.5-turbo model to generate the descriptions and Jira issue links based on the PR title.
4+
5+
## Installation
6+
7+
To install the program, clone the repository and build the binary:
8+
9+
```sh
10+
git clone https://github.com/your-repo/pull-request-description-generator.git
11+
cd pull-request-description-generator
12+
go build
13+
```
14+
15+
## Usage
16+
17+
Before running the program, you'll need to set the following environment variables:
18+
19+
- `GITHUB_TOKEN`: Your GitHub access token.
20+
- `OPENAI_TOKEN`: Your OpenAI access token.
21+
- `OWNER`: The GitHub owner (username or organization) of the repository.
22+
- `REPO`: The GitHub repository name.
23+
- `PR_NUMBER`: The pull request number.
24+
25+
You can also use flags to provide the required information:
26+
27+
```
28+
./pull-request-description-generator --gh-token <GITHUB_TOKEN> --openai-token <OPENAI_TOKEN> --owner <OWNER> --repo <REPO> --pr-number <PR_NUMBER>
29+
```
30+
31+
Optional flags:
32+
33+
- `--test`: Test mode. The generated description will be printed to the console without updating the pull request.
34+
- `--skip-files`: Comma-separated list of files to skip when generating the description (default: "go.mod,go.sum,.pb.go").
35+
36+
After running the program, the pull request description will be updated with the generated content.
37+
38+
## Dependencies
39+
40+
- [go-flags](https://github.com/jessevdk/go-flags): A Go library for command line flag parsing.
41+
- [go-openai](https://github.com/sashabaranov/go-openai): A Go client for the OpenAI API.
42+
43+
## Functions
44+
45+
- `getDiffContent`: Fetches the diff content from the GitHub API.
46+
- `parseGitDiffAndSplitPerFile`: Parses the git diff and splits it into a slice of FileDiff.
47+
- `getFilenameFromDiffHeader`: Extracts the filename from a diff header.
48+
- `generatePRDescription`: Generates the pull request description using the OpenAI API.
49+
- `getPullRequestTitle`: Fetches the pull request title from the GitHub API.
50+
- `generateJiraLinkByTitle`: Generates a Jira issue link based on the PR title.
51+
- `updatePullRequestDescription`: Updates the pull request description on GitHub.
52+
53+
## License
54+
55+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)