src/utils/repo.js
function fetchBranches(repoState, driver) {
    const oldBranches = repoState.getBranches();
    return driver.fetchBranches()
    .then((branches) => {
        return repoState.set('branches', branches);
    })
    .then(function refreshWorkingStates(repoState) {
        // Remove outdated WorkingStates
        return oldBranches.reduce((repoState, oldBranch) => {
            const fullName = oldBranch.getFullName();
            const newBranch = repoState.getBranch(fullName);
            if (newBranch === null || newBranch.getSha() !== oldBranch.getSha()) {
                // Was removed OR updated
                return updateWorkingState(repoState, oldBranch, null);
            } else {
                // Unchanged
                return repoState;
            }
        }, repoState);
    });
}
function fetchBranches(repoState, driver) {
    const oldBranches = repoState.getBranches();
    return driver.fetchBranches()
    .then((branches) => {
        return repoState.set('branches', branches);
    })
    .then(function refreshWorkingStates(repoState) {
        // Remove outdated WorkingStates
        return oldBranches.reduce((repoState, oldBranch) => {
            const fullName = oldBranch.getFullName();
            const newBranch = repoState.getBranch(fullName);
            if (newBranch === null || newBranch.getSha() !== oldBranch.getSha()) {
                // Was removed OR updated
                return updateWorkingState(repoState, oldBranch, null);
            } else {
                // Unchanged
                return repoState;
            }
        }, repoState);
    });
}
Fetch the list of branches in the repository and update them all. Will clear the
WorkingStates of all branches that have updated.
@param {RepositoryState} repoState
@param {Driver} driver
@return {Promise<RepositoryState>} with list of branches fetched