def test_get_commit_id_from_ref_404(self): """ Attempt to fetch a branch that has been deleted """ responses.add( responses.GET, 'https://api.github.com/repos/edx/edx-platform/git/refs/heads/deleted-branch', body=json.dumps({'message': 'Not Found'}), content_type='application/json; charset=utf8', status=404) with self.assertRaises(github.ObjectDoesNotExist): github.get_commit_id_from_ref('edx/edx-platform', 'deleted-branch')
def test_get_commit_id_from_ref(self): """ Obtaining `commit_id` from a repo reference (eg. a branch) """ responses.add( responses.GET, 'https://api.github.com/repos/edx/edx-platform/git/refs/heads/master', body=json.dumps({'object': {'sha': 'test-sha'}}), content_type='application/json; charset=utf8', status=200) self.assertEqual( github.get_commit_id_from_ref('edx/edx-platform', 'master'), 'test-sha')
def get_branch_tip(self): """ Get the `commit_id` of the current tip of the branch """ self.logger.info('Fetching commit ID of the tip of branch %s', self.branch_name) try: new_commit_id = github.get_commit_id_from_ref( self.fork_name, self.branch_name, ref_type=self.ref_type) except github.ObjectDoesNotExist: self.logger.error("Branch '%s' not found. Has it been deleted on GitHub?", self.branch_name) raise return new_commit_id
def get_branch_tip(self): """ Get the `commit_id` of the current tip of the branch """ self.logger.info('Fetching commit ID of the tip of branch %s', self.branch_name) try: new_commit_id = github.get_commit_id_from_ref( self.fork_name, self.branch_name, ref_type=self.ref_type) except github.ObjectDoesNotExist: self.logger.error( "Branch '%s' not found. Has it been deleted on GitHub?", self.branch_name) raise return new_commit_id