Skip to content

Apache DataFusion SQL Query Engine

ARROW-6121: [Tools] Improve merge tool ergonomics

François Saint-Jacques02c1a8e9b670
diff --git a/dev/merge.conf.sample b/dev/merge.conf.sample
new file mode 100644
index 0000000000..c71b211614
--- /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 623e3352ae..dfe9e337b1 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)