File tree 4 files changed +19
-4
lines changed
4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export type CommandLineArguments = {
7
7
reset : boolean ;
8
8
backport : boolean ;
9
9
defaultBranch : string ;
10
+ fetchRemote : boolean ;
10
11
} ;
11
12
12
13
/**
@@ -51,6 +52,12 @@ export async function readCommandLineArguments(
51
52
default : 'main' ,
52
53
type : 'string' ,
53
54
} )
55
+ . option ( 'fetch-remote' , {
56
+ alias : 'f' ,
57
+ describe : 'Syncronizes local git references with remote' ,
58
+ default : true ,
59
+ type : 'boolean' ,
60
+ } )
54
61
. help ( )
55
62
. strict ( )
56
63
. parse ( ) ;
Original file line number Diff line number Diff line change @@ -45,7 +45,10 @@ export async function determineInitialParameters({
45
45
const args = await readCommandLineArguments ( argv ) ;
46
46
47
47
const projectDirectoryPath = path . resolve ( cwd , args . projectDirectory ) ;
48
- const project = await readProject ( projectDirectoryPath , { stderr } ) ;
48
+ const project = await readProject ( projectDirectoryPath , {
49
+ stderr,
50
+ fetchRemote : args . fetchRemote ,
51
+ } ) ;
49
52
const tempDirectoryPath =
50
53
args . tempDirectory === undefined
51
54
? path . join (
Original file line number Diff line number Diff line change @@ -74,17 +74,18 @@ function examineReleaseVersion(packageVersion: SemVer): ReleaseVersion {
74
74
* @param projectDirectoryPath - The path to the project.
75
75
* @param args - Additional arguments.
76
76
* @param args.stderr - A stream that can be used to write to standard error.
77
+ * @param args.fetchRemote - Whether to synchronize local tags with remote.
77
78
* @returns An object that represents information about the project.
78
79
* @throws if the project does not contain a root `package.json` (polyrepo and
79
80
* monorepo) or if any of the workspaces specified in the root `package.json` do
80
81
* not have `package.json`s (monorepo only).
81
82
*/
82
83
export async function readProject (
83
84
projectDirectoryPath : string ,
84
- { stderr } : { stderr : WriteStreamLike } ,
85
+ { fetchRemote , stderr } : { fetchRemote ?: boolean ; stderr : WriteStreamLike } ,
85
86
) : Promise < Project > {
86
87
const repositoryUrl = await getRepositoryHttpsUrl ( projectDirectoryPath ) ;
87
- const tagNames = await getTagNames ( projectDirectoryPath ) ;
88
+ const tagNames = await getTagNames ( projectDirectoryPath , fetchRemote ) ;
88
89
const rootPackage = await readMonorepoRootPackage ( {
89
90
packageDirectoryPath : projectDirectoryPath ,
90
91
projectDirectoryPath,
Original file line number Diff line number Diff line change @@ -256,13 +256,17 @@ export async function branchExists(
256
256
* advised to only run this once.
257
257
*
258
258
* @param repositoryDirectoryPath - The path to the repository directory.
259
+ * @param fetchRemote - Whether to synchronize local tags with remote.
259
260
* @returns The names of the tags.
260
261
* @throws If no tags are found and the local git history is incomplete.
261
262
*/
262
263
export async function getTagNames (
263
264
repositoryDirectoryPath : string ,
265
+ fetchRemote ?: boolean ,
264
266
) : Promise < string [ ] > {
265
- await runGitCommandWithin ( repositoryDirectoryPath , 'fetch' , [ '--tags' ] ) ;
267
+ if ( typeof fetchRemote !== 'boolean' || fetchRemote ) {
268
+ await runGitCommandWithin ( repositoryDirectoryPath , 'fetch' , [ '--tags' ] ) ;
269
+ }
266
270
267
271
const tagNames = await getLinesFromGitCommandWithin (
268
272
repositoryDirectoryPath ,
You can’t perform that action at this time.
0 commit comments