"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const rimraf = require("@zkochan/rimraf");
const execa = require("execa");
const path = require("path");
const tempy = require("tempy");
exports.default = () => {
    return {
        git: async function fetchFromGit(cafs, resolution, opts) {
            const tempLocation = tempy.directory();
            await execGit(['clone', resolution.repo, tempLocation]);
            await execGit(['checkout', resolution.commit], { cwd: tempLocation });
            // removing /.git to make directory integrity calculation faster
            await rimraf(path.join(tempLocation, '.git'));
            return {
                filesIndex: await cafs.addFilesFromDir(tempLocation, opts.manifest),
            };
        },
    };
};
function prefixGitArgs() {
    return process.platform === 'win32' ? ['-c', 'core.longpaths=true'] : [];
}
function execGit(args, opts) {
    const fullArgs = prefixGitArgs().concat(args || []);
    return execa('git', fullArgs, opts);
}
//# sourceMappingURL=index.js.map