Browse Source

HADOOP-9011. saveVersion.py does not include branch in version annotation. Contributed by Chris Nauroth.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-trunk-win@1408994 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 12 years ago
parent
commit
9ba1c253fb

+ 8 - 4
dev-support/saveVersion.py

@@ -39,7 +39,7 @@ template_string = \
 '''/*
  * Generated by saveVersion.py
  */
-%s(version="%s", revision="%s",
+%s(version="%s", revision="%s", branch="%s",
   user="%s", date="%s", url="%s",
   srcChecksum="%s")
 package %s;
@@ -108,8 +108,8 @@ def main(argv=None):
     branch = subprocessOutput(['git', 'branch'])
 
     filter_current_branch = re.compile(r'^\* (.*)$', re.MULTILINE)
-    current_branch = filter_current_branch.search(branch).group(1).strip()
-    url = "%s on branch %s" % (origin, current_branch)
+    branch = filter_current_branch.search(branch).group(1).strip()
+    url = "%s on branch %s" % (origin, branch)
   else:
     svn_info = subprocessOutput(['svn', 'info'])
     filter_last_revision = re.compile(r'^Last Changed Rev: (.*)$', re.MULTILINE)
@@ -118,6 +118,10 @@ def main(argv=None):
     filter_url = re.compile(r'^URL: (.*)$', re.MULTILINE)
     url = filter_url.search(svn_info).group(1).strip()
 
+    # Get canonical branch (branches/X, tags/X, or trunk)
+    filter_current_branch = re.compile(r'.*((branches/.*$)|(tags/.*$)|.*(trunk)$)')
+    branch = filter_current_branch.search(url).group(1).strip()
+
   filter_java = re.compile(r'.+\.java$')
   file_list = []
   for root, dirs, files in os.walk(os.path.normpath(src_checksum_root_dir)):
@@ -143,7 +147,7 @@ def main(argv=None):
 
   target_file = os.path.join(target_dir, 'package-info.java')
   fout = open(target_file, "w")
-  fout.write(template_string % (annotation, version, revision, user, date, url, srcChecksum, package))
+  fout.write(template_string % (annotation, version, revision, branch, user, date, url, srcChecksum, package))
   fout.close()
 
   print("Checksummed %s src/**.java files" % file_count)

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.branch-trunk-win.txt

@@ -53,3 +53,6 @@ branch-trunk-win changes - unreleased
 
   HADOOP-9008. Building hadoop tarball fails on Windows. (Chris Nauroth via
   suresh)
+
+  HADOOP-9011. saveVersion.py does not include branch in version annotation.
+  (Chris Nauroth via suresh)