lib/utils/git.js
function cloneGitRepo(host, ref) {
    var isBranch = false;

    ref = ref || 'master';
    if (!validateSha(ref)) isBranch = true;

    return Q()

    // Create temporary folder to store git repos
    .then(function() {
        if (GIT_TMP) return;
        return fs.tmp.dir()
            .then(function(_tmp) {
                GIT_TMP = _tmp;
            });
    })

    // Return or clone the git repo
    .then(function() {
        // Unique ID for repo/ref combinaison
        var repoId = crc.crc32(host+'#'+ref).toString(16);

        // Absolute path to the folder
        var repoPath = path.resolve(GIT_TMP, repoId);

        return fs.exists(repoPath)
            .then(function(doExists) {
                if (doExists) return;

                // Clone repo
                return exec('git clone '+host+' '+repoPath)
                .then(function() {
                    return exec('git checkout '+ref, { cwd: repoPath });
                });
            })
            .thenResolve(repoPath);
    });
}
function cloneGitRepo(host, ref) {
    var isBranch = false;

    ref = ref || 'master';
    if (!validateSha(ref)) isBranch = true;

    return Q()

    // Create temporary folder to store git repos
    .then(function() {
        if (GIT_TMP) return;
        return fs.tmp.dir()
            .then(function(_tmp) {
                GIT_TMP = _tmp;
            });
    })

    // Return or clone the git repo
    .then(function() {
        // Unique ID for repo/ref combinaison
        var repoId = crc.crc32(host+'#'+ref).toString(16);

        // Absolute path to the folder
        var repoPath = path.resolve(GIT_TMP, repoId);

        return fs.exists(repoPath)
            .then(function(doExists) {
                if (doExists) return;

                // Clone repo
                return exec('git clone '+host+' '+repoPath)
                .then(function() {
                    return exec('git checkout '+ref, { cwd: repoPath });
                });
            })
            .thenResolve(repoPath);
    });
}
function cloneGitRepo ( host , ref ) { var isBranch = false ; ref = ref || 'master' ; if ( ! validateSha ( ref ) ) isBranch = true ; return Q ( ) // Create temporary folder to store git repos . then ( function ( ) { if ( GIT_TMP ) return ; return fs . tmp . dir ( ) . then ( function ( _tmp ) { GIT_TMP = _tmp ; } ) ; } ) // Return or clone the git repo . then ( function ( ) { // Unique ID for repo/ref combinaison var repoId = crc . crc32 ( host + '#' + ref ) . toString ( 16 ) ; // Absolute path to the folder var repoPath = path . resolve ( GIT_TMP , repoId ) ; return fs . exists ( repoPath ) . then ( function ( doExists ) { if ( doExists ) return ; // Clone repo return exec ( 'git clone ' + host + ' ' + repoPath ) . then ( function ( ) { return exec ( 'git checkout ' + ref , { cwd : repoPath } ) ; } ) ; } ) . thenResolve ( repoPath ) ; } ) ; }
Clone a git repo from a specific ref
Clone a git repo from a specific ref