Resolve dynamically-set branch

def get_checkout_target(self):
        '''
        Resolve dynamically-set branch
        '''
        if self.role == 'git_pillar' and self.branch == '__env__':
            try:
                return self.all_saltenvs
            except AttributeError:
                # all_saltenvs not configured for this remote
                pass
            target = self.opts.get('pillarenv') \
                or self.opts.get('saltenv') \
                or 'base'
            return self.base \
                if target == 'base' \
                else six.text_type(target)
        return self.branch