'Helper method to forcefully publish a course,
making the published branch point to the same structure as the draft branch.'

def force_publish_course(self, course_locator, user_id, commit=False):

    versions = None
    index_entry = self.get_course_index(course_locator)
    if (index_entry is not None):
        versions = index_entry['versions']
        if commit:
            if (versions['published-branch'] != versions['draft-branch']):
                self._update_head(course_locator, index_entry, 'published-branch', index_entry['versions']['draft-branch'])
                self._flag_publish_event(course_locator)
                return self.get_course_index(course_locator)['versions']
    return versions
