1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-19 17:07:18 +03:00

feat(Github Node): Add option to get pull requests (#9094)

This commit is contained in:
Chengyou Liu 2024-04-15 18:01:14 +08:00 committed by GitHub
parent 1dbc8d4594
commit 4d9000bf27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -253,6 +253,12 @@ export class Github implements INodeType {
'Get the community profile of a repository with metrics, health score, description, license, etc',
action: 'Get the profile of a repository',
},
{
name: 'Get Pull Requests',
value: 'getPullRequests',
description: 'Returns pull requests of a repository',
action: 'Get pull requests of a repository',
},
{
name: 'List Popular Paths',
value: 'listPopularPaths',
@ -1322,7 +1328,7 @@ export class Github implements INodeType {
type: 'string',
default: '',
description:
'Return only issues with the given labels. Multiple lables can be separated by comma.',
'Return only issues with the given labels. Multiple labels can be separated by comma.',
},
{
displayName: 'Updated Since',
@ -1401,6 +1407,130 @@ export class Github implements INodeType {
],
},
// ----------------------------------
// repository:getPullRequests
// ----------------------------------
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: ['repository'],
operation: ['getPullRequests'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: ['repository'],
operation: ['getPullRequests'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Filters',
name: 'getRepositoryPullRequestsFilters',
type: 'collection',
typeOptions: {
multipleValueButtonText: 'Add Filter',
},
displayOptions: {
show: {
operation: ['getPullRequests'],
resource: ['repository'],
},
},
default: {},
options: [
{
displayName: 'State',
name: 'state',
type: 'options',
options: [
{
name: 'All',
value: 'all',
description: 'Returns pull requests with any state',
},
{
name: 'Closed',
value: 'closed',
description: 'Return pull requests with "closed" state',
},
{
name: 'Open',
value: 'open',
description: 'Return pull requests with "open" state',
},
],
default: 'open',
description: 'The state to set',
},
{
displayName: 'Sort',
name: 'sort',
type: 'options',
options: [
{
name: 'Created',
value: 'created',
description: 'Sort by created date',
},
{
name: 'Updated',
value: 'updated',
description: 'Sort by updated date',
},
{
name: 'Popularity',
value: 'popularity',
description: 'Sort by number of comments',
},
{
name: 'Long-Running',
value: 'long-running',
description:
'Sort by date created and will limit the results to pull requests that have been open for more than a month and have had activity within the past month',
},
],
default: 'created',
description: 'The order the pull requests should be returned in',
},
{
displayName: 'Direction',
name: 'direction',
type: 'options',
options: [
{
name: 'Ascending',
value: 'asc',
description: 'Sort in ascending order',
},
{
name: 'Descending',
value: 'desc',
description: 'Sort in descending order',
},
],
default: 'desc',
description: 'The sort order',
},
],
},
// ----------------------------------
// rerview
// ----------------------------------
@ -1734,6 +1864,7 @@ export class Github implements INodeType {
const overwriteDataOperationsArray = [
'file:list',
'repository:getIssues',
'repository:getPullRequests',
'repository:listPopularPaths',
'repository:listReferrers',
'user:getRepositories',
@ -2072,6 +2203,22 @@ export class Github implements INodeType {
returnAll = this.getNodeParameter('returnAll', 0);
if (!returnAll) {
qs.per_page = this.getNodeParameter('limit', 0);
}
} else if (operation === 'getPullRequests') {
// ----------------------------------
// getPullRequests
// ----------------------------------
requestMethod = 'GET';
qs = this.getNodeParameter('getRepositoryPullRequestsFilters', i) as IDataObject;
endpoint = `/repos/${owner}/${repository}/pulls`;
returnAll = this.getNodeParameter('returnAll', 0);
if (!returnAll) {
qs.per_page = this.getNodeParameter('limit', 0);
}