예제 #1
0
 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()
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
 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
예제 #5
0
 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()
예제 #6
0
 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