Skip to content

Commit 4aa4d86

Browse files
committed
Transpile
1 parent 7b0a136 commit 4aa4d86

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

.github/actions/checkout/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
9797
# Default: false
9898
single-branch: ''
9999

100+
# Additional refs to fetch. Each ref should be separated with new lines. For
101+
# example, to fetch all tags: `refs/tags/*:refs/tags/*`
102+
# Default:
103+
additional-fetch-refs: ''
104+
100105
# Personal access token (PAT) used to fetch the repository. The PAT is configured
101106
# with the local git config, which enables your scripts to run authenticated git
102107
# commands. The post-job step removes the PAT.

.github/actions/checkout/dist/index.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,20 +1525,20 @@ function getSource(settings) {
15251525
}
15261526
if (settings.fetchDepth <= 0) {
15271527
let refSpec = settings.singleBranch
1528-
? refHelper.getRefSpec(settings.ref, settings.commit)
1528+
? refHelper.getRefSpec(settings.ref, settings.commit, settings.additionalFetchRefs)
15291529
: refHelper.getRefSpecForAllHistory(settings.ref, settings.commit);
15301530
yield git.fetch(refSpec, fetchOptions);
15311531
// When all history is fetched, the ref we're interested in may have moved to a different
15321532
// commit (push or force push). If so, fetch again with a targeted refspec.
15331533
if (!(yield refHelper.testRef(git, settings.ref, settings.commit))) {
1534-
refSpec = refHelper.getRefSpec(settings.ref, settings.commit);
1534+
refSpec = refHelper.getRefSpec(settings.ref, settings.commit, settings.additionalFetchRefs);
15351535
yield git.fetch(refSpec, fetchOptions);
15361536
}
15371537
}
15381538
else {
15391539
fetchOptions.fetchDepth = settings.fetchDepth;
15401540
fetchOptions.fetchTags = settings.fetchTags;
1541-
const refSpec = refHelper.getRefSpec(settings.ref, settings.commit);
1541+
const refSpec = refHelper.getRefSpec(settings.ref, settings.commit, settings.additionalFetchRefs);
15421542
yield git.fetch(refSpec, fetchOptions);
15431543
}
15441544
core.endGroup();
@@ -2013,6 +2013,10 @@ function getInputs() {
20132013
result.singleBranch =
20142014
(core.getInput('single-branch') || 'false').toUpperCase() === 'TRUE';
20152015
core.debug(`single branch = ${result.singleBranch}`);
2016+
// Additional fetch refs
2017+
result.additionalFetchRefs =
2018+
core.getMultilineInput('additional-fetch-refs') || [];
2019+
core.debug(`additional fetch refs = ${JSON.stringify(result.additionalFetchRefs)}`);
20162020
// Clean
20172021
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE';
20182022
core.debug(`clean = ${result.clean}`);
@@ -2223,6 +2227,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
22232227
exports.tagsRefSpec = void 0;
22242228
exports.getCheckoutInfo = getCheckoutInfo;
22252229
exports.getRefSpecForAllHistory = getRefSpecForAllHistory;
2230+
exports.getSingleRefSpec = getSingleRefSpec;
22262231
exports.getRefSpec = getRefSpec;
22272232
exports.testRef = testRef;
22282233
exports.checkCommitInfo = checkCommitInfo;
@@ -2287,7 +2292,7 @@ function getRefSpecForAllHistory(ref, commit) {
22872292
}
22882293
return result;
22892294
}
2290-
function getRefSpec(ref, commit) {
2295+
function getSingleRefSpec(ref, commit) {
22912296
if (!ref && !commit) {
22922297
throw new Error('Args ref and commit cannot both be empty');
22932298
}
@@ -2335,6 +2340,16 @@ function getRefSpec(ref, commit) {
23352340
return [`+${ref}:${ref}`];
23362341
}
23372342
}
2343+
function getRefSpec(ref, commit, additionalFetchRefs) {
2344+
const result = [];
2345+
const singleRefSpec = getSingleRefSpec(ref, commit);
2346+
result.push(...singleRefSpec);
2347+
for (const additionalRef of additionalFetchRefs) {
2348+
const additionalRefSpec = getSingleRefSpec(additionalRef, '');
2349+
result.push(...additionalRefSpec);
2350+
}
2351+
return result;
2352+
}
23382353
/**
23392354
* Tests whether the initial fetch created the ref at the expected commit
23402355
*/

0 commit comments

Comments
 (0)