Skip to content

Commit bf91b7c

Browse files
committed
Create Pull Request improvements
1 parent 225921b commit bf91b7c

File tree

2 files changed

+20
-75
lines changed

2 files changed

+20
-75
lines changed

components/github/actions/create-pull-request/create-pull-request.mjs

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { ConfigurationError } from "@pipedream/platform";
2-
import { toSingleLineString } from "../../common/utils.mjs";
32
import github from "../../github.app.mjs";
43

54
export default {
65
key: "github-create-pull-request",
76
name: "Create Pull Request",
8-
description: toSingleLineString(`
9-
Creates a new pull request for a specified repository.
10-
[See the documentation](https://docs.github.com/en/rest/pulls/pulls#create-a-pull-request)
11-
`),
12-
version: "0.0.9",
7+
description: "Creates a new pull request for a specified repository. [See the documentation](https://docs.github.com/en/rest/pulls/pulls#create-a-pull-request)",
8+
version: "0.1.{{ts}}",
139
type: "action",
1410
props: {
1511
github,
@@ -18,20 +14,8 @@ export default {
1814
github,
1915
"repoFullname",
2016
],
21-
},
22-
head: {
23-
propDefinition: [
24-
github,
25-
"branch",
26-
(c) => ({
27-
repoFullname: c.repoFullname,
28-
}),
29-
],
30-
label: "Head Branch",
31-
description: toSingleLineString(`
32-
The name of the branch where your changes are implemented.
33-
For cross-repository pull requests in the same network, \`namespace\` head with a user like this: \`username:branch\`.
34-
`),
17+
label: "Base Repository",
18+
description: "The base repository, where the pull request will be created.",
3519
},
3620
base: {
3721
propDefinition: [
@@ -42,58 +26,48 @@ export default {
4226
}),
4327
],
4428
label: "Base Branch",
45-
description: toSingleLineString(`
46-
The name of the branch you want the changes pulled into.
47-
This should be an existing branch on the current repository.
48-
You cannot submit a pull request to one repository that requests a merge to a base of another repository.
49-
`),
29+
description: "The base branch, where the changes will be received.",
5030
},
51-
org: {
31+
headRepo: {
5232
propDefinition: [
5333
github,
54-
"orgName",
34+
"repoFullname",
5535
],
56-
optional: true,
36+
label: "Head Repository",
37+
description: "The head repository, where the changes originate from. This can, but does not have to, be the same repository.",
5738
},
58-
headRepo: {
39+
head: {
5940
propDefinition: [
6041
github,
61-
"repoOrg",
42+
"branch",
6243
(c) => ({
63-
org: c.org,
44+
repoFullname: c.headRepo,
6445
}),
6546
],
66-
label: "Head Repository's Name",
67-
description: toSingleLineString(`
68-
The name of the repository where the changes in the pull request were made.
69-
This field is required for cross-repository pull requests if both repositories are owned by the same organization.
70-
`),
71-
optional: true,
47+
label: "Head Branch",
48+
description: "The head branch, where the changes originate from",
7249
},
7350
body: {
7451
label: "Body",
75-
description: "The contents of the pull request.",
52+
description: "The text description of the pull request.",
7653
type: "string",
7754
optional: true,
7855
},
7956
maintainerCanModify: {
80-
label: "Maintainer Can Modify",
57+
label: "Maintainers Can Modify",
8158
description: "Indicates whether [maintainers can modify](https://docs.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) the pull request.",
8259
type: "boolean",
8360
optional: true,
8461
},
8562
draft: {
8663
label: "Is Draft",
87-
description: toSingleLineString(`
88-
Indicates whether the pull request is a draft.
89-
See "[Draft Pull Requests](https://docs.github.com/articles/about-pull-requests#draft-pull-requests)" in the GitHub Help documentation to learn more.
90-
`),
64+
description: "Indicates whether the pull request is a draft. See \"[Draft Pull Requests](https://docs.github.com/articles/about-pull-requests#draft-pull-requests)\" in the GitHub Help documentation to learn more.",
9165
type: "boolean",
9266
optional: true,
9367
},
9468
title: {
9569
label: "Title",
96-
description: "The title of the new pull request.",
70+
description: "The title of the pull request.",
9771
type: "string",
9872
optional: true,
9973
},
@@ -106,21 +80,15 @@ export default {
10680
}),
10781
],
10882
label: "Issue",
109-
description: toSingleLineString(`
110-
An issue in the repository to convert to a pull request.
111-
The issue title, body, and comments will become the title, body, and comments on the new pull request.
112-
`),
83+
description: "An issue in the repository to convert to a pull request. The issue title, body, and comments will become the title, body, and comments on the new pull request.",
11384
min: 1,
11485
optional: true,
11586
},
11687
},
11788
async run({ $ }) {
11889

11990
if (!this.issue && !this.title) {
120-
throw new ConfigurationError(toSingleLineString(`
121-
Title is required if Issue is unspecified.
122-
You can either specify a new pull request with Title or convert an existing issue to a pull request with Issue.
123-
`));
91+
throw new ConfigurationError("Title is required if Issue is unspecified. You can either specify a new pull request with Title or convert an existing issue to a pull request with Issue.");
12492
}
12593

12694
if (this.issue && this.title) {

components/github/common/utils.mjs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
/**
2-
* A utility function that accepts a string as an argument and reformats it in
3-
* order to remove newline characters and consecutive spaces. Useful when
4-
* dealing with very long templated strings that are split into multiple lines.
5-
*
6-
* @example
7-
* // returns "This is a much cleaner string"
8-
* toSingleLineString(`
9-
* This is a much
10-
* cleaner string
11-
* `);
12-
*
13-
* @param {string} multiLineString the input string to reformat
14-
* @returns a formatted string based on the content of the input argument,
15-
* without newlines and multiple spaces
16-
*/
17-
export function toSingleLineString(multiLineString) {
18-
return multiLineString
19-
.trim()
20-
.replace(/\n/g, " ")
21-
.replace(/\s{2,}/g, " ");
22-
}
23-
241
async function getUserRepoPermissions(github, repoFullname) {
252
const { login: username } = await github.getAuthenticatedUser();
263
const { user: { permissions } } = await github.getUserRepoPermissions({

0 commit comments

Comments
 (0)