This is an automated email from the ASF dual-hosted git repository.
pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git
The following commit(s) were added to refs/heads/master by this push:
new ff1b958 SUBMARINE-1014. Restore merge_submarine_pr.py file (#738)
ff1b958 is described below
commit ff1b958d47df3675228bf504217e5aaead825bcb
Author: KUAN-HSUN-LI <[email protected]>
AuthorDate: Wed Sep 8 23:47:50 2021 +0800
SUBMARINE-1014. Restore merge_submarine_pr.py file (#738)
---
.flake8 | 3 +-
dev-support/cicd/merge_submarine_pr.py | 66 ++++++++++++++++------------------
2 files changed, 32 insertions(+), 37 deletions(-)
diff --git a/.flake8 b/.flake8
index b916a3e..0459d36 100644
--- a/.flake8
+++ b/.flake8
@@ -16,4 +16,5 @@
#
[flake8]
-max-line-length = 100
\ No newline at end of file
+max-line-length = 100
+exclude = dev-support/cicd
\ No newline at end of file
diff --git a/dev-support/cicd/merge_submarine_pr.py
b/dev-support/cicd/merge_submarine_pr.py
index 7f5d1c4..37877f3 100755
--- a/dev-support/cicd/merge_submarine_pr.py
+++ b/dev-support/cicd/merge_submarine_pr.py
@@ -63,19 +63,19 @@ os.chdir(SUBMARINE_HOME)
def get_json(url):
try:
return json.load(urllib2.urlopen(url))
- except urllib2.HTTPError:
- print("Unable to fetch URL, exiting: %s" % url)
+ except urllib2.HTTPError as e:
+ print "Unable to fetch URL, exiting: %s" % url
sys.exit(-1)
def fail(msg):
- print(msg)
+ print msg
clean_up()
sys.exit(-1)
def run_cmd(cmd):
- print(cmd)
+ print cmd
if isinstance(cmd, list):
return subprocess.check_output(cmd)
else:
@@ -83,7 +83,7 @@ def run_cmd(cmd):
def continue_maybe(prompt):
- result = input("\n%s (y/n): " % prompt)
+ result = raw_input("\n%s (y/n): " % prompt)
if result.lower() != "y":
fail("Okay, exiting")
@@ -92,13 +92,13 @@ original_head = run_cmd("git rev-parse HEAD")[:8]
def clean_up():
- print("Restoring head pointer to %s" % original_head)
+ print "Restoring head pointer to %s" % original_head
run_cmd("git checkout %s" % original_head)
branches = run_cmd("git branch").replace(" ", "").split("\n")
for branch in filter(lambda x: x.startswith(BRANCH_PREFIX), branches):
- print("Deleting local branch %s" % branch)
+ print "Deleting local branch %s" % branch
run_cmd("git branch -D %s" % branch)
@@ -138,7 +138,7 @@ def merge_pr(pr_num, target_ref):
if body is not None:
# We remove @ symbols from the body to avoid triggering e-mails
# to people every time someone creates a public fork of Submarine.
- if isinstance(body, re.UNICODE):
+ if isinstance(body, unicode):
merge_message_flags += ["-m", body.encode("utf-8").replace("@",
"")]
else:
merge_message_flags += ["-m", body.replace("@", "")]
@@ -186,13 +186,13 @@ def merge_pr(pr_num, target_ref):
merge_hash = run_cmd("git rev-parse %s" % target_branch_name)[:8]
clean_up()
- print("Pull request #%s merged!" % pr_num)
- print("Merge hash: %s" % merge_hash)
+ print ("Pull request #%s merged!" % pr_num)
+ print ("Merge hash: %s" % merge_hash)
return merge_hash
def cherry_pick(pr_num, merge_hash, default_branch):
- pick_ref = input("Enter a branch name [%s]: " % default_branch)
+ pick_ref = raw_input("Enter a branch name [%s]: " % default_branch)
if pick_ref == "":
pick_ref = default_branch
@@ -222,8 +222,8 @@ def cherry_pick(pr_num, merge_hash, default_branch):
pick_hash = run_cmd("git rev-parse %s" % pick_branch_name)[:8]
clean_up()
- print("Pull request #%s picked into %s!" % (pr_num, pick_ref))
- print("Pick hash: %s" % pick_hash)
+ print ("Pull request #%s picked into %s!" % (pr_num, pick_ref))
+ print ("Pick hash: %s" % pick_hash)
return pick_ref
@@ -241,7 +241,7 @@ def resolve_jira_issue(merge_branches, comment,
default_jira_id=""):
{"server": JIRA_API_BASE}, basic_auth=(JIRA_USERNAME, JIRA_PASSWORD)
)
- jira_id = input("Enter a JIRA id [%s]: " % default_jira_id)
+ jira_id = raw_input("Enter a JIRA id [%s]: " % default_jira_id)
if jira_id == "":
jira_id = default_jira_id
@@ -260,23 +260,17 @@ def resolve_jira_issue(merge_branches, comment,
default_jira_id=""):
if cur_status == "Resolved" or cur_status == "Closed":
fail("JIRA issue %s already has status '%s'" % (jira_id, cur_status))
- print("=== JIRA %s ===" % jira_id)
- print(
+ print ("=== JIRA %s ===" % jira_id)
+ print (
"summary\t\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,
- )
+ % (cur_summary, cur_assignee, cur_status, JIRA_BASE, jira_id)
)
versions = asf_jira.project_versions("SUBMARINE")
versions = sorted(versions, key=lambda x: x.name, reverse=True)
versions = filter(lambda x: x.raw["released"] is False, versions)
# Consider only x.y.z versions
- versions = filter(lambda x: re.match(r"\d+\.\d+\.\d+", x.name), versions)
+ versions = filter(lambda x: re.match("\d+\.\d+\.\d+", x.name), versions)
default_fix_versions = map(lambda x: fix_version_from_branch(x,
versions).name, merge_branches)
for v in default_fix_versions:
@@ -291,7 +285,7 @@ def resolve_jira_issue(merge_branches, comment,
default_jira_id=""):
default_fix_versions = filter(lambda x: x != v,
default_fix_versions)
default_fix_versions = ",".join(default_fix_versions)
- fix_versions = input("Enter comma-separated fix version(s) [%s]: " %
default_fix_versions)
+ fix_versions = raw_input("Enter comma-separated fix version(s) [%s]: " %
default_fix_versions)
if fix_versions == "":
fix_versions = default_fix_versions
fix_versions = fix_versions.replace(" ", "").split(",")
@@ -306,7 +300,7 @@ def resolve_jira_issue(merge_branches, comment,
default_jira_id=""):
jira_id, resolve["id"], fixVersions=jira_fix_versions, comment=comment
)
- print("Successfully resolved %s with fixVersions=%s!" % (jira_id,
fix_versions))
+ print "Successfully resolved %s with fixVersions=%s!" % (jira_id,
fix_versions)
def resolve_jira_issues(title, merge_branches, comment):
@@ -324,7 +318,7 @@ def resolve_jira_issues(title, merge_branches, comment):
# latest_branch = sorted(branch_names, reverse=True)[0]
latest_branch = "master"
-pr_num = input("Which pull request would you like to merge? (e.g. 23): ")
+pr_num = raw_input("Which pull request would you like to merge? (e.g. 23): ")
pr = get_json("%s/pulls/%s" % (GITHUB_API_BASE, pr_num))
pr_events = get_json("%s/issues/%s/events" % (GITHUB_API_BASE, pr_num))
@@ -344,7 +338,7 @@ if merge_commits:
merge_hash = merge_commits[0]["commit_id"]
message = get_json("%s/commits/%s" % (GITHUB_API_BASE,
merge_hash))["commit"]["message"]
- print("Pull request %s has already been merged, assuming you want to
backport" % pr_num)
+ print "Pull request %s has already been merged, assuming you want to
backport" % pr_num
commit_is_downloaded = (
run_cmd(["git", "rev-parse", "--quiet", "--verify", "%s^{commit}" %
merge_hash]).strip()
!= ""
@@ -352,7 +346,7 @@ if merge_commits:
if not commit_is_downloaded:
fail("Couldn't find any merge commit for #%s, you may need to update
HEAD." % pr_num)
- print("Found commit %s:\n%s" % (merge_hash, message))
+ print "Found commit %s:\n%s" % (merge_hash, message)
cherry_pick(pr_num, merge_hash, latest_branch)
sys.exit(0)
@@ -363,8 +357,8 @@ if not bool(pr["mergeable"]):
)
continue_maybe(msg)
-print("\n=== Pull Request #%s ===" % pr_num)
-print("title\t%s\nsource\t%s\ntarget\t%s\nurl\t%s" % (title, pr_repo_desc,
target_ref, url))
+print ("\n=== Pull Request #%s ===" % pr_num)
+print ("title\t%s\nsource\t%s\ntarget\t%s\nurl\t%s" % (title, pr_repo_desc,
target_ref, url))
continue_maybe("Proceed with merging pull request #%s?" % pr_num)
merged_refs = [target_ref]
@@ -372,7 +366,7 @@ merged_refs = [target_ref]
merge_hash = merge_pr(pr_num, target_ref)
pick_prompt = "Would you like to pick %s into another branch?" % merge_hash
-while input("\n%s (y/n): " % pick_prompt).lower() == "y":
+while raw_input("\n%s (y/n): " % pick_prompt).lower() == "y":
merged_refs = merged_refs + [cherry_pick(pr_num, merge_hash,
latest_branch)]
if JIRA_IMPORTED:
@@ -381,8 +375,8 @@ if JIRA_IMPORTED:
jira_comment = "Issue resolved by pull request %s\n[%s/%s]" % (pr_num,
GITHUB_BASE, pr_num)
resolve_jira_issues(title, merged_refs, jira_comment)
else:
- print("JIRA_USERNAME and JIRA_PASSWORD not set")
- print("Exiting without trying to close the associated JIRA.")
+ print "JIRA_USERNAME and JIRA_PASSWORD not set"
+ print "Exiting without trying to close the associated JIRA."
else:
- print("Could not find jira library. Run 'sudo pip install jira' to
install.")
- print("Exiting without trying to close the associated JIRA.")
+ print "Could not find jira library. Run 'sudo pip install jira' to
install."
+ print "Exiting without trying to close the associated JIRA."
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]