Beispiel #1
0
def commits():
    """Returns a list of commit messages in a repository.

    GET /git/commits?param=<value>

    :arg str project: Project to query commits from. (required)
    :arg str branch: Branch to pull commits from. (default: master)

    JSON::

        {
          "commits": [
            {
              "author": "Thanh Ha",
              "author_email": "*****@*****.**",
              "author_tz_offset": 14400,
              "authored_date": 1460316386,
              "committed_date": 1460392605,
              "committer": "Thanh Ha",
              "committer_email": "*****@*****.**",
              "committer_tz_offset": 14400,
              "hash": "1e409af62fd99413c5be86c5b43ad602a8cebc1e",
              "lines": {
                "deletions": 55,
                "files": 7,
                "insertions": 103,
                "lines": 158
              },
              "message": "Refactor Gerrit API into a Flask Blueprint..."
            },
            ...
          ]
        }

    .. note::

        :date: The date represented in seconds since epoch
        :tz_offset: The seconds offset west of UTC.
    """
    mapping = {
        'project': request.args.get('project', None),
        'branch': request.args.get('branch', 'master'),
    }

    filters = {
        'author': request.args.get('author', None),
        'organization': request.args.get('organization', None)
    }

    result = check_parameters(mapping)
    if not result:
        git = get_githandler(mapping['project'])
        commits = git.commits(mapping['branch'], filters=filters)

        if commits:
            result = {'commits': commits}
        else:
            result = {'error': 'Unable to lookup commits, branch {0} was not found!'.format(mapping['branch'])}

    return jsonify(result)
Beispiel #2
0
def branches():
    """Returns a list of branches in a given repository.

    GET /git/branches?param=<value>

    :arg str project: Project to query commits from. (required)

    JSON::

        {
          "branches": [
            "master",
            "stable/beryllium",
            "stable/helium",
            "stable/lithium",
            ...
          ]
        }
    """

    mapping = {
        'project': request.args.get('project', None),
    }

    result = check_parameters(mapping)
    if not result:
        git = get_githandler(mapping['project'])
        branches = git.branches()

        if branches:
            result = {'branches': branches}
        else:
            result = {'error': 'No branches found for {0}.'.format(mapping['project'])}

    return jsonify(result)
Beispiel #3
0
def project_info():
    """Provides meta information on project.

    Refer to the specfile located here:
    https://opendaylight-spectrometer.readthedocs.io/en/latest/project-info-spec.html
    """
    mapping = {
        'project': request.args.get('project', None),
    }

    result = check_parameters(mapping)
    if not result:
        git = get_githandler(mapping['project'])
        project_info = git.project_info()
        result = {'project-info': project_info}

    return jsonify(result)
Beispiel #4
0
def project_info():
    """Provides meta information on project.

    Refer to the specfile located here:
    https://opendaylight-spectrometer.readthedocs.io/en/latest/project-info-spec.html
    """
    mapping = {
        'project': request.args.get('project', None),
    }

    result = check_parameters(mapping)
    if not result:
        git = get_githandler(mapping['project'])
        project_info = git.project_info()
        result = {'project-info': project_info}

    return jsonify(result)
Beispiel #5
0
def branches():
    """Returns a list of branches in a given repository.

    GET /git/branches?param=<value>

    :arg str project: Project to query commits from. (required)

    JSON::

        {
          "branches": [
            "master",
            "stable/beryllium",
            "stable/helium",
            "stable/lithium",
            ...
          ]
        }
    """

    mapping = {
        'project': request.args.get('project', None),
    }

    result = check_parameters(mapping)
    if not result:
        git = get_githandler(mapping['project'])
        branches = git.branches()

        if branches:
            result = {'branches': branches}
        else:
            result = {
                'error':
                'No branches found for {0}.'.format(mapping['project'])
            }

    return jsonify(result)
