feat(GitHub Node): GitHub Node Overhaul implementation #12271 (#13238)

This commit is contained in:
Stanimira Rikova
2025-04-04 21:03:45 +03:00
committed by GitHub
parent 2f0b5e488e
commit 33e265aaa8
14 changed files with 1797 additions and 189 deletions

View File

@@ -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 };
}