def test_prefix_ambiguous(self): repository = self._create_repository() revision_1 = self.create_revision(repository=repository, sha=self.sha) revision_2 = self.create_revision(repository=repository, sha=self.sha_similiar) with pytest.raises(MultipleResultsFound): Revision.get_by_sha_prefix_query(repository.id, '73a5').scalar()
def get(self, project_id, commit_id): project = Project.get(project_id) if not project: return '', 404 repo = project.repository try: revision = Revision.get_by_sha_prefix_query( repo.id, commit_id, ).options( joinedload('author') ).scalar() except MultipleResultsFound: return '', 404 else: if not revision: return '', 404 context = self.serialize(revision) context.update({ 'repository': repo, }) return self.respond(context)
def get(self, project_id, commit_id): project = Project.get(project_id) if not project: return '', 404 repo = project.repository try: revision = Revision.get_by_sha_prefix_query( repo.id, commit_id, ).options(joinedload('author')).scalar() except MultipleResultsFound: return '', 404 else: if not revision: return '', 404 context = self.serialize(revision) context.update({ 'repository': repo, }) return self.respond(context)
def test_prefix_full(self): repository = self._create_repository() revision = self.create_revision(repository=repository, sha=self.sha) assert Revision.get_by_sha_prefix_query(repository.id, self.sha).scalar() == revision