You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2019/06/14 11:30:11 UTC
[lucene-solr] branch master updated: LUCENE-8861: Script to find
open PRs that needs attention (#719)
This is an automated email from the ASF dual-hosted git repository.
janhoy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new d279368 LUCENE-8861: Script to find open PRs that needs attention (#719)
d279368 is described below
commit d2793688ca6d2d7e0f334108c9a504f45a78d262
Author: Jan Høydahl <ja...@users.noreply.github.com>
AuthorDate: Fri Jun 14 13:30:04 2019 +0200
LUCENE-8861: Script to find open PRs that needs attention (#719)
---
dev-tools/scripts/githubPRs.py | 111 +++++++++++++++++++++++++++++++++++++
dev-tools/scripts/requirements.txt | 2 +
lucene/CHANGES.txt | 2 +
3 files changed, 115 insertions(+)
diff --git a/dev-tools/scripts/githubPRs.py b/dev-tools/scripts/githubPRs.py
new file mode 100755
index 0000000..999b380
--- /dev/null
+++ b/dev-tools/scripts/githubPRs.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Simple script that queries Github for all open PRs, then finds the ones without
+issue number in title, and the ones where the linked JIRA is already closed
+"""
+
+import os
+import sys
+sys.path.append(os.path.dirname(__file__))
+import argparse
+import json
+import re
+from github import Github
+from jira import JIRA
+
+def read_config():
+ parser = argparse.ArgumentParser(description='Find open Pull Requests that need attention')
+ parser.add_argument('--json', action='store_true', default=False, help='Output as json')
+ parser.add_argument('--token', help='Github access token in case you query too often anonymously')
+ newconf = parser.parse_args()
+ return newconf
+
+
+def out(text):
+ global conf
+ if not conf.json:
+ print(text)
+
+
+def main():
+ global conf
+ conf = read_config()
+ token = conf.token if conf.token is not None else None
+ if token:
+ gh = Github(token)
+ else:
+ gh = Github()
+ jira = JIRA('https://issues.apache.org/jira')
+ result = {}
+ repo = gh.get_repo('apache/lucene-solr')
+ open_prs = repo.get_pulls(state='open')
+ out("Lucene/Solr Github PR report")
+ out("============================")
+ out("Number of open Pull Requests: %s" % open_prs.totalCount)
+ result['open_count'] = open_prs.totalCount
+
+ lack_jira = list(filter(lambda x: not re.match(r'.*\b(LUCENE|SOLR)-\d{3,6}\b', x.title), open_prs))
+ lack_jira_dict = {}
+ for pr in lack_jira:
+ lack_jira_dict[pr.number] = pr.title
+ result['no_jira_count'] = len(lack_jira_dict)
+ result['no_jira'] = lack_jira_dict
+ out("\nPRs lacking JIRA reference in title")
+ for pr in lack_jira:
+ out(" #%s: %s" % (pr.number, pr.title))
+
+ out("\nOpen PRs with a resolved JIRA")
+ has_jira = list(filter(lambda x: re.match(r'.*\b(LUCENE|SOLR)-\d{3,6}\b', x.title), open_prs))
+
+ issue_ids = []
+ issue_to_pr = {}
+ for pr in has_jira:
+ jira_issue_str = re.match(r'.*\b((LUCENE|SOLR)-\d{3,6})\b', pr.title).group(1)
+ issue_ids.append(jira_issue_str)
+ issue_to_pr[jira_issue_str] = pr
+
+ resolved_jiras = jira.search_issues(jql_str="key in (%s) AND status in ('Closed', 'Resolved')" % ", ".join(issue_ids))
+ closed_jira_dict = {}
+ for issue in resolved_jiras:
+ pr_title = issue_to_pr[issue.key].title
+ pr_number = issue_to_pr[issue.key].number
+ closed_jira_dict[pr_number] = { 'key': issue.key,
+ 'status': issue.fields.status.name,
+ 'resolution': issue.fields.resolution.name,
+ 'resolution_date': issue.fields.resolutiondate,
+ 'pr_title': pr_title}
+ out(" #%s: %s status=%s, resolution=%s, resolutiondate=%s (%s)" % (pr_number,
+ issue.key,
+ issue.fields.status.name,
+ issue.fields.resolution.name,
+ issue.fields.resolutiondate,
+ pr_title)
+ )
+ result['closed_jira_count'] = len(resolved_jiras)
+ result['closed_jira'] = closed_jira_dict
+
+ if conf.json:
+ print(json.dumps(result, indent=4))
+
+
+if __name__ == '__main__':
+ try:
+ main()
+ except KeyboardInterrupt:
+ print('\nReceived Ctrl-C, exiting early')
diff --git a/dev-tools/scripts/requirements.txt b/dev-tools/scripts/requirements.txt
new file mode 100644
index 0000000..a65679d
--- /dev/null
+++ b/dev-tools/scripts/requirements.txt
@@ -0,0 +1,2 @@
+PyGithub
+jira
\ No newline at end of file
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index afbddf4..2c3efe1 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -109,6 +109,8 @@ Other
* LUCENE-8847: Code Cleanup: Remove StringBuilder.append with concatted strings
+* LUCENE-8861: Script to find open Github PRs that needs attention (janhoy)
+
======================= Lucene 8.1.1 =======================
(No Changes)