Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): create a GitHub Pull Request from a fork (#45)
* made logger global (for read-only) and main interface for pr
- Loading branch information
1 parent
d078cce
commit 782bced
Showing
19 changed files
with
868 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2020 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {CreatePullRequest, CreatePullRequestUserOptions} from './types'; | ||
|
||
const DEFAULT_BRANCH_NAME = 'code-suggestions'; | ||
const DEFAULT_PRIMARY_BRANCH = 'master'; | ||
|
||
/** | ||
* Add defaults to GitHub Pull Request options. | ||
* Preserves the empty string. | ||
* For ESCMAScript, null/undefined values are preserved for required fields. | ||
* Recommended with an object validation function to check empty strings and incorrect types. | ||
* @param {PullRequestUserOptions} options the user-provided github pull request options | ||
* @returns {CreatePullRequest} git hub context with defaults applied | ||
*/ | ||
function addPullRequestDefaults( | ||
options: CreatePullRequestUserOptions | ||
): CreatePullRequest { | ||
const pullRequestSettings: CreatePullRequest = { | ||
upstreamOwner: options.upstreamOwner, | ||
upstreamRepo: options.upstreamRepo, | ||
description: options.description, | ||
title: options.title, | ||
message: options.message, | ||
force: options.force || false, | ||
branch: | ||
typeof options.branch === 'string' ? options.branch : DEFAULT_BRANCH_NAME, | ||
primary: | ||
typeof options.primary === 'string' | ||
? options.primary | ||
: DEFAULT_PRIMARY_BRANCH, | ||
maintainersCanModify: options.maintainersCanModify === false ? false : true, | ||
}; | ||
return pullRequestSettings; | ||
} | ||
|
||
export {addPullRequestDefaults}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './fork-handler'; | ||
export {branch} from './branch-handler'; | ||
export {commitAndPush} from './commit-and-push-handler'; | ||
export * from './pr-handler'; | ||
export * from './pull-request-handler'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.