- introduce experiment to fetch tags via graphQL (will offer the ability to fetch less tags, but ordered based on commit date)
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ export default [{
|
||||
ignores: ["**/dist/", "**/lib/", "**/node_modules/"]
|
||||
}, ...compat.extends("plugin:github/recommended"), {
|
||||
|
||||
files: ["src/**.ts", "__tests__/**.ts"],
|
||||
files: ["**/*.ts", "__tests__/**.ts"],
|
||||
|
||||
plugins: {
|
||||
jest,
|
||||
|
||||
+4
-4
@@ -48,6 +48,8 @@
|
||||
"semver": "^7.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.19.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^22.12.0",
|
||||
"@types/semver": "^7.5.8",
|
||||
@@ -55,19 +57,17 @@
|
||||
"@typescript-eslint/parser": "^8.22.0",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"eslint": "^9.19.0",
|
||||
"eslint-import-resolver-typescript": "^3.7.0",
|
||||
"eslint-plugin-github": "^5.1.7",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jest": "^28.11.0",
|
||||
"eslint-plugin-prettier": "^5.2.3",
|
||||
"eslint-import-resolver-typescript": "^3.7.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "3.4.2",
|
||||
"ts-jest": "^29.2.5",
|
||||
"typescript": "^5.7.3",
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.19.0"
|
||||
"typescript": "^5.7.3"
|
||||
},
|
||||
"overrides": {
|
||||
"glob": "11.0.1"
|
||||
|
||||
@@ -7,6 +7,7 @@ import {DiffInfo} from '../pr-collector/commits.js'
|
||||
import {CommentInfo, PullData, PullRequestInfo, PullReviewsData, PullsListData} from '../pr-collector/pullRequests.js'
|
||||
import {Unpacked} from '../pr-collector/utils.js'
|
||||
import moment from 'moment'
|
||||
import {GraphQlQueryResponse} from '@octokit/graphql/types'
|
||||
|
||||
export class GithubRepository extends BaseRepository {
|
||||
async getDiffRemote(owner: string, repo: string, base: string, head: string): Promise<DiffInfo> {
|
||||
@@ -194,6 +195,7 @@ export class GithubRepository extends BaseRepository {
|
||||
auth: `token ${this.token}`,
|
||||
baseUrl: this.url
|
||||
})
|
||||
|
||||
if (this.proxy) {
|
||||
const agent = new HttpsProxyAgent(this.proxy)
|
||||
this.octokit.hook.before('request', options => {
|
||||
@@ -206,7 +208,44 @@ export class GithubRepository extends BaseRepository {
|
||||
}
|
||||
|
||||
async getTags(owner: string, repo: string, maxTagsToFetch: number): Promise<TagInfo[]> {
|
||||
const pageSize = maxTagsToFetch > 100 ? 100 : maxTagsToFetch // 100 max page size in graphql
|
||||
const tagsInfo: TagInfo[] = []
|
||||
|
||||
const result: GraphQlQueryResponse<unknown> = await this.octokit.graphql(`
|
||||
{
|
||||
repository(owner: "${owner}", name: "${repo}") {
|
||||
refs(refPrefix: "refs/tags/", first: ${pageSize}, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) {
|
||||
edges {
|
||||
node {
|
||||
name
|
||||
target {
|
||||
oid
|
||||
... on Tag {
|
||||
message
|
||||
commitUrl
|
||||
tagger {
|
||||
name
|
||||
email
|
||||
date
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
// @ts-expect-error graphql response
|
||||
// eslint-disable-next-line github/array-foreach, @typescript-eslint/no-explicit-any
|
||||
result.repository.refs.edges.forEach((edge: any) => {
|
||||
tagsInfo.push({
|
||||
name: edge.node.name,
|
||||
commit: edge.node.target.oid
|
||||
})
|
||||
})
|
||||
|
||||
const options = this.octokit.repos.listTags.endpoint.merge({
|
||||
owner,
|
||||
repo,
|
||||
|
||||
Reference in New Issue
Block a user