mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
⚡ Add GitHub PR reviews (#1346)
* Adds operations to get and create PR reviews * Improvements to #709 * ⚡ Fix commit field description Co-authored-by: Johannes Kettmann <jkettmann@gmx.net>
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
* @param {object} body
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
method,
|
||||
@@ -31,6 +31,10 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (Object.keys(option).length !== 0) {
|
||||
Object.assign(options, option);
|
||||
}
|
||||
|
||||
try {
|
||||
const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string;
|
||||
|
||||
@@ -95,3 +99,22 @@ export async function getFileSha(this: IHookFunctions | IExecuteFunctions, owner
|
||||
}
|
||||
return responseData.sha;
|
||||
}
|
||||
|
||||
export async function githubApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
|
||||
query.per_page = 100;
|
||||
query.page = 1;
|
||||
|
||||
do {
|
||||
responseData = await githubApiRequest.call(this, method, endpoint, body, query, { resolveWithFullResponse: true });
|
||||
query.page++;
|
||||
returnData.push.apply(returnData, responseData.body);
|
||||
} while (
|
||||
responseData.headers.link && responseData.headers.link.includes('next')
|
||||
);
|
||||
return returnData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user