mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(GitHub Node): Fix credential tests and File > List operation (#2999)
* Fixed credential test failing * Fixed File list operation not working
This commit is contained in:
parent
8d04474e30
commit
ec618e25bb
|
@ -1767,7 +1767,7 @@ export class Github implements INodeType {
|
||||||
credentialTest: {
|
credentialTest: {
|
||||||
async githubApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
|
async githubApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
|
||||||
const credentials = credential.data;
|
const credentials = credential.data;
|
||||||
const baseUrl = credentials!.server as string || 'https://api.github.com/user';
|
const baseUrl = credentials!.server as string || 'https://api.github.com';
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
@ -1775,7 +1775,7 @@ export class Github implements INodeType {
|
||||||
'User-Agent': 'n8n',
|
'User-Agent': 'n8n',
|
||||||
Authorization: `token ${credentials!.accessToken}`,
|
Authorization: `token ${credentials!.accessToken}`,
|
||||||
},
|
},
|
||||||
uri: baseUrl,
|
uri: baseUrl.endsWith('/') ? baseUrl + 'user' : baseUrl + '/user',
|
||||||
json: true,
|
json: true,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
};
|
};
|
||||||
|
@ -1952,7 +1952,7 @@ export class Github implements INodeType {
|
||||||
body.sha = await getFileSha.call(this, owner, repository, filePath, body.branch as string | undefined);
|
body.sha = await getFileSha.call(this, owner, repository, filePath, body.branch as string | undefined);
|
||||||
|
|
||||||
endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`;
|
endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`;
|
||||||
} else if (operation === 'get' || operation === 'list') {
|
} else if (operation === 'get') {
|
||||||
requestMethod = 'GET';
|
requestMethod = 'GET';
|
||||||
|
|
||||||
const filePath = this.getNodeParameter('filePath', i) as string;
|
const filePath = this.getNodeParameter('filePath', i) as string;
|
||||||
|
@ -1961,6 +1961,11 @@ export class Github implements INodeType {
|
||||||
if (additionalParameters.reference) {
|
if (additionalParameters.reference) {
|
||||||
qs.ref = additionalParameters.reference;
|
qs.ref = additionalParameters.reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`;
|
||||||
|
} else if (operation === 'list') {
|
||||||
|
requestMethod = 'GET';
|
||||||
|
const filePath = this.getNodeParameter('filePath', i) as string;
|
||||||
endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`;
|
endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`;
|
||||||
}
|
}
|
||||||
} else if (resource === 'issue') {
|
} else if (resource === 'issue') {
|
||||||
|
|
Loading…
Reference in a new issue