Skip to content

Commit fee210a

Browse files
authored
feat: add ability to configure how many commits we retrieve when iterating through repo history (#2679)
* feat: add ability to configure how many commits we retrieve when iterating throgh history * added commit-batch-size to config.json
1 parent 02586f5 commit fee210a

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

docs/manifest-releaser.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ defaults (those are documented in comments)
268268
// value, but it will increase the number of API calls used.
269269
"commit-search-depth": 500,
270270

271+
// Number of commits to fetch per API request when searching commit history.
272+
// This controls the batch size for GraphQL pagination. Lower values result in
273+
// more API calls but may help avoid timeouts. Higher values reduce API calls
274+
// but each request takes longer. Defaults to 10.
275+
"commit-batch-size": 10,
276+
271277
// when creating multiple pull requests or releases, issue GitHub API requests
272278
// sequentially rather than concurrently, waiting for the previous request to
273279
// complete before issuing the next one.

schemas/config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@
431431
"description": "When considering commit history, only look this many commits deep.",
432432
"type": "number"
433433
},
434+
"commit-batch-size": {
435+
"description": "Number of commits to fetch per API request when searching commit history. Lower values result in more API calls but may help avoid timeouts. Defaults to 10.",
436+
"type": "number"
437+
},
434438
"sequential-calls": {
435439
"description": "Whether to open pull requests/releases sequentially rather than concurrently. If you have many components, you may want to set this to avoid secondary rate limits.",
436440
"type": "boolean"
@@ -462,6 +466,7 @@
462466
"group-pull-request-title-pattern": true,
463467
"release-search-depth": true,
464468
"commit-search-depth": true,
469+
"commit-batch-size": true,
465470
"sequential-calls": true,
466471
"release-type": true,
467472
"bump-minor-pre-major": true,

src/github.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ interface ReleaseHistory {
160160
interface CommitIteratorOptions {
161161
maxResults?: number;
162162
backfillFiles?: boolean;
163+
batchSize?: number;
163164
}
164165

165166
interface ReleaseIteratorOptions {
@@ -449,7 +450,7 @@ export class GitHub {
449450
cursor,
450451
owner: this.repository.owner,
451452
repo: this.repository.repo,
452-
num: 10,
453+
num: options.batchSize ?? 10,
453454
targetBranch,
454455
maxFilesChanged: 100, // max is 100
455456
};

src/manifest.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export interface ManifestOptions {
215215
groupPullRequestTitlePattern?: string;
216216
releaseSearchDepth?: number;
217217
commitSearchDepth?: number;
218+
commitBatchSize?: number;
218219
logger?: Logger;
219220
dateFormat?: string;
220221
}
@@ -270,6 +271,7 @@ export interface ManifestConfig extends ReleaserConfigJson {
270271
'group-pull-request-title-pattern'?: string;
271272
'release-search-depth'?: number;
272273
'commit-search-depth'?: number;
274+
'commit-batch-size'?: number;
273275
'sequential-calls'?: boolean;
274276
'always-update'?: boolean;
275277
}
@@ -288,6 +290,7 @@ export const DEFAULT_SNAPSHOT_LABELS = ['autorelease: snapshot'];
288290
export const SNOOZE_LABEL = 'autorelease: snooze';
289291
const DEFAULT_RELEASE_SEARCH_DEPTH = 400;
290292
const DEFAULT_COMMIT_SEARCH_DEPTH = 500;
293+
const DEFAULT_COMMIT_BATCH_SIZE = 10;
291294

292295
export const MANIFEST_PULL_REQUEST_TITLE_PATTERN = 'chore: release ${branch}';
293296

@@ -328,6 +331,7 @@ export class Manifest {
328331
private groupPullRequestTitlePattern?: string;
329332
readonly releaseSearchDepth: number;
330333
readonly commitSearchDepth: number;
334+
readonly commitBatchSize: number;
331335
readonly logger: Logger;
332336
private pullRequestOverflowHandler: PullRequestOverflowHandler;
333337

@@ -397,6 +401,8 @@ export class Manifest {
397401
manifestOptions?.releaseSearchDepth || DEFAULT_RELEASE_SEARCH_DEPTH;
398402
this.commitSearchDepth =
399403
manifestOptions?.commitSearchDepth || DEFAULT_COMMIT_SEARCH_DEPTH;
404+
this.commitBatchSize =
405+
manifestOptions?.commitBatchSize || DEFAULT_COMMIT_BATCH_SIZE;
400406
this.logger = manifestOptions?.logger ?? defaultLogger;
401407
this.plugins = (manifestOptions?.plugins || []).map(pluginType =>
402408
buildPlugin({
@@ -626,6 +632,7 @@ export class Manifest {
626632
const commitGenerator = this.github.mergeCommitIterator(this.targetBranch, {
627633
maxResults: this.commitSearchDepth,
628634
backfillFiles: true,
635+
batchSize: this.commitBatchSize,
629636
});
630637
const releaseShas = new Set(Object.values(releaseShasByPath));
631638
this.logger.debug(releaseShas);
@@ -1468,6 +1475,7 @@ async function parseConfig(
14681475
extraLabels: configExtraLabel?.split(','),
14691476
releaseSearchDepth: config['release-search-depth'],
14701477
commitSearchDepth: config['commit-search-depth'],
1478+
commitBatchSize: config['commit-batch-size'],
14711479
sequentialCalls: config['sequential-calls'],
14721480
};
14731481
return {config: repositoryConfig, options: manifestOptions};

0 commit comments

Comments
 (0)