You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/08/08 16:37:57 UTC
[arrow] branch master updated: ARROW-6121: [Tools] Improve merge
tool ergonomics
This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 9b3e692 ARROW-6121: [Tools] Improve merge tool ergonomics
9b3e692 is described below
commit 9b3e6927e6657261f4e07d227b1f93f57284997f
Author: François Saint-Jacques <fs...@gmail.com>
AuthorDate: Thu Aug 8 11:37:48 2019 -0500
ARROW-6121: [Tools] Improve merge tool ergonomics
- merge_arrow_pr.py now accepts the pull-request number as a single optional argument, e.g. `./merge_arrow_pr.py 4921`.
- merge_arrow_pr.py can optionally read a configuration file located in `~/.config/arrow/merge.conf` which contains options like jira credentials. See the `dev/merge.conf` file as example
Closes #5000 from fsaintjacques/ARROW-6121-merge-ergonomic and squashes the following commits:
5298308d7 <Wes McKinney> Handle username/password separately (in case username is set but not password)
581653735 <François Saint-Jacques> Rename merge.conf to merge.conf.sample
7c51ca8f0 <François Saint-Jacques> Add license to config file
1213946bd <François Saint-Jacques> ARROW-6121: Improve merge tool ergonomics
Lead-authored-by: François Saint-Jacques <fs...@gmail.com>
Co-authored-by: Wes McKinney <we...@apache.org>
Signed-off-by: Wes McKinney <we...@apache.org>
---
dev/merge.conf.sample | 25 ++++++++++++++++++++++
dev/merge_arrow_pr.py | 57 ++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 68 insertions(+), 14 deletions(-)
diff --git a/dev/merge.conf.sample b/dev/merge.conf.sample
new file mode 100644
index 0000000..c71b211
--- /dev/null
+++ b/dev/merge.conf.sample
@@ -0,0 +1,25 @@
+# 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.
+
+# Configuration for the merge_arrow_pr.py tool
+# Install a copy of this file at ~/.config/arrow/merge.conf
+
+[jira]
+# issues.apache.org JIRA credentials. Sadly, the jira instance doesn't offer
+# token credentials. Ensure that the file is properly protected.
+username=johnsmith
+password=123456
diff --git a/dev/merge_arrow_pr.py b/dev/merge_arrow_pr.py
index 623e335..dfe9e33 100755
--- a/dev/merge_arrow_pr.py
+++ b/dev/merge_arrow_pr.py
@@ -33,6 +33,7 @@
# ARROW_GITHUB_API_TOKEN: a GitHub API token to use for API requests (to avoid
# rate limiting)
+import configparser
import os
import pprint
import re
@@ -460,24 +461,52 @@ def prompt_for_fix_version(cmd, jira_issue):
return [get_version_json(v) for v in issue_fix_versions]
-def connect_jira(cmd):
- # ASF JIRA username
- jira_username = os.environ.get("APACHE_JIRA_USERNAME")
+CONFIG_FILE = "~/.config/arrow/merge.conf"
+
+
+def load_configuration():
+ config = configparser.ConfigParser()
+ config.read(os.path.expanduser(CONFIG_FILE))
+ return config
+
+
+def get_credentials(cmd):
+ username, password = None, None
+
+ config = load_configuration()
+ if "jira" in config.sections():
+ username = config["jira"].get("username")
+ password = config["jira"].get("password")
+
+ # Fallback to environment variables
+ if not username:
+ username = os.environ.get("APACHE_JIRA_USERNAME")
- # ASF JIRA password
- jira_password = os.environ.get("APACHE_JIRA_PASSWORD")
+ if not password:
+ password = os.environ.get("APACHE_JIRA_PASSWORD")
- if not jira_username:
- jira_username = cmd.prompt("Env APACHE_JIRA_USERNAME not set, "
- "please enter your JIRA username:")
+ # Fallback to user tty prompt
+ if not username:
+ username = cmd.prompt("Env APACHE_JIRA_USERNAME not set, "
+ "please enter your JIRA username:")
- if not jira_password:
- jira_password = cmd.getpass("Env APACHE_JIRA_PASSWORD not set, "
- "please enter "
- "your JIRA password:")
+ if not password:
+ password = cmd.getpass("Env APACHE_JIRA_PASSWORD not set, "
+ "please enter your JIRA password:")
+ return (username, password)
+
+
+def connect_jira(cmd):
return jira.client.JIRA({'server': JIRA_API_BASE},
- basic_auth=(jira_username, jira_password))
+ basic_auth=get_credentials(cmd))
+
+
+def get_pr_num():
+ if len(sys.argv) == 2:
+ return sys.argv[1]
+
+ return input("Which pull request would you like to merge? (e.g. 34): ")
def cli():
@@ -489,7 +518,7 @@ def cli():
cmd = CommandInput()
- pr_num = input("Which pull request would you like to merge? (e.g. 34): ")
+ pr_num = get_pr_num()
os.chdir(ARROW_HOME)