src/indexOld.js
function _commit(repo, pathsToStage, message, pathsToUnstage) {
        return co(function*(){
            repo = repo || (yield nodegit.Repository.open(repositoryPath));
            debug("Adding files to the index");
            let index = yield repo.refreshIndex(repositoryPath + "/.git/index");

            if(pathsToUnstage && pathsToUnstage.length && pathsToUnstage.length > 0) {
                for(let file of pathsToUnstage) {
                    yield index.removeByPath(file);
                }
                yield index.write();
                yield index.writeTree();
            }

            debug("Creating main files");
            let signature = nodegit.Signature.default(repo);
            debug("Commiting");
            yield repo.createCommitOnHead(pathsToStage, signature, signature, message || "Automatic initialization");
        });
    }
function _commit(repo, pathsToStage, message, pathsToUnstage) {
        return co(function*(){
            repo = repo || (yield nodegit.Repository.open(repositoryPath));
            debug("Adding files to the index");
            let index = yield repo.refreshIndex(repositoryPath + "/.git/index");

            if(pathsToUnstage && pathsToUnstage.length && pathsToUnstage.length > 0) {
                for(let file of pathsToUnstage) {
                    yield index.removeByPath(file);
                }
                yield index.write();
                yield index.writeTree();
            }

            debug("Creating main files");
            let signature = nodegit.Signature.default(repo);
            debug("Commiting");
            yield repo.createCommitOnHead(pathsToStage, signature, signature, message || "Automatic initialization");
        });
    }
function _commit ( repo , pathsToStage , message , pathsToUnstage ) { return co ( function * ( ) { repo = repo || ( yield nodegit . Repository . open ( repositoryPath ) ) ; debug ( "Adding files to the index" ) ; let index = yield repo . refreshIndex ( repositoryPath + "/.git/index" ) ; if ( pathsToUnstage && pathsToUnstage . length && pathsToUnstage . length > 0 ) { for ( let file of pathsToUnstage ) { yield index . removeByPath ( file ) ; } yield index . write ( ) ; yield index . writeTree ( ) ; } debug ( "Creating main files" ) ; let signature = nodegit . Signature . default ( repo ) ; debug ( "Commiting" ) ; yield repo . createCommitOnHead ( pathsToStage , signature , signature , message || "Automatic initialization" ) ; } ) ; }
Commit to the repository
@method _commit
@param {Repository} repo The repository connection object
@param {Array} pathsToStage The array of file paths(relative to the repository) to be staged
@param {String} message The message to go along with this commit
@param {Array} pathsToUnstage The array of file paths(relative to the repository) to be un-staged
@returns {Array} An Array of file paths belonging to the directory path provided
Commit to the repository