@@ -11,17 +11,25 @@ import { PackageRename } from './shared-types';
1111 * Get the most recent tag for a project.
1212 *
1313 * @param options - Options.
14+ * @param options.fetchRemote - Whether to synchronize local tags with remote.
1415 * @param options.tagPrefixes - A list of tag prefixes to look for, where the first is the intended
1516 * prefix and each subsequent prefix is a fallback in case the previous tag prefixes are not found.
17+ * @param options.run - Optional alternative shell command interpreter
1618 * @returns The most recent tag.
1719 */
1820async function getMostRecentTag ( {
21+ fetchRemote,
1922 tagPrefixes,
23+ run = runCommand ,
2024} : {
25+ fetchRemote ?: boolean ;
2126 tagPrefixes : [ string , ...string [ ] ] ;
27+ run ?: ( cmd : string , args : string [ ] ) => Promise < ( string | null ) [ ] > ;
2228} ) {
2329 // Ensure we have all tags on remote
24- await runCommand ( 'git' , [ 'fetch' , '--tags' ] ) ;
30+ if ( typeof fetchRemote !== 'boolean' || fetchRemote ) {
31+ await run ( 'git' , [ 'fetch' , '--tags' ] ) ;
32+ }
2533
2634 let mostRecentTagCommitHash : string | null = null ;
2735 for ( const tagPrefix of tagPrefixes ) {
@@ -219,6 +227,8 @@ export type UpdateChangelogOptions = {
219227 * The package rename properties, used in case of package is renamed
220228 */
221229 packageRename ?: PackageRename ;
230+ fetchRemote ?: boolean ;
231+ run ?: ( cmd : string , args : string [ ] ) => Promise < ( string | null ) [ ] > ;
222232} ;
223233
224234/**
@@ -243,6 +253,8 @@ export type UpdateChangelogOptions = {
243253 * @param options.formatter - A custom Markdown formatter to use.
244254 * @param options.packageRename - The package rename properties.
245255 * An optional, which is required only in case of package renamed.
256+ * @param options.fetchRemote - Whether to synchronize local tags with remote.
257+ * @param options.run - Optional alternative shell command interpreter
246258 * @returns The updated changelog text.
247259 */
248260export async function updateChangelog ( {
@@ -254,6 +266,8 @@ export async function updateChangelog({
254266 tagPrefixes = [ 'v' ] ,
255267 formatter = undefined ,
256268 packageRename,
269+ fetchRemote = true ,
270+ run,
257271} : UpdateChangelogOptions ) : Promise < string | undefined > {
258272 const changelog = parseChangelog ( {
259273 changelogContent,
@@ -264,6 +278,8 @@ export async function updateChangelog({
264278 } ) ;
265279
266280 const mostRecentTag = await getMostRecentTag ( {
281+ fetchRemote,
282+ run,
267283 tagPrefixes,
268284 } ) ;
269285
0 commit comments