mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
@@ -26,6 +26,10 @@ type RepositorySearchResponse = {
|
||||
total_count: number;
|
||||
};
|
||||
|
||||
type RefItem = {
|
||||
ref: string;
|
||||
};
|
||||
|
||||
export async function getUsers(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
@@ -115,3 +119,54 @@ export async function getWorkflows(
|
||||
const nextPaginationToken = page * per_page < responseData.total_count ? page + 1 : undefined;
|
||||
return { results, paginationToken: nextPaginationToken };
|
||||
}
|
||||
|
||||
export async function getRefs(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
paginationToken?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const owner = this.getCurrentNodeParameter('owner', { extractValue: true });
|
||||
const repository = this.getCurrentNodeParameter('repository', { extractValue: true });
|
||||
const page = paginationToken ? +paginationToken : 1;
|
||||
const per_page = 100;
|
||||
|
||||
const responseData: RefItem[] = await githubApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/repos/${owner}/${repository}/git/refs`,
|
||||
{},
|
||||
{ page, per_page },
|
||||
);
|
||||
|
||||
const refs: INodeListSearchItems[] = [];
|
||||
|
||||
for (const ref of responseData) {
|
||||
const refPath = ref.ref.split('/');
|
||||
const refType = refPath[1];
|
||||
const refName = refPath.slice(2).join('/');
|
||||
|
||||
let description = '';
|
||||
if (refType === 'heads') {
|
||||
description = `Branch: ${refName}`;
|
||||
} else if (refType === 'tags') {
|
||||
description = `Tag: ${refName}`;
|
||||
} else {
|
||||
description = `${refType}: ${refName}`;
|
||||
}
|
||||
|
||||
refs.push({
|
||||
name: refName,
|
||||
value: refName,
|
||||
description,
|
||||
});
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
const filteredRefs = refs.filter((ref) =>
|
||||
ref.name.toLowerCase().includes(filter.toLowerCase()),
|
||||
);
|
||||
return { results: filteredRefs };
|
||||
}
|
||||
const nextPaginationToken = responseData.length === per_page ? page + 1 : undefined;
|
||||
return { results: refs, paginationToken: nextPaginationToken };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user