You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by jl...@apache.org on 2016/06/03 22:27:06 UTC
[1/3] incubator-airflow git commit: [AIRFLOW-207] Improve JIRA auth
workflow
Repository: incubator-airflow
Updated Branches:
refs/heads/master 89edb6fff -> 0535d1714
[AIRFLOW-207] Improve JIRA auth workflow
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/5ccf2242
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/5ccf2242
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/5ccf2242
Branch: refs/heads/master
Commit: 5ccf2242f5966b5e2f45a26327406f8467c998a9
Parents: f72b0d3
Author: jlowin <jl...@users.noreply.github.com>
Authored: Thu Jun 2 12:57:26 2016 -0400
Committer: jlowin <jl...@users.noreply.github.com>
Committed: Thu Jun 2 12:57:26 2016 -0400
----------------------------------------------------------------------
dev/README.md | 2 +-
dev/airflow-pr | 68 ++++++++++++++++++++++++++++++++---------------------
2 files changed, 42 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5ccf2242/dev/README.md
----------------------------------------------------------------------
diff --git a/dev/README.md b/dev/README.md
index cab550e..68ff62d 100755
--- a/dev/README.md
+++ b/dev/README.md
@@ -72,7 +72,7 @@ origin https://github.com/<USER>/airflow (push)
```
#### JIRA
-Users should set environment variables `JIRA_USERNAME` and `JIRA_PASSWORD` corresponding to their ASF JIRA login. This will allow the tool to automatically close issues.
+Users should set environment variables `JIRA_USERNAME` and `JIRA_PASSWORD` corresponding to their ASF JIRA login. This will allow the tool to automatically close issues. If they are not set, the user will be prompted every time.
#### GitHub OAuth Token
Unauthenticated users can only make 60 requests/hour to the Github API. If you get an error about exceeding the rate, you will need to set a `GITHUB_OAUTH_KEY` environment variable that contains a token value. Users can generate tokens from their GitHub profile.
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5ccf2242/dev/airflow-pr
----------------------------------------------------------------------
diff --git a/dev/airflow-pr b/dev/airflow-pr
index 0ff64ec..ced236e 100755
--- a/dev/airflow-pr
+++ b/dev/airflow-pr
@@ -46,12 +46,6 @@ if sys.version_info[0] == 3:
raw_input = input
try:
- import jira.client
- JIRA_IMPORTED = True
-except ImportError:
- JIRA_IMPORTED = False
-
-try:
import click
except ImportError:
print("Could not find the click library. Run 'sudo pip install click' to install.")
@@ -63,10 +57,6 @@ AIRFLOW_GIT_LOCATION = os.environ.get("AIRFLOW_GIT", os.getcwd())
GITHUB_REMOTE_NAME = os.environ.get("GITHUB_REMOTE_NAME", "github")
# Remote name which points to Apache git
APACHE_REMOTE_NAME = os.environ.get("APACHE_REMOTE_NAME", "apache")
-# ASF JIRA username
-JIRA_USERNAME = os.environ.get("JIRA_USERNAME", "")
-# ASF JIRA password
-JIRA_PASSWORD = os.environ.get("JIRA_PASSWORD", "")
# OAuth key used for issuing requests against the GitHub API. If this is not defined, then requests
# will be unauthenticated. You should only need to configure this if you find yourself regularly
# exceeding your IP's unauthenticated request rate limit. You can create an OAuth key at
@@ -405,21 +395,41 @@ def resolve_jira_issue(comment=None, jira_id=None, merge_branches=None):
jira_id: an Airflow JIRA id, either an integer or a string with the form
AIRFLOW-X. If not provided, the user will be prompted to provide one.
"""
- if merge_branches is None:
- merge_branches = []
-
- if JIRA_IMPORTED:
- if not JIRA_USERNAME and not JIRA_PASSWORD:
- raise PRToolError(
- "JIRA_USERNAME and JIRA_PASSWORD not set; exiting.")
- else:
+ try:
+ import jira.client
+ except ImportError:
raise PRToolError(
"Could not find jira-python library; exiting. Run "
"'sudo pip install jira' to install.")
- asf_jira = jira.client.JIRA(
- {'server': JIRA_API_BASE},
- basic_auth=(JIRA_USERNAME, JIRA_PASSWORD))
+ if merge_branches is None:
+ merge_branches = []
+
+ # ASF JIRA username
+ JIRA_USERNAME = os.environ.get("JIRA_USERNAME", "")
+ # ASF JIRA password
+ JIRA_PASSWORD = os.environ.get("JIRA_PASSWORD", "")
+
+ if not JIRA_USERNAME:
+ JIRA_USERNAME = click.prompt(
+ click.style('Username for Airflow JIRA', fg='blue', bold=True),
+ type=str)
+ click.echo(
+ 'Set the JIRA_USERNAME env var to avoid this prompt in the future.')
+ if not JIRA_PASSWORD:
+ JIRA_PASSWORD = click.prompt(
+ click.style('Password for Airflow JIRA', fg='blue', bold=True),
+ type=str,
+ hide_input=True)
+ click.echo(
+ 'Set the JIRA_PASSWORD env var to avoid this prompt in the future.')
+
+ try:
+ asf_jira = jira.client.JIRA(
+ {'server': JIRA_API_BASE},
+ basic_auth=(JIRA_USERNAME, JIRA_PASSWORD))
+ except:
+ raise ValueError('Could not log in to JIRA!')
if jira_id is None:
jira_id = click.prompt(click.style(
@@ -618,10 +628,12 @@ def main(pr_num, local=False):
Apache git remote name (defaults to "apache")
- JIRA_USERNAME
- ASF JIRA username. Required to automatically close JIRA issues
+ ASF JIRA username for automatically closing JIRA issues. Users will be
+ prompted if it is not set.
- JIRA_PASSWORD
- ASF JIRA password. Required to automatically close JIRA issues
+ ASF JIRA password for automatically closing JIRA issues. Users will be
+ prompted if it is not set.
- GITHUB_OAUTH_KEY
Only required if you are exceeding the rate limit for a single IP
@@ -719,8 +731,8 @@ def main(pr_num, local=False):
if local:
return
- pick_prompt = "Would you like to pick %s into another branch?" % merge_hash
- while click.confirm(click.style("pick_prompt", fg='blue', bold=True)):
+ msg = "Would you like to pick {} into another branch?".format(merge_hash)
+ while click.confirm(click.style(msg, fg='blue', bold=True)):
merged_refs = merged_refs + [cherry_pick(pr_num, merge_hash, latest_branch)]
continue_maybe("Would you like to update associated JIRA issues?")
@@ -787,10 +799,12 @@ def merge(pr_num):
Apache git remote name (defaults to "apache")
- JIRA_USERNAME
- ASF JIRA username. Required to automatically close JIRA issues
+ ASF JIRA username for automatically closing JIRA issues. Users will be
+ prompted if it is not set.
- JIRA_PASSWORD
- ASF JIRA password. Required to automatically close JIRA issues
+ ASF JIRA password for automatically closing JIRA issues. Users will be
+ prompted if it is not set.
- GITHUB_OAUTH_KEY
Only required if you are exceeding the rate limit for a single IP
[3/3] incubator-airflow git commit: Merge pull request #1567 from
jlowin/pr-tool-7
Posted by jl...@apache.org.
Merge pull request #1567 from jlowin/pr-tool-7
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/0535d171
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/0535d171
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/0535d171
Branch: refs/heads/master
Commit: 0535d17140f63409b1beea06f88b3e198c0fdb95
Parents: 89edb6f 2ce8ff5
Author: jlowin <jl...@users.noreply.github.com>
Authored: Fri Jun 3 18:26:59 2016 -0400
Committer: jlowin <jl...@users.noreply.github.com>
Committed: Fri Jun 3 18:26:59 2016 -0400
----------------------------------------------------------------------
dev/README.md | 2 +-
dev/airflow-pr | 136 +++++++++++++++++++++++++++++-----------------------
2 files changed, 78 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
[2/3] incubator-airflow git commit: [AIRFLOW-187] Improve PR Tool UX
Posted by jl...@apache.org.
[AIRFLOW-187] Improve PR Tool UX
Improved styling for PR tool prompts
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/2ce8ff56
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/2ce8ff56
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/2ce8ff56
Branch: refs/heads/master
Commit: 2ce8ff565071ff8b69a61ce0e78024305f6bf0d7
Parents: 5ccf224
Author: jlowin <jl...@users.noreply.github.com>
Authored: Fri Jun 3 16:40:45 2016 -0400
Committer: jlowin <jl...@users.noreply.github.com>
Committed: Fri Jun 3 16:44:34 2016 -0400
----------------------------------------------------------------------
dev/airflow-pr | 68 ++++++++++++++++++++++++++++-------------------------
1 file changed, 36 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2ce8ff56/dev/airflow-pr
----------------------------------------------------------------------
diff --git a/dev/airflow-pr b/dev/airflow-pr
index ced236e..f098fb8 100755
--- a/dev/airflow-pr
+++ b/dev/airflow-pr
@@ -108,11 +108,11 @@ def run_cmd(cmd, echo_cmd=True):
if isinstance(cmd, list):
if echo_cmd:
click.echo('>> Running command: {}'.format(' '.join(cmd)))
- return subprocess.check_output(cmd).decode('utf-8')
+ return subprocess.check_output(cmd).decode('utf-8').strip()
else:
if echo_cmd:
click.echo('>> Running command: {}'.format(cmd))
- return subprocess.check_output(cmd.split(" ")).decode('utf-8')
+ return subprocess.check_output(cmd.split(" ")).decode('utf-8').strip()
def continue_maybe(prompt):
@@ -183,8 +183,9 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, local):
merge_message_flags = []
if squash:
- commit_authors = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name,
- '--pretty=format:%an <%ae>']).split("\n")
+ commit_authors = run_cmd(
+ ['git', 'log', 'HEAD..{}'.format(pr_branch_name),
+ '--pretty=format:%an <%ae>'], echo_cmd=False).split("\n")
distinct_authors = sorted(
set(commit_authors),
key=lambda x: commit_authors.count(x),
@@ -197,8 +198,9 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, local):
if primary_author == "":
primary_author = distinct_authors[0]
- commits = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name,
- '--pretty=format:%h [%an] %s']).split("\n\n")
+ commits = run_cmd(
+ ['git', 'log', 'HEAD..%s' % pr_branch_name,
+ '--pretty=format:%h [%an] %s'], echo_cmd=False).split("\n\n")
# -- set authors and add authors to commit message
authors = "\n".join(["Author: %s" % a for a in distinct_authors])
@@ -208,7 +210,8 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, local):
# -- Add PR to commit message
merge_message_flags.extend(["-m", title])
msg = click.style(
- 'Would you like include the PR body in the squash commit message?',
+ 'Would you like to include the PR body in the squash '
+ 'commit message?',
fg='blue', bold=True)
if body and click.confirm(msg, default=False, prompt_suffix=''):
# We remove @ symbols from the body to avoid triggering e-mails
@@ -217,10 +220,13 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, local):
if had_conflicts:
- committer_name = run_cmd("git config --get user.name").strip()
- committer_email = run_cmd("git config --get user.email").strip()
- message = "This patch had conflicts when merged, resolved by\nCommitter: %s <%s>" % (
- committer_name, committer_email)
+ committer_name = run_cmd(
+ "git config --get user.name", echo_cmd=False)
+ committer_email = run_cmd(
+ "git config --get user.email", echo_cmd=False)
+ message = (
+ 'This patch had conflicts when merged, resolved by '
+ 'Committer: %s <%s>' % (committer_name, committer_email))
merge_message_flags.extend(["-m", message])
# The string "Closes #%s" string is required for GitHub to correctly
@@ -248,17 +254,14 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, local):
# -- ask user to edit commit message
click.echo(click.style('\n=== Current Squash Commit ===', bold=True))
click.echo(run_cmd('git log -1 --pretty=%B', echo_cmd=False))
+ click.echo(click.style('=== End of Squash Commit ===\n', bold=True))
msg = (
- 'If you would like to edit the commit message, open a new\n'
+ 'If you would like to edit the commit message, open a new '
'terminal and run:\n\n'
' git commit --amend\n\n'
- 'When you have finished, return here and press any key to \n'
+ 'When you have finished, return here and press any key to '
'continue.')
- click.prompt(
- click.style(msg, fg='blue', bold=True),
- prompt_suffix='',
- default='ok',
- show_default=False)
+ click.pause(click.style(msg, fg='blue', bold=True))
if local:
msg =(
@@ -267,11 +270,7 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, local):
'you are finished, press any key to delete the PR branch and\n'
'restore your original environment.'.format(target_branch_name))
- click.prompt(
- click.style(msg, fg='blue', bold=True),
- prompt_suffix='',
- default='ok',
- show_default=False)
+ click.pause(click.style(msg, fg='blue', bold=True))
clean_up()
return
@@ -467,7 +466,7 @@ def resolve_jira_issue(comment=None, jira_id=None, merge_branches=None):
fail("JIRA issue %s already has status '%s'" % (jira_id, cur_status))
click.echo(click.style("\n === JIRA %s ===" % jira_id, bold=True))
- click.echo("summary:\t\t%s\nassignee:\t%s\nstatus:\t\t%s\nurl:\t\t%s/%s\n" % (
+ click.echo("summary:\t%s\nassignee:\t%s\nstatus:\t\t%s\nurl:\t\t%s/%s\n" % (
cur_summary, cur_assignee, cur_status, JIRA_BASE, jira_id))
continue_maybe('Proceed with AIRFLOW-{}?'.format(jira_id))
@@ -521,20 +520,25 @@ def resolve_jira_issue(comment=None, jira_id=None, merge_branches=None):
else:
jira_fix_versions = None
- resolve = list(filter(
- lambda a: a['name'] == "Resolve Issue",
+ resolved = click.confirm(click.style(
+ 'Do you want to mark {} as "resolved" instead '
+ 'of "closed"?'.format(jira_id),
+ fg='blue', bold=True))
+ action = list(filter(
+ lambda a: a['name'] == 'Resolve Issue' if resolved else 'Close Issue',
asf_jira.transitions(jira_id)))[0]
resolution = list(filter(
lambda r: r.raw['name'] == "Fixed",
asf_jira.resolutions()))[0]
asf_jira.transition_issue(
jira_id,
- resolve["id"],
+ action["id"],
fixVersions=jira_fix_versions,
comment=comment,
resolution = {'id': resolution.raw['id']})
- click.echo("Successfully resolved {id}{fv}!".format(
+ click.echo("Successfully {action} {id}{fv}!".format(
+ action='resolved' if resolved else 'closed',
id=jira_id,
fv=' with fix versions={}'.format(fix_versions) if fix_versions else ''))
@@ -599,10 +603,10 @@ def standardize_jira_ref(text):
def get_current_ref():
- ref = run_cmd("git rev-parse --abbrev-ref HEAD").strip()
+ ref = run_cmd("git rev-parse --abbrev-ref HEAD")
if ref == 'HEAD':
# The current ref is a detached HEAD, so grab its SHA.
- return run_cmd("git rev-parse HEAD").strip()
+ return run_cmd("git rev-parse HEAD")
else:
return ref
@@ -705,8 +709,8 @@ def main(pr_num, local=False):
continue_maybe(
"Pull request %s has already been merged. Do you want to backport?" % pr_num)
- commit_is_downloaded = run_cmd(['git', 'rev-parse', '--quiet', '--verify',
- "%s^{commit}" % merge_hash]).strip() != ""
+ commit_is_downloaded = run_cmd(
+ ['git', 'rev-parse', '--quiet', '--verify', "%s^{commit}" % merge_hash]) != ""
if not commit_is_downloaded:
fail("Couldn't find any merge commit for #%s, you may need to update HEAD." % pr_num)