@@ -16,37 +16,41 @@ import { $ } from 'execa';
16
16
/**
17
17
* @param {Object } opts
18
18
* @param {string } opts.cwd
19
+ * @param {boolean } [opts.fetchAll=true] Whether to fetch all tags from all remotes before finding the latest tag.
19
20
* @returns {Promise<string> }
20
21
*/
21
22
export async function findLatestTaggedVersion ( opts ) {
22
- const { stdout } = await $ ( {
23
- cwd : opts . cwd ,
24
- // First fetch all tags from all remotes to ensure we have the latest tags. Uses -q flag to suppress output.
25
- // And then find the latest tag matching "v*".
26
- } ) `git fetch --tags --all -q && git describe --tags --abbrev=0 --match ${ 'v*' } ` ; // only include "version-tags"
23
+ const $$ = $ ( { cwd : opts . cwd } ) ;
24
+ const fetchAll = opts . fetchAll ?? true ;
25
+ if ( fetchAll ) {
26
+ // Fetch all tags from all remotes to ensure we have the latest tags.
27
+ await $$ `git fetch --tags --all` ;
28
+ }
29
+ const { stdout } = await $$ `git describe --tags --abbrev=0 --match ${ 'v*' } ` ; // only include "version-tags"
27
30
return stdout . trim ( ) ;
28
31
}
29
32
30
33
/**
31
34
* @typedef {Object } FetchCommitsOptions
32
- * @property {string } token
33
35
* @property {string } repo
34
36
* @property {string } lastRelease
35
37
* @property {string } release
38
+ * @property {string } token
36
39
* @property {string } [org="mui"]
37
40
*/
38
41
39
42
/**
40
43
* Fetches commits between two refs (lastRelease..release) including PR details.
41
- * Throws if the `token` option is not provided .
44
+ * Automatically handles GitHub OAuth authentication .
42
45
*
43
46
* @param {FetchCommitsOptions } param0
44
47
* @returns {Promise<FetchedCommitDetails[]> }
45
48
*/
46
49
export async function fetchCommitsBetweenRefs ( { org = 'mui' , ...options } ) {
47
50
if ( ! options . token ) {
48
- throw new Error ( 'Missing " token" option. The token needs `public_repo` permissions .' ) ;
51
+ throw new Error ( 'GitHub token is required .' ) ;
49
52
}
53
+
50
54
const opts = { ...options , org } ;
51
55
52
56
return await fetchCommitsRest ( opts ) ;
@@ -57,7 +61,7 @@ export async function fetchCommitsBetweenRefs({ org = 'mui', ...options }) {
57
61
* It is more reliable than the GraphQL API but requires multiple network calls (1 + n).
58
62
* One to list all commits between the two refs and then one for each commit to get the PR details.
59
63
*
60
- * @param {FetchCommitsOptions & { org: string } } param0
64
+ * @param {FetchCommitsOptions & { org: string, token: string } } param0
61
65
*
62
66
* @returns {Promise<FetchedCommitDetails[]> }
63
67
*/
0 commit comments