mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
⚡ Fix pagination for retrieving user repos in GitHub node (#1554)
* ⚡ Fix pagination on user:getRepositories * ⚡ Fix pagination on repository:getIssues * ✏️ Fix typos and periods in descriptions * ⚡ Minor improvement Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
896ef33f40
commit
e37b89df4f
|
@ -130,27 +130,27 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Create',
|
name: 'Create',
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new issue',
|
description: 'Create a new issue.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Create Comment',
|
name: 'Create Comment',
|
||||||
value: 'createComment',
|
value: 'createComment',
|
||||||
description: 'Create a new comment on an issue',
|
description: 'Create a new comment on an issue.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Edit',
|
name: 'Edit',
|
||||||
value: 'edit',
|
value: 'edit',
|
||||||
description: 'Edit an issue',
|
description: 'Edit an issue.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
value: 'get',
|
value: 'get',
|
||||||
description: 'Get the data of a single issues',
|
description: 'Get the data of a single issue.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Lock',
|
name: 'Lock',
|
||||||
value: 'lock',
|
value: 'lock',
|
||||||
description: 'Lock an issue',
|
description: 'Lock an issue.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
|
@ -172,22 +172,22 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Create',
|
name: 'Create',
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new file in repository',
|
description: 'Create a new file in repository.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Delete',
|
name: 'Delete',
|
||||||
value: 'delete',
|
value: 'delete',
|
||||||
description: 'Delete a file in repository',
|
description: 'Delete a file in repository.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Edit',
|
name: 'Edit',
|
||||||
value: 'edit',
|
value: 'edit',
|
||||||
description: 'Edit a file in repository',
|
description: 'Edit a file in repository.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
value: 'get',
|
value: 'get',
|
||||||
description: 'Get the data of a single issue',
|
description: 'Get the data of a single issue.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
|
@ -209,22 +209,22 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
value: 'get',
|
value: 'get',
|
||||||
description: 'Get the data of a single repository',
|
description: 'Get the data of a single repository.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get License',
|
name: 'Get License',
|
||||||
value: 'getLicense',
|
value: 'getLicense',
|
||||||
description: 'Returns the contents of the repository\'s license file, if one is detected',
|
description: 'Returns the contents of the repository\'s license file, if one is detected.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get Issues',
|
name: 'Get Issues',
|
||||||
value: 'getIssues',
|
value: 'getIssues',
|
||||||
description: 'Returns issues of a repository',
|
description: 'Returns issues of a repository.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get Profile',
|
name: 'Get Profile',
|
||||||
value: 'getProfile',
|
value: 'getProfile',
|
||||||
description: 'Get the community profile of a repository with metrics, health score, description, license, ...',
|
description: 'Get the community profile of a repository with metrics, health score, description, license, etc.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'List Popular Paths',
|
name: 'List Popular Paths',
|
||||||
|
@ -234,7 +234,7 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'List Referrers',
|
name: 'List Referrers',
|
||||||
value: 'listReferrers',
|
value: 'listReferrers',
|
||||||
description: 'Get the top 10 referrering domains over the last 14 days',
|
description: 'Get the top 10 referrering domains over the last 14 days.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'getIssues',
|
default: 'getIssues',
|
||||||
|
@ -256,7 +256,7 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Get Repositories',
|
name: 'Get Repositories',
|
||||||
value: 'getRepositories',
|
value: 'getRepositories',
|
||||||
description: 'Returns the repositories of a user',
|
description: 'Returns the repositories of a user.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Invite',
|
name: 'Invite',
|
||||||
|
@ -283,7 +283,7 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Create',
|
name: 'Create',
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Creates a new release',
|
description: 'Creates a new release.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
|
@ -305,22 +305,22 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Create',
|
name: 'Create',
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Creates a new review',
|
description: 'Creates a new review.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
value: 'get',
|
value: 'get',
|
||||||
description: 'Get a review for a pull request',
|
description: 'Get a review for a pull request.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get All',
|
name: 'Get All',
|
||||||
value: 'getAll',
|
value: 'getAll',
|
||||||
description: 'Get all reviews for a pull request',
|
description: 'Get all reviews for a pull request.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Update',
|
name: 'Update',
|
||||||
value: 'update',
|
value: 'update',
|
||||||
description: 'Update a review',
|
description: 'Update a review.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
|
@ -815,12 +815,12 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Closed',
|
name: 'Closed',
|
||||||
value: 'closed',
|
value: 'closed',
|
||||||
description: 'Set the state to "closed"',
|
description: 'Set the state to "closed".',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Open',
|
name: 'Open',
|
||||||
value: 'open',
|
value: 'open',
|
||||||
description: 'Set the state to "open"',
|
description: 'Set the state to "open".',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'open',
|
default: 'open',
|
||||||
|
@ -860,7 +860,7 @@ export class Github implements INodeType {
|
||||||
name: 'assignee',
|
name: 'assignee',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'User to assign issue too.',
|
description: 'User to assign issue to.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -1046,6 +1046,47 @@ export class Github implements INodeType {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// repository:getIssues
|
// repository:getIssues
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'repository',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getIssues',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: false,
|
||||||
|
description: 'If all results should be returned or only up to a given limit.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'repository',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getIssues',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 100,
|
||||||
|
},
|
||||||
|
default: 50,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Filters',
|
displayName: 'Filters',
|
||||||
name: 'getRepositoryIssuesFilters',
|
name: 'getRepositoryIssuesFilters',
|
||||||
|
@ -1108,17 +1149,17 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'All',
|
name: 'All',
|
||||||
value: 'all',
|
value: 'all',
|
||||||
description: 'Returns issues with any state',
|
description: 'Returns issues with any state.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Closed',
|
name: 'Closed',
|
||||||
value: 'closed',
|
value: 'closed',
|
||||||
description: 'Return issues with "closed" state',
|
description: 'Return issues with "closed" state.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Open',
|
name: 'Open',
|
||||||
value: 'open',
|
value: 'open',
|
||||||
description: 'Return issues with "open" state',
|
description: 'Return issues with "open" state.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'open',
|
default: 'open',
|
||||||
|
@ -1132,17 +1173,17 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Created',
|
name: 'Created',
|
||||||
value: 'created',
|
value: 'created',
|
||||||
description: 'Sort by created date',
|
description: 'Sort by created date.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Updated',
|
name: 'Updated',
|
||||||
value: 'updated',
|
value: 'updated',
|
||||||
description: 'Sort by updated date',
|
description: 'Sort by updated date.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Comments',
|
name: 'Comments',
|
||||||
value: 'comments',
|
value: 'comments',
|
||||||
description: 'Sort by comments',
|
description: 'Sort by comments.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'created',
|
default: 'created',
|
||||||
|
@ -1156,12 +1197,12 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Ascending',
|
name: 'Ascending',
|
||||||
value: 'asc',
|
value: 'asc',
|
||||||
description: 'Sort in ascending order',
|
description: 'Sort in ascending order.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Descending',
|
name: 'Descending',
|
||||||
value: 'desc',
|
value: 'desc',
|
||||||
description: 'Sort in descending order',
|
description: 'Sort in descending order.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'desc',
|
default: 'desc',
|
||||||
|
@ -1214,7 +1255,7 @@ export class Github implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'ID of the review',
|
description: 'ID of the review.',
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -1318,17 +1359,17 @@ export class Github implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'Approve',
|
name: 'Approve',
|
||||||
value: 'approve',
|
value: 'approve',
|
||||||
description: 'Approve the pull request',
|
description: 'Approve the pull request.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Request Change',
|
name: 'Request Change',
|
||||||
value: 'requestChanges',
|
value: 'requestChanges',
|
||||||
description: 'Request code changes',
|
description: 'Request code changes.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Comment',
|
name: 'Comment',
|
||||||
value: 'comment',
|
value: 'comment',
|
||||||
description: 'Add a comment without approval or change requests',
|
description: 'Add a comment without approval or change requests.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Pending',
|
name: 'Pending',
|
||||||
|
@ -1386,7 +1427,7 @@ export class Github implements INodeType {
|
||||||
name: 'commitId',
|
name: 'commitId',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The SHA of the commit that needs a review, if different from the latest',
|
description: 'The SHA of the commit that needs a review, if different from the latest.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -1414,6 +1455,50 @@ export class Github implements INodeType {
|
||||||
description: 'The body of the review',
|
description: 'The body of the review',
|
||||||
},
|
},
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
// user:getRepositories
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getRepositories',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: false,
|
||||||
|
description: 'If all results should be returned or only up to a given limit.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getRepositories',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 100,
|
||||||
|
},
|
||||||
|
default: 50,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
|
// ----------------------------------
|
||||||
// user:invite
|
// user:invite
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
|
@ -1736,6 +1821,12 @@ export class Github implements INodeType {
|
||||||
qs = this.getNodeParameter('getRepositoryIssuesFilters', i) as IDataObject;
|
qs = this.getNodeParameter('getRepositoryIssuesFilters', i) as IDataObject;
|
||||||
|
|
||||||
endpoint = `/repos/${owner}/${repository}/issues`;
|
endpoint = `/repos/${owner}/${repository}/issues`;
|
||||||
|
|
||||||
|
returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
|
|
||||||
|
if (returnAll === false) {
|
||||||
|
qs.per_page = this.getNodeParameter('limit', 0) as number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (resource === 'review') {
|
} else if (resource === 'review') {
|
||||||
if (operation === 'get') {
|
if (operation === 'get') {
|
||||||
|
@ -1791,7 +1882,7 @@ export class Github implements INodeType {
|
||||||
const reviewId = this.getNodeParameter('reviewId', i) as string;
|
const reviewId = this.getNodeParameter('reviewId', i) as string;
|
||||||
|
|
||||||
body.body = this.getNodeParameter('body', i) as string;
|
body.body = this.getNodeParameter('body', i) as string;
|
||||||
|
|
||||||
endpoint = `/repos/${owner}/${repository}/pulls/${pullRequestNumber}/reviews/${reviewId}`;
|
endpoint = `/repos/${owner}/${repository}/pulls/${pullRequestNumber}/reviews/${reviewId}`;
|
||||||
}
|
}
|
||||||
} else if (resource === 'user') {
|
} else if (resource === 'user') {
|
||||||
|
@ -1804,13 +1895,19 @@ export class Github implements INodeType {
|
||||||
|
|
||||||
endpoint = `/users/${owner}/repos`;
|
endpoint = `/users/${owner}/repos`;
|
||||||
|
|
||||||
} else if (operation === 'invite') {
|
returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
|
|
||||||
|
if (returnAll === false) {
|
||||||
|
qs.per_page = this.getNodeParameter('limit', 0) as number;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (operation === 'invite') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// invite
|
// invite
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'POST';
|
requestMethod = 'POST';
|
||||||
const org = this.getNodeParameter('organization', i) as string;
|
const org = this.getNodeParameter('organization', i) as string;
|
||||||
endpoint = `/orgs/${org}/invitations`;
|
endpoint = `/orgs/${org}/invitations`;
|
||||||
body.email = this.getNodeParameter('email', i) as string;
|
body.email = this.getNodeParameter('email', i) as string;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue