Esempio n. 1
0
    def sync_versions(self, request, **kwargs):
        """
        Sync the version data in the repo (on the build server) with what we have in the database.

        Returns the identifiers for the versions that have been deleted.
        """
        project = get_object_or_404(
            Project.objects.api(self.request.user), pk=kwargs['pk'])

        # If the currently highest non-prerelease version is active, then make
        # the new latest version active as well.
        old_highest_version = determine_stable_version(project.versions.all())
        if old_highest_version is not None:
            activate_new_stable = old_highest_version.active
        else:
            activate_new_stable = False

        try:
            # Update All Versions
            data = request.DATA
            added_versions = set()
            if 'tags' in data:
                ret_set = api_utils.sync_versions(
                    project=project, versions=data['tags'], type='tag')
                added_versions.update(ret_set)
            if 'branches' in data:
                ret_set = api_utils.sync_versions(
                    project=project, versions=data['branches'], type='branch')
                added_versions.update(ret_set)
            deleted_versions = api_utils.delete_versions(project, data)
        except Exception, e:
            log.exception("Sync Versions Error: %s" % e.message)
            return Response({'error': e.message}, status=status.HTTP_400_BAD_REQUEST)
Esempio n. 2
0
    def sync_versions(self, request, **kwargs):
        """
        Sync the version data in the repo (on the build server) with what we have in the database.

        Returns the identifiers for the versions that have been deleted.
        """
        project = get_object_or_404(Project.objects.api(self.request.user),
                                    pk=kwargs['pk'])
        try:
            # Update All Versions
            data = request.DATA
            added_versions = set()
            if 'tags' in data:
                ret_set = api_utils.sync_versions(project=project,
                                                  versions=data['tags'],
                                                  type='tag')
                added_versions.update(ret_set)
            if 'branches' in data:
                ret_set = api_utils.sync_versions(project=project,
                                                  versions=data['branches'],
                                                  type='branch')
                added_versions.update(ret_set)
            deleted_versions = api_utils.delete_versions(project, data)
        except Exception, e:
            log.exception("Sync Versions Error: %s" % e.message)
            return Response({'error': e.message},
                            status=status.HTTP_400_BAD_REQUEST)
Esempio n. 3
0
    def sync_versions(self, request, **kwargs):
        """
        Sync the version data in the repo (on the build server) with what we have in the database.

        Returns the identifiers for the versions that have been deleted.
        """
        project = get_object_or_404(Project, pk=kwargs["pk"])
        try:
            data = request.DATA
            added_versions = set()
            if "tags" in data:
                ret_set = api_utils.sync_versions(project=project, versions=data["tags"], type="tag")
                added_versions.update(ret_set)
            if "branches" in data:
                ret_set = api_utils.sync_versions(project=project, versions=data["branches"], type="branch")
                added_versions.update(ret_set)
            deleted_versions = api_utils.delete_versions(project, data)
            return Response({"added_versions": added_versions, "deleted_versions": deleted_versions})
        except Exception, e:
            log.exception("Sync Versions Error: %s" % e.message)
            return Response({"error": e.message}, status=status.HTTP_400_BAD_REQUEST)
Esempio n. 4
0
    def sync_versions(self, request, **kwargs):
        """
        Sync the version data in the repo (on the build server) with what we have in the database.

        Returns the identifiers for the versions that have been deleted.
        """
        project = get_object_or_404(Project.objects.api(self.request.user), pk=kwargs['pk'])
        try:
            # Update All Versions
            data = request.DATA
            added_versions = set()
            if 'tags' in data:
                ret_set = api_utils.sync_versions(project=project, versions=data['tags'], type='tag')
                added_versions.update(ret_set)
            if 'branches' in data:
                ret_set = api_utils.sync_versions(project=project, versions=data['branches'], type='branch')
                added_versions.update(ret_set)
            deleted_versions = api_utils.delete_versions(project, data)
        except Exception, e:
            log.exception("Sync Versions Error: %s" % e.message)
            return Response({'error': e.message}, status=status.HTTP_400_BAD_REQUEST)