You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by fj...@apache.org on 2019/05/17 06:11:22 UTC
[incubator-druid] branch master updated: Add auto tagging milestone
script (#7677)
This is an automated email from the ASF dual-hosted git repository.
fjy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git
The following commit(s) were added to refs/heads/master by this push:
new 94721de Add auto tagging milestone script (#7677)
94721de is described below
commit 94721de141ba04420616a5a5380a6db453d8a025
Author: Jihoon Son <ji...@apache.org>
AuthorDate: Thu May 16 23:11:17 2019 -0700
Add auto tagging milestone script (#7677)
* Add auto tagging milestone script
* fix usage
* missing newline
* missing newline
---
docs/_bin/tag-missing-milestones.py | 60 +++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/docs/_bin/tag-missing-milestones.py b/docs/_bin/tag-missing-milestones.py
new file mode 100644
index 0000000..9f78d28
--- /dev/null
+++ b/docs/_bin/tag-missing-milestones.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python3
+
+# 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.
+
+import os
+import subprocess
+import sys
+import requests
+
+
+if len(sys.argv) != 5:
+ sys.stderr.write('usage: program <github-username> <previous-release-commit> <new-release-commit> <milestone-number-to-tag>\n')
+ sys.stderr.write(" e.g., program myusername 75c70c2ccc 29f3a328da 30\n")
+ sys.stderr.write(" It is also necessary to set a GIT_TOKEN environment variable containing a personal access token.\n")
+ sys.exit(1)
+
+
+github_username = sys.argv[1]
+previous_release_commit = sys.argv[2]
+new_release_commit = sys.argv[3]
+milestone = sys.argv[4]
+milestone_json = {'milestone': milestone}
+
+# Find all commits between that commit and the current release branch
+command = "git rev-list {}..{}".format(previous_release_commit, new_release_commit)
+all_commits = subprocess.check_output(command, shell=True).decode('UTF-8')
+
+for sha in all_commits.splitlines():
+ try:
+ url = "https://api.github.com/repos/apache/incubator-druid/commits/{}/pulls".format(sha)
+ headers = {'Accept': 'application/vnd.github.groot-preview+json'}
+ pull_requests = requests.get(url, headers=headers, auth=(github_username, os.environ["GIT_TOKEN"])).json()
+
+ print("Retrieved {} pull requests associated to commit {}".format(len(pull_requests), sha))
+ for pr in pull_requests:
+ pr_number = pr['number']
+ if pr['milestone'] is None:
+ print("Tagging Pull Request {} with milestone {}".format(pr_number, milestone))
+ url = "https://api.github.com/repos/apache/incubator-druid/issues/{}".format(pr_number)
+ requests.patch(url, json=milestone_json, auth=(github_username, os.environ["GIT_TOKEN"]))
+ else:
+ print("Skipping Pull Request {} since it's already tagged with milestone {}".format(pr_number, milestone))
+
+ except Exception as e:
+ print("Got exception for commit: {} ex: {}".format(sha, e))
+ continue
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org