src/utils/remote.js
function sync(repoState, driver, opts = {}) {
    opts = Object.assign({
        branch: repoState.getCurrentBranch(),
        force: false,
        remote: {
            name: 'origin'
        }
    }, opts);

    return pull(repoState, driver, opts)
        .fail((err) => {
            if (err.code === ERRORS.REF_NOT_FOUND) {
                return Promise(repoState);
            }

            return Promise.reject(err);
        })
        .then((newRepoState) => {
            return push(newRepoState, driver, opts);
        });
}
function sync(repoState, driver, opts = {}) {
    opts = Object.assign({
        branch: repoState.getCurrentBranch(),
        force: false,
        remote: {
            name: 'origin'
        }
    }, opts);

    return pull(repoState, driver, opts)
        .fail((err) => {
            if (err.code === ERRORS.REF_NOT_FOUND) {
                return Promise(repoState);
            }

            return Promise.reject(err);
        })
        .then((newRepoState) => {
            return push(newRepoState, driver, opts);
        });
}
Sync repository with remote by pulling / pushing to the remote.
@param {RepositoryState} repoState
@param {Driver} driver
@param {Branch} [opts.branch] Branch to push. Default to current
@param {String} [opts.remote.name=origin] Name of the remote
@param {String} [opts.remote.url] URL if the remote needs to be created
@param {Boolean} [opts.force=false] Ignore non fast forward
@param {String} [opts.auth.username] Authentication username
@param {String} [opts.auth.password] Authentication password
@return {Promise<RepositoryState>}
@throws {Promise<ERROR.NOT_FAST_FORWARD>}
@throws {Promise<ERROR.AUTHENTICATION_FAILED>}
@throws {Promise<ERROR.UNKNOWN_REMOTE>}