code-suggester
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -35,3 +35,2 @@ "use strict"; | ||
logger_1.logger.info(`Fork successfully exists on ${upstream.repo}`); | ||
// TODO autosync | ||
return { | ||
@@ -38,0 +37,0 @@ repo: forkedRepo.name, |
@@ -31,3 +31,12 @@ "use strict"; | ||
async function openPullRequest(octokit, upstream, origin, description, maintainersCanModify = true, upstreamPrimary = DEFAULT_PRIMARY) { | ||
// TODO - autosync fork, update branch, and re-apply changes | ||
const head = `${origin.owner}:${origin.branch}`; | ||
const existingPullRequest = (await octokit.pulls.list({ | ||
owner: upstream.owner, | ||
repo: origin.repo, | ||
head, | ||
})).data.findIndex(pr => pr.head.label === head) >= 0; | ||
if (existingPullRequest) { | ||
logger_1.logger.info(`Found existing pull request for reference ${origin.owner}:${origin.branch}. Skipping creating a new pull request.`); | ||
return; | ||
} | ||
const pullResponseData = (await octokit.pulls.create({ | ||
@@ -34,0 +43,0 @@ owner: upstream.owner, |
# Changelog | ||
## [1.1.0](https://www.github.com/googleapis/code-suggester/compare/v1.0.1...v1.1.0) (2020-08-07) | ||
### Features | ||
* **action:** setup configuration for GitHub actions ([#69](https://www.github.com/googleapis/code-suggester/issues/69)) ([b879d75](https://www.github.com/googleapis/code-suggester/commit/b879d75c8b051a4cfd0a19088946f496b4beaeb0)) | ||
### Bug Fixes | ||
* **core-library:** do not create pr when a pr already exists for a ref ([#66](https://www.github.com/googleapis/code-suggester/issues/66)) ([4c7b259](https://www.github.com/googleapis/code-suggester/commit/4c7b259e7025d5a5a4357cbb588a7cfa66869023)), closes [#17](https://www.github.com/googleapis/code-suggester/issues/17) | ||
### [1.0.1](https://www.github.com/googleapis/code-suggester/compare/v1.0.0...v1.0.1) (2020-08-04) | ||
@@ -4,0 +16,0 @@ |
{ | ||
"name": "code-suggester", | ||
"description": "Library to propose code changes", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google LLC", |
@@ -17,5 +17,7 @@ [//]: # "This README.md file is auto-generated, all changes to this file will be lost." | ||
1. can be imported as a [library](#Core-Library), or | ||
2. used as a [CLI](#CLI) tool | ||
2. used as a [CLI](#CLI) tool, or | ||
3. configured in a [GitHub Action](#Action) | ||
## Core Library | ||
@@ -131,2 +133,6 @@ | ||
#### Environment Variables | ||
#### `ACCESS_TOKEN` | ||
*string* <br> | ||
**Required.** The GitHub access token which has permissions to fork, write to its forked repo and its branches, as well as create Pull Requests on the upstream repository. | ||
@@ -178,2 +184,89 @@ #### Options | ||
## Action | ||
### create a pull request | ||
Opens a GitHub Pull Request against the upstream primary branch with the provided git directory. By default the git directory is the same as the `$GITHUB_WORKSPACE` directory. | ||
#### Syntax | ||
`pr --upstream-repo=<string> --upstream-owner=<string> --title=<string> --description=<string> --message=<string> [options] ` | ||
#### Environment Variables | ||
#### `ACCESS_TOKEN` | ||
*string* <br> | ||
**Required.** The GitHub access token which has permissions to fork, write to its forked repo and its branches, as well as create Pull Requests on the upstream repository. We recommend storing it as a secret in your GitHub repository. | ||
#### Options | ||
#### `upstream_repo` | ||
*string* <br> | ||
**Required.** The repository to create the fork off of. | ||
#### `upstream_owner` | ||
*string* <br> | ||
**Required.** The owner of the upstream repository. | ||
#### `description` | ||
*string* <br> | ||
**Required.** The GitHub Pull Request description. | ||
#### `title` | ||
*string* <br> | ||
**Required.** The GitHub Pull Request title. | ||
#### `branch` | ||
*string* <br> | ||
The GitHub working branch name. Default value is: `'code-suggestions'`. | ||
#### `primary` | ||
*string* <br> | ||
The primary upstream branch to open a PR against. Default value is: `'master'`. | ||
#### `message` | ||
*string* <br> | ||
**Required.** The GitHub commit message. | ||
#### `force` | ||
*boolean* <br> | ||
Whether or not to force push a reference with different commit history before the remote reference HEAD. Default value is: `false`. | ||
#### `maintainers_can_modify` | ||
*boolean* <br> | ||
Whether or not maintainers can modify the pull request. Default value is: `true`. | ||
#### `git_dir` | ||
*string* <br> | ||
**Required.** The path of a git directory. Relative to `$GITHUB_WORKSPACE`. | ||
### Example | ||
The following example is a `.github/workflows/main.yaml` file in repo `Octocat/HelloWorld`. This would add a LICENSE folder to the root `HelloWorld` repo on every pull request if it is not already there. | ||
```yaml | ||
on: | ||
push: | ||
branches: | ||
- master | ||
name: ci | ||
jobs: | ||
add-license: | ||
runs-on: ubuntu-latest | ||
env: | ||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: <YOUR CHANGES> # the physical changes you want to make to your repository | ||
run: (curl http://www.apache.org/licenses/LICENSE-2.0.txt) > LICENSE # For example adding LICENSE file | ||
- uses: googleapis/code-suggester@v1 # takes the changes from git directory | ||
with: | ||
command: pr | ||
upstream_owner: Octocat | ||
upstream_repo: HelloWorld | ||
description: 'This pull request is adding a LICENSE file' | ||
title: 'chore(license): add license file' | ||
message: 'chore(license): add license file' | ||
branch: my-branch | ||
git_dir: '.' | ||
``` | ||
## Supported Node.js Versions | ||
@@ -180,0 +273,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
99358
1212
331