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)
def branches(): """Returns a list of branches in a given repository by querying Gerrit. GET /gerrit/branches?param=<value> :arg str project: Project to query branches from. (required) JSON:: { "branches": [ { "ref": "refs/heads/stable/beryllium", "revision": "8f72284f3808328604bdff7f91a6999094f7c6d7" }, ... ] } """ mapping = { 'project': request.args.get('project', None), } result = check_parameters(mapping) if not result: gerrit = GerritHandler(app.config['GERRIT_URL']) branches = gerrit.project_branches_list(mapping['project']) if not branches: result = {'error': 'No branches found for {0}.'.format(mapping['project'])} else: result = {'branches': branches} return jsonify(result)
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)
def branches(): """Returns a list of branches in a given repository by querying Gerrit. GET /gerrit/branches?param=<value> :arg str project: Project to query branches from. (required) JSON:: { "branches": [ { "ref": "refs/heads/stable/beryllium", "revision": "8f72284f3808328604bdff7f91a6999094f7c6d7" }, ... ] } """ mapping = { 'project': request.args.get('project', None), } result = check_parameters(mapping) if not result: gerrit = GerritHandler(app.config['GERRIT_URL']) branches = gerrit.project_branches_list(mapping['project']) if not branches: result = { 'error': 'No branches found for {0}.'.format(mapping['project']) } else: result = {'branches': branches} return jsonify(result)
def merged_changes(): """Returns a list of merged changes in a given repository by querying Gerrit. GET /gerrit/changes?param=<value> :arg str project: Project to query changes from. (required) :arg str branch: Branch to pull changes from. (default: master) JSON:: { "changes": [ { "_number": 37706, "branch": "master", "change_id": "I4168e023b77bfddbb6f72057e849925ba2dffa17", "created": "2016-04-18 02:42:33.000000000", "deletions": 0, "hashtags": [], "id": "spectrometer~master~I4168e023b77bfddbb6f72057e849925ba2dffa17", "insertions": 119, "owner": { "_account_id": 2759 }, "project": "spectrometer", "status": "MERGED", "subject": "Add API to return commits since ref", "submittable": false, "topic": "git-api", "updated": "2016-04-19 09:03:03.000000000" }, ... ] } """ mapping = { 'project': request.args.get('project', None), 'branch': request.args.get('branch', 'master') } result = check_parameters(mapping) if not result: gerrit = GerritHandler(app.config['GERRIT_URL']) changes = gerrit.project_merged_changes_list(mapping['project'], mapping['branch']) if not changes: result = { 'error': 'No changes found for {0}.'.format(mapping['project']) } else: result = {'changes': changes} return jsonify(result)
def merged_changes(): """Returns a list of merged changes in a given repository by querying Gerrit. GET /gerrit/changes?param=<value> :arg str project: Project to query changes from. (required) :arg str branch: Branch to pull changes from. (default: master) JSON:: { "changes": [ { "_number": 37706, "branch": "master", "change_id": "I4168e023b77bfddbb6f72057e849925ba2dffa17", "created": "2016-04-18 02:42:33.000000000", "deletions": 0, "hashtags": [], "id": "spectrometer~master~I4168e023b77bfddbb6f72057e849925ba2dffa17", "insertions": 119, "owner": { "_account_id": 2759 }, "project": "spectrometer", "status": "MERGED", "subject": "Add API to return commits since ref", "submittable": false, "topic": "git-api", "updated": "2016-04-19 09:03:03.000000000" }, ... ] } """ mapping = { 'project': request.args.get('project', None), 'branch': request.args.get('branch', 'master') } result = check_parameters(mapping) if not result: gerrit = GerritHandler(app.config['GERRIT_URL']) changes = gerrit.project_merged_changes_list(mapping['project'], mapping['branch']) if not changes: result = {'error': 'No changes found for {0}.'.format(mapping['project'])} else: result = {'changes': changes} return jsonify(result)
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)
def tags(): """Returns a list of tags in a given repository by querying Gerrit. GET /gerrit/tags?param=<value> :arg str project: Project to query tags from. (required) JSON:: { "tags": [ { "message": "OpenDaylight Beryllium-SR1 release", "object": "f76cc0a12dc8f06dae3cedc31d06add72df8de5d", "ref": "refs/tags/release/beryllium-sr1", "revision": "8b92d614ee48b4fc5ba11c3f38c92dfa14d43655", "tagger": { "date": "2016-03-23 13:34:09.000000000", "email": "*****@*****.**", "name": "Thanh Ha", "tz": -240 } }, ... ] } """ mapping = { 'project': request.args.get('project', None), } result = check_parameters(mapping) if not result: gerrit = GerritHandler(app.config['GERRIT_URL']) tags = gerrit.project_tags_list(mapping['project']) if not branches: result = { 'error': 'No tags found for {0}.'.format(mapping['project']) } else: result = {'tags': tags} return jsonify(result)
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), 'no_cache': request.args.get('no_cache', False), } result = check_parameters(mapping) if not result: git = create_handler(mapping['project']) collection = app.mongo.db.branches data_id = '{0}'.format(mapping['project']) args = [] branches = get_cache(collection, data_id, mapping['no_cache'], git.branches, args) if branches: result = {'branches': branches} else: result = {'error': 'No branches found for {0}.'.format(mapping['project'])} return jsonify(result)
def tags(): """Returns a list of tags in a given repository by querying Gerrit. GET /gerrit/tags?param=<value> :arg str project: Project to query tags from. (required) JSON:: { "tags": [ { "message": "OpenDaylight Beryllium-SR1 release", "object": "f76cc0a12dc8f06dae3cedc31d06add72df8de5d", "ref": "refs/tags/release/beryllium-sr1", "revision": "8b92d614ee48b4fc5ba11c3f38c92dfa14d43655", "tagger": { "date": "2016-03-23 13:34:09.000000000", "email": "*****@*****.**", "name": "Thanh Ha", "tz": -240 } }, ... ] } """ mapping = { 'project': request.args.get('project', None), } result = check_parameters(mapping) if not result: gerrit = GerritHandler(app.config['GERRIT_URL']) tags = gerrit.project_tags_list(mapping['project']) if not branches: result = {'error': 'No tags found for {0}.'.format(mapping['project'])} else: result = {'tags': tags} return jsonify(result)
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)
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)
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)
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)
def commits_since_ref(): """Returns a list of commits in branch until common parent of ref. Searches Git for a common_parent between *branch* and *ref* 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 branch: Branch to pull commits from. (required) :arg str ref: To pull cached data or not. (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), 'no_cache': request.args.get('no_cache', False), } result = check_parameters(mapping) if not result: git = create_handler(mapping['project']) collection = app.mongo.db.commits data_id = '{0}:{1}:{2}'.format(mapping['project'], mapping['ref1'], mapping['ref2']) args = [mapping['ref1'], mapping['ref2']] commits = get_cache(collection, data_id, mapping['no_cache'], git.commits_since_ref, args) if commits: result = {'commits': commits} else: result = {'error': 'Unable to compare {ref1} to {ref2}.'.format( ref1=mapping['ref1'], ref2=mapping['ref2'])} return jsonify(result)