From df2c4e99af57d5d26c6888855f871a763135e7f8 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Sat, 12 Feb 2022 18:36:57 +0100 Subject: [PATCH] :zap: Make it possible to get file from specific branch/tag/commit via GitHub --- .../nodes-base/nodes/Github/Github.node.ts | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Github/Github.node.ts b/packages/nodes-base/nodes/Github/Github.node.ts index d8b491910b..d1110cbfd4 100644 --- a/packages/nodes-base/nodes/Github/Github.node.ts +++ b/packages/nodes-base/nodes/Github/Github.node.ts @@ -661,7 +661,34 @@ export class Github implements INodeType { description: 'Name of the binary property in which to save the binary data of the received file.', }, - + { + displayName: 'Additional Parameters', + name: 'additionalParameters', + placeholder: 'Add Parameter', + description: 'Additional fields to add.', + type: 'collection', + default: {}, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'file', + ], + }, + }, + options: [ + { + displayName: 'Reference', + name: 'reference', + type: 'string', + default: '', + placeholder: 'master', + description: 'The name of the commit/branch/tag. Default: the repository’s default branch (usually master).', + } + ], + }, // ---------------------------------- // issue @@ -1929,7 +1956,11 @@ export class Github implements INodeType { requestMethod = 'GET'; const filePath = this.getNodeParameter('filePath', i) as string; + const additionalParameters = this.getNodeParameter('additionalParameters', i) as IDataObject; + if (additionalParameters.reference) { + qs.ref = additionalParameters.reference; + } endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`; } } else if (resource === 'issue') {