Beispiel #6
0
def commits():
    """Returns a list of commit messages in a repository.

    GET /git/commits?param=<value>

    :arg str project: Project to query commits from. (required)
    :arg str branch: Branch to pull commits from. (default: master)

    JSON::

        {
          "commits": [
            {
              "author": "Thanh Ha",
              "author_email": "*****@*****.**",
              "author_tz_offset": 14400,
              "authored_date": 1460316386,
              "committed_date": 1460392605,
              "committer": "Thanh Ha",
              "committer_email": "*****@*****.**",
              "committer_tz_offset": 14400,
              "hash": "1e409af62fd99413c5be86c5b43ad602a8cebc1e",
              "lines": {
                "deletions": 55,
                "files": 7,
                "insertions": 103,
                "lines": 158
              },
              "message": "Refactor Gerrit API into a Flask Blueprint..."
            },
            ...
          ]
        }

    .. note::

        :date: The date represented in seconds since epoch
        :tz_offset: The seconds offset west of UTC.
    """
    mapping = {
        'project': request.args.get('project', None),
        'branch': request.args.get('branch', 'master'),
    }

    filters = {
        'author': request.args.get('author', None),
        'organization': request.args.get('organization', None)
    }

    result = check_parameters(mapping)
    if not result:
        git = get_githandler(mapping['project'])
        commits = git.commits(mapping['branch'], filters=filters)

        if commits:
            result = {'commits': commits}
        else:
            result = {
                'error':
                'Unable to lookup commits, branch {0} was not found!'.format(
                    mapping['branch'])
            }

    return jsonify(result)
Beispiel #7
0
def commits_since_ref():
    """Returns a list of commits in branch until common parent of ref.

    Searches Git for a common_parent between *ref1* and *ref2* and returns
    a the commit log of all the commits until the common parent excluding
    the common_parent commit itself.

    GET /git/commits_since_ref?param=<value>

    :arg str project: Project to query commits from. (required)
    :arg str ref1: Reference to get commit information from. (required)
    :arg str ref2: Reference to start at until ref1. (required)

    JSON::

        {
          "commits": [
            {
              "author": "Thanh Ha",
              "author_email": "*****@*****.**",
              "author_tz_offset": 14400,
              "authored_date": 1460316386,
              "committed_date": 1460392605,
              "committer": "Thanh Ha",
              "committer_email": "*****@*****.**",
              "committer_tz_offset": 14400,
              "hash": "1e409af62fd99413c5be86c5b43ad602a8cebc1e",
              "lines": {
                "deletions": 55,
                "files": 7,
                "insertions": 103,
                "lines": 158
              },
              "message": "Refactor Gerrit API into a Flask Blueprint..."
            },
            ...
          ]
        }
    """
    mapping = {
        'project': request.args.get('project', None),
        'ref1': request.args.get('ref1', None),
        'ref2': request.args.get('ref2', None),
    }

    filters = {
        'author': request.args.get('author', None),
        'organization': request.args.get('organization', None)
    }

    result = check_parameters(mapping)
    if not result:
        git = get_githandler(mapping['project'])
        commits = git.commits_since_ref(mapping['ref1'],
                                        mapping['ref2'],
                                        filters=filters)

        if commits:
            result = {'commits': commits}
        else:
            result = {
                'error':
                'Unable to compare {ref1} to {ref2}.'.format(
                    ref1=mapping['ref1'], ref2=mapping['ref2'])
            }

    return jsonify(result)
Beispiel #8
0
def commits_since_ref():
    """Returns a list of commits in branch until common parent of ref.

    Searches Git for a common_parent between *ref1* and *ref2* and returns
    a the commit log of all the commits until the common parent excluding
    the common_parent commit itself.

    GET /git/commits_since_ref?param=<value>

    :arg str project: Project to query commits from. (required)
    :arg str ref1: Reference to get commit information from. (required)
    :arg str ref2: Reference to start at until ref1. (required)

    JSON::

        {
          "commits": [
            {
              "author": "Thanh Ha",
              "author_email": "*****@*****.**",
              "author_tz_offset": 14400,
              "authored_date": 1460316386,
              "committed_date": 1460392605,
              "committer": "Thanh Ha",
              "committer_email": "*****@*****.**",
              "committer_tz_offset": 14400,
              "hash": "1e409af62fd99413c5be86c5b43ad602a8cebc1e",
              "lines": {
                "deletions": 55,
                "files": 7,
                "insertions": 103,
                "lines": 158
              },
              "message": "Refactor Gerrit API into a Flask Blueprint..."
            },
            ...
          ]
        }
    """
    mapping = {
        'project': request.args.get('project', None),
        'ref1': request.args.get('ref1', None),
        'ref2': request.args.get('ref2', None),
    }

    filters = {
        'author': request.args.get('author', None),
        'organization': request.args.get('organization', None)
    }

    result = check_parameters(mapping)
    if not result:
        git = get_githandler(mapping['project'])
        commits = git.commits_since_ref(
            mapping['ref1'], mapping['ref2'], filters=filters)

        if commits:
            result = {'commits': commits}
        else:
            result = {'error': 'Unable to compare {ref1} to {ref2}.'.format(
                ref1=mapping['ref1'], ref2=mapping['ref2'])}

    return jsonify(result)