<commit_before>angular.module('codebrag.branches')

    .factory('currentRepoContext', function(authService, $rootScope, $q, events) {

        var currentContext,
            contextReady = $q.defer(),
            TO_REVIEW = 'pending',
            ALL = 'all';

        currentContext = {
            commitsFilter: TO_REVIEW,
            repo: null,
            branch: null,

            ready: function () {
                return contextReady.promise;
            },

            isToReviewFilterSet: function () {
                return this.commitsFilter === TO_REVIEW;
            },

            switchBranch: function (newBranch) {
                this.branch = newBranch;
                $rootScope.$broadcast(events.branches.branchChanged, newBranch);
            },

            switchCommitsFilter: function (newFilter) {
                this.commitsFilter = (newFilter === TO_REVIEW ? newFilter : ALL);
                $rootScope.$broadcast(events.commitsListFilterChanged, this.commitsFilter);
            }
        };

        authService.userAuthenticated.then(function(user) {
            currentContext.branch = user.settings.selectedBranch;
            currentContext.repo  = 'codebrag';  // TODO: fetch from authenticated user
            contextReady.resolve();
        });

        return currentContext;
<commit_msg>Temporary hack - expose current context to rootScope to be able to switch repos easily.<commit_after>angular.module('codebrag.branches')

    .factory('currentRepoContext', function(authService, $rootScope, $q, events) {

        var currentContext,
            contextReady = $q.defer(),
            TO_REVIEW = 'pending',
            ALL = 'all';

        currentContext = {
            commitsFilter: TO_REVIEW,
            repo: null,
            branch: null,

            ready: function () {
                return contextReady.promise;
            },

            isToReviewFilterSet: function () {
                return this.commitsFilter === TO_REVIEW;
            },

            switchBranch: function (newBranch) {
                this.branch = newBranch;
                $rootScope.$broadcast(events.branches.branchChanged, newBranch);
            },

            switchCommitsFilter: function (newFilter) {
                this.commitsFilter = (newFilter === TO_REVIEW ? newFilter : ALL);
                $rootScope.$broadcast(events.commitsListFilterChanged, this.commitsFilter);
            }
        };

        authService.userAuthenticated.then(function(user) {
            currentContext.branch = user.settings.selectedBranch;
            currentContext.repo  = 'codebrag';  // TODO: fetch from authenticated user
            contextReady.resolve();
        });

        $rootScope.currentRepoContext = currentContext;     //FIXME: for now, to get access to switching repo
        return currentContext;

{'fraction_non_alphanumeric': 0.09762900976290098, 'fraction_numerical': 0.0, 'mean_word_length': 1.8921370967741935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '411992', 'n_tokens_mistral': 735, 'n_tokens_neox': 714, 'n_words': 144}