Updated Branches:
  refs/heads/FLUME-1787 2e227db06 -> 04fe3586e

Fix attachment order


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/04fe3586
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/04fe3586
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/04fe3586

Branch: refs/heads/FLUME-1787
Commit: 04fe3586e10ec16e2a337835cb9cdd6d2a8526eb
Parents: 2e227db
Author: Brock Noland <[email protected]>
Authored: Thu Dec 20 14:01:31 2012 -0600
Committer: Brock Noland <[email protected]>
Committed: Thu Dec 20 14:01:31 2012 -0600

----------------------------------------------------------------------
 dev-support/test-patch.py |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/04fe3586/dev-support/test-patch.py
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.py b/dev-support/test-patch.py
index 819f4a0..256c05a 100755
--- a/dev-support/test-patch.py
+++ b/dev-support/test-patch.py
@@ -86,16 +86,16 @@ def jira_post_comment(result, defect, branch, username, 
password):
     sys.exit(1)
 
 # hack (from hadoop) but REST api doesn't list attachments?
-def jira_get_attachments(result, defect, username, password):
+def jira_get_attachment(result, defect, username, password):
   html = jira_get_defect_html(result, defect, username, password)
   pattern = "(/secure/attachment/[0-9]+/%s[0-9\-]*\.(patch|txt|patch\.txt))" % 
(re.escape(defect))
-  matcher = re.findall(pattern, html, re.IGNORECASE)
-  attachments = []
-  for match in matcher:
-    attachment = "%s%s" % (BASE_JIRA_URL, match[0])
-    if attachment not in attachments:
-      attachments += [attachment]
-  return attachments
+  matches = []
+  for match in re.findall(pattern, html, re.IGNORECASE):
+    matches += [ match[0] ]
+  if matches:
+    matches.sort()
+    return  "%s%s" % (BASE_JIRA_URL, matches.pop())
+  return None
 
 def git_cleanup():
   rc = execute("git clean -d -f", False)
@@ -272,11 +272,11 @@ if defect:
   if '"Patch Available"' not in jira_json:
     print "ERROR: Defect %s not in patch available state" % (defect)
     sys.exit(1)
-  attachments = jira_get_attachments(result, defect, username, password)
-  if not attachments:
+  attachment = jira_get_attachment(result, defect, username, password)
+  if not attachment:
     print "ERROR: No attachments found for %s" % (defect)
     sys.exit(1)
-  result.attachment = attachments.pop()
+  result.attachment = attachment
   patch_contents = jira_request(result, result.attachment, username, password, 
None, {}).read()
   patch_file = "%s/%s.patch" % (output_dir, defect)
   with open(patch_file, 'a') as fh:

Reply via email to