mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-24 12:25:34 +00:00
Revert "Update from upstream"
This commit is contained in:
parent
cd901f67c6
commit
a5a8778704
22 changed files with 16121 additions and 1020 deletions
113
dist/index.js
vendored
113
dist/index.js
vendored
|
@ -470,7 +470,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||
exports.createCommandManager = exports.MinimumGitVersion = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const exec = __importStar(__nccwpck_require__(1514));
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
const fshelper = __importStar(__nccwpck_require__(7219));
|
||||
const io = __importStar(__nccwpck_require__(7436));
|
||||
const path = __importStar(__nccwpck_require__(1017));
|
||||
|
@ -481,9 +480,9 @@ const git_version_1 = __nccwpck_require__(3142);
|
|||
// Auth header not supported before 2.9
|
||||
// Wire protocol v2 not supported before 2.18
|
||||
exports.MinimumGitVersion = new git_version_1.GitVersion('2.18');
|
||||
function createCommandManager(workingDirectory, lfs, doSparseCheckout) {
|
||||
function createCommandManager(workingDirectory, lfs) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield GitCommandManager.createCommandManager(workingDirectory, lfs, doSparseCheckout);
|
||||
return yield GitCommandManager.createCommandManager(workingDirectory, lfs);
|
||||
});
|
||||
}
|
||||
exports.createCommandManager = createCommandManager;
|
||||
|
@ -496,7 +495,6 @@ class GitCommandManager {
|
|||
};
|
||||
this.gitPath = '';
|
||||
this.lfs = false;
|
||||
this.doSparseCheckout = false;
|
||||
this.workingDirectory = '';
|
||||
}
|
||||
branchDelete(remote, branch) {
|
||||
|
@ -576,23 +574,6 @@ class GitCommandManager {
|
|||
return result;
|
||||
});
|
||||
}
|
||||
sparseCheckout(sparseCheckout) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield this.execGit(['sparse-checkout', 'set', ...sparseCheckout]);
|
||||
});
|
||||
}
|
||||
sparseCheckoutNonConeMode(sparseCheckout) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield this.execGit(['config', 'core.sparseCheckout', 'true']);
|
||||
const output = yield this.execGit([
|
||||
'rev-parse',
|
||||
'--git-path',
|
||||
'info/sparse-checkout'
|
||||
]);
|
||||
const sparseCheckoutPath = path.join(this.workingDirectory, output.stdout.trimRight());
|
||||
yield fs.promises.appendFile(sparseCheckoutPath, `\n${sparseCheckout.join('\n')}\n`);
|
||||
});
|
||||
}
|
||||
checkout(ref, startPoint) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const args = ['checkout', '--progress', '--force'];
|
||||
|
@ -634,21 +615,15 @@ class GitCommandManager {
|
|||
return output.exitCode === 0;
|
||||
});
|
||||
}
|
||||
fetch(refSpec, options) {
|
||||
fetch(refSpec, fetchDepth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const args = ['-c', 'protocol.version=2', 'fetch'];
|
||||
if (!refSpec.some(x => x === refHelper.tagsRefSpec) && !options.fetchTags) {
|
||||
if (!refSpec.some(x => x === refHelper.tagsRefSpec)) {
|
||||
args.push('--no-tags');
|
||||
}
|
||||
args.push('--prune', '--no-recurse-submodules');
|
||||
if (options.showProgress) {
|
||||
args.push('--progress');
|
||||
}
|
||||
if (options.filter) {
|
||||
args.push(`--filter=${options.filter}`);
|
||||
}
|
||||
if (options.fetchDepth && options.fetchDepth > 0) {
|
||||
args.push(`--depth=${options.fetchDepth}`);
|
||||
args.push('--prune', '--progress', '--no-recurse-submodules');
|
||||
if (fetchDepth && fetchDepth > 0) {
|
||||
args.push(`--depth=${fetchDepth}`);
|
||||
}
|
||||
else if (fshelper.fileExistsSync(path.join(this.workingDirectory, '.git', 'shallow'))) {
|
||||
args.push('--unshallow');
|
||||
|
@ -721,8 +696,8 @@ class GitCommandManager {
|
|||
}
|
||||
log1(format) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const args = format ? ['log', '-1', format] : ['log', '-1'];
|
||||
const silent = format ? false : true;
|
||||
var args = format ? ['log', '-1', format] : ['log', '-1'];
|
||||
var silent = format ? false : true;
|
||||
const output = yield this.execGit(args, false, silent);
|
||||
return output.stdout;
|
||||
});
|
||||
|
@ -845,10 +820,10 @@ class GitCommandManager {
|
|||
return output.exitCode === 0;
|
||||
});
|
||||
}
|
||||
static createCommandManager(workingDirectory, lfs, doSparseCheckout) {
|
||||
static createCommandManager(workingDirectory, lfs) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const result = new GitCommandManager();
|
||||
yield result.initializeCommandManager(workingDirectory, lfs, doSparseCheckout);
|
||||
yield result.initializeCommandManager(workingDirectory, lfs);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
@ -884,7 +859,7 @@ class GitCommandManager {
|
|||
return result;
|
||||
});
|
||||
}
|
||||
initializeCommandManager(workingDirectory, lfs, doSparseCheckout) {
|
||||
initializeCommandManager(workingDirectory, lfs) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.workingDirectory = workingDirectory;
|
||||
// Git-lfs will try to pull down assets if any of the local/user/system setting exist.
|
||||
|
@ -936,14 +911,6 @@ class GitCommandManager {
|
|||
throw new Error(`Minimum required git-lfs version is ${minimumGitLfsVersion}. Your git-lfs ('${gitLfsPath}') is ${gitLfsVersion}`);
|
||||
}
|
||||
}
|
||||
this.doSparseCheckout = doSparseCheckout;
|
||||
if (this.doSparseCheckout) {
|
||||
// The `git sparse-checkout` command was introduced in Git v2.25.0
|
||||
const minimumGitSparseCheckoutVersion = new git_version_1.GitVersion('2.25');
|
||||
if (!gitVersion.checkMinimum(minimumGitSparseCheckoutVersion)) {
|
||||
throw new Error(`Minimum Git version required for sparse checkout is ${minimumGitSparseCheckoutVersion}. Your git ('${this.gitPath}') is ${gitVersion}`);
|
||||
}
|
||||
}
|
||||
// Set the user agent
|
||||
const gitHttpUserAgent = `git/${gitVersion} (github-actions-checkout)`;
|
||||
core.debug(`Set git useragent to: ${gitHttpUserAgent}`);
|
||||
|
@ -1243,29 +1210,20 @@ function getSource(settings) {
|
|||
}
|
||||
// Fetch
|
||||
core.startGroup('Fetching the repository');
|
||||
const fetchOptions = {};
|
||||
if (settings.filter) {
|
||||
fetchOptions.filter = settings.filter;
|
||||
}
|
||||
else if (settings.sparseCheckout) {
|
||||
fetchOptions.filter = 'blob:none';
|
||||
}
|
||||
if (settings.fetchDepth <= 0) {
|
||||
// Fetch all branches and tags
|
||||
let refSpec = refHelper.getRefSpecForAllHistory(settings.ref, settings.commit);
|
||||
yield git.fetch(refSpec, fetchOptions);
|
||||
yield git.fetch(refSpec);
|
||||
// When all history is fetched, the ref we're interested in may have moved to a different
|
||||
// commit (push or force push). If so, fetch again with a targeted refspec.
|
||||
if (!(yield refHelper.testRef(git, settings.ref, settings.commit))) {
|
||||
refSpec = refHelper.getRefSpec(settings.ref, settings.commit);
|
||||
yield git.fetch(refSpec, fetchOptions);
|
||||
yield git.fetch(refSpec);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fetchOptions.fetchDepth = settings.fetchDepth;
|
||||
fetchOptions.fetchTags = settings.fetchTags;
|
||||
const refSpec = refHelper.getRefSpec(settings.ref, settings.commit);
|
||||
yield git.fetch(refSpec, fetchOptions);
|
||||
yield git.fetch(refSpec, settings.fetchDepth);
|
||||
}
|
||||
core.endGroup();
|
||||
// Checkout info
|
||||
|
@ -1275,23 +1233,11 @@ function getSource(settings) {
|
|||
// LFS fetch
|
||||
// Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
|
||||
// Explicit lfs fetch will fetch lfs objects in parallel.
|
||||
// For sparse checkouts, let `checkout` fetch the needed objects lazily.
|
||||
if (settings.lfs && !settings.sparseCheckout) {
|
||||
if (settings.lfs) {
|
||||
core.startGroup('Fetching LFS objects');
|
||||
yield git.lfsFetch(checkoutInfo.startPoint || checkoutInfo.ref);
|
||||
core.endGroup();
|
||||
}
|
||||
// Sparse checkout
|
||||
if (settings.sparseCheckout) {
|
||||
core.startGroup('Setting up sparse checkout');
|
||||
if (settings.sparseCheckoutConeMode) {
|
||||
yield git.sparseCheckout(settings.sparseCheckout);
|
||||
}
|
||||
else {
|
||||
yield git.sparseCheckoutNonConeMode(settings.sparseCheckout);
|
||||
}
|
||||
core.endGroup();
|
||||
}
|
||||
// Checkout
|
||||
core.startGroup('Checking out the ref');
|
||||
yield git.checkout(checkoutInfo.ref, checkoutInfo.startPoint);
|
||||
|
@ -1345,7 +1291,7 @@ function cleanup(repositoryPath) {
|
|||
}
|
||||
let git;
|
||||
try {
|
||||
git = yield gitCommandManager.createCommandManager(repositoryPath, false, false);
|
||||
git = yield gitCommandManager.createCommandManager(repositoryPath, false);
|
||||
}
|
||||
catch (_a) {
|
||||
return;
|
||||
|
@ -1376,7 +1322,7 @@ function getGitCommandManager(settings) {
|
|||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info(`Working directory is '${settings.repositoryPath}'`);
|
||||
try {
|
||||
return yield gitCommandManager.createCommandManager(settings.repositoryPath, settings.lfs, settings.sparseCheckout != null);
|
||||
return yield gitCommandManager.createCommandManager(settings.repositoryPath, settings.lfs);
|
||||
}
|
||||
catch (err) {
|
||||
// Git is required for LFS
|
||||
|
@ -1727,35 +1673,12 @@ function getInputs() {
|
|||
// Clean
|
||||
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE';
|
||||
core.debug(`clean = ${result.clean}`);
|
||||
// Filter
|
||||
const filter = core.getInput('filter');
|
||||
if (filter) {
|
||||
result.filter = filter;
|
||||
}
|
||||
core.debug(`filter = ${result.filter}`);
|
||||
// Sparse checkout
|
||||
const sparseCheckout = core.getMultilineInput('sparse-checkout');
|
||||
if (sparseCheckout.length) {
|
||||
result.sparseCheckout = sparseCheckout;
|
||||
core.debug(`sparse checkout = ${result.sparseCheckout}`);
|
||||
}
|
||||
result.sparseCheckoutConeMode =
|
||||
(core.getInput('sparse-checkout-cone-mode') || 'true').toUpperCase() ===
|
||||
'TRUE';
|
||||
// Fetch depth
|
||||
result.fetchDepth = Math.floor(Number(core.getInput('fetch-depth') || '1'));
|
||||
if (isNaN(result.fetchDepth) || result.fetchDepth < 0) {
|
||||
result.fetchDepth = 0;
|
||||
}
|
||||
core.debug(`fetch depth = ${result.fetchDepth}`);
|
||||
// Fetch tags
|
||||
result.fetchTags =
|
||||
(core.getInput('fetch-tags') || 'false').toUpperCase() === 'TRUE';
|
||||
core.debug(`fetch tags = ${result.fetchTags}`);
|
||||
// Show fetch progress
|
||||
result.showProgress =
|
||||
(core.getInput('show-progress') || 'true').toUpperCase() === 'TRUE';
|
||||
core.debug(`show progress = ${result.showProgress}`);
|
||||
// LFS
|
||||
result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE';
|
||||
core.debug(`lfs = ${result.lfs}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue