hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject [40/50] [abbrv] hadoop git commit: HADOOP-11807. add a lint mode to releasedocmaker (ramtin via aw)
Date Mon, 27 Jul 2015 20:08:22 GMT
HADOOP-11807. add a lint mode to releasedocmaker (ramtin via aw)

(cherry picked from commit 8e657fba2fd33f7550597ea9c4c6e9a87aa1ef1c)


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

Branch: refs/heads/YARN-2928
Commit: ba9820629f2643bf90db9e79b029bf4e09a003f3
Parents: 2726910
Author: Allen Wittenauer <aw@apache.org>
Authored: Sat Jun 27 08:59:50 2015 -0700
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Mon Jul 27 12:57:37 2015 -0700

----------------------------------------------------------------------
 dev-support/releasedocmaker.py                  | 76 +++++++++++++++++---
 hadoop-common-project/hadoop-common/CHANGES.txt |  2 +
 2 files changed, 68 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba982062/dev-support/releasedocmaker.py
----------------------------------------------------------------------
diff --git a/dev-support/releasedocmaker.py b/dev-support/releasedocmaker.py
index 2ccc1c0..8e68b3c 100755
--- a/dev-support/releasedocmaker.py
+++ b/dev-support/releasedocmaker.py
@@ -87,8 +87,15 @@ def notableclean(str):
   str=str.rstrip()
   return str
 
+# clean output dir
+def cleanOutputDir(dir):
+    files = os.listdir(dir)
+    for name in files:
+        os.remove(os.path.join(dir,name))
+    os.rmdir(dir)
+
 def mstr(obj):
-  if (obj == None):
+  if (obj is None):
     return ""
   return unicode(obj)
 
@@ -148,7 +155,7 @@ class Jira:
     return mstr(self.fields['description'])
 
   def getReleaseNote(self):
-    if (self.notes == None):
+    if (self.notes is None):
       field = self.parent.fieldIdMap['Release Note']
       if (self.fields.has_key(field)):
         self.notes=mstr(self.fields[field])
@@ -159,14 +166,14 @@ class Jira:
   def getPriority(self):
     ret = ""
     pri = self.fields['priority']
-    if(pri != None):
+    if(pri is not None):
       ret = pri['name']
     return mstr(ret)
 
   def getAssignee(self):
     ret = ""
     mid = self.fields['assignee']
-    if(mid != None):
+    if(mid is not None):
       ret = mid['displayName']
     return mstr(ret)
 
@@ -182,21 +189,21 @@ class Jira:
   def getType(self):
     ret = ""
     mid = self.fields['issuetype']
-    if(mid != None):
+    if(mid is not None):
       ret = mid['name']
     return mstr(ret)
 
   def getReporter(self):
     ret = ""
     mid = self.fields['reporter']
-    if(mid != None):
+    if(mid is not None):
       ret = mid['displayName']
     return mstr(ret)
 
   def getProject(self):
     ret = ""
     mid = self.fields['project']
-    if(mid != None):
+    if(mid is not None):
       ret = mid['key']
     return mstr(ret)
 
@@ -214,7 +221,7 @@ class Jira:
     return False
 
   def getIncompatibleChange(self):
-    if (self.incompat == None):
+    if (self.incompat is None):
       field = self.parent.fieldIdMap['Hadoop Flags']
       self.reviewed=False
       self.incompat=False
@@ -227,6 +234,24 @@ class Jira:
               self.reviewed=True
     return self.incompat
 
+  def checkMissingComponent(self):
+      if (len(self.fields['components'])>0):
+          return False
+      return True
+
+  def checkMissingAssignee(self):
+      if (self.fields['assignee'] is not None):
+          return False
+      return True
+
+  def checkVersionString(self):
+      field = self.parent.fieldIdMap['Fix Version/s']
+      for h in self.fields[field]:
+          found = re.match('^((\d+)(\.\d+)*).*$|^(\w+\-\d+)$', h['name'])
+          if not found:
+              return True
+      return False
+
   def getReleaseDate(self,version):
     for j in range(len(self.fields['fixVersions'])):
       if self.fields['fixVersions'][j]==version:
@@ -339,9 +364,11 @@ def main():
              help="build an index file")
   parser.add_option("-u","--usetoday", dest="usetoday", action="store_true",
              help="use current date for unreleased versions")
+  parser.add_option("-n","--lint", dest="lint", action="store_true",
+             help="use lint flag to exit on failures")
   (options, args) = parser.parse_args()
 
-  if (options.versions == None):
+  if (options.versions is None):
     options.versions = []
 
   if (len(args) > 2):
@@ -396,6 +423,9 @@ def main():
   reloutputs.writeAll(relhead)
   choutputs.writeAll(chhead)
 
+  errorCount=0
+  warningCount=0
+  lintMessage=""
   incompatlist=[]
   buglist=[]
   improvementlist=[]
@@ -408,6 +438,14 @@ def main():
   for jira in sorted(jlist):
     if jira.getIncompatibleChange():
       incompatlist.append(jira)
+      if (len(jira.getReleaseNote())==0):
+          warningCount+=1
+
+    if jira.checkVersionString():
+       warningCount+=1
+
+    if jira.checkMissingComponent() or jira.checkMissingAssignee():
+      errorCount+=1
     elif jira.getType() == "Bug":
       buglist.append(jira)
     elif jira.getType() == "Improvement":
@@ -431,15 +469,33 @@ def main():
       reloutputs.writeKeyRaw(jira.getProject(),"\n---\n\n")
       reloutputs.writeKeyRaw(jira.getProject(), line)
       line ='\n**WARNING: No release note provided for this incompatible change.**\n\n'
-      print 'WARNING: incompatible change %s lacks release notes.' % (notableclean(jira.getId()))
+      lintMessage += "\nWARNING: incompatible change %s lacks release notes." % (notableclean(jira.getId()))
       reloutputs.writeKeyRaw(jira.getProject(), line)
 
+    if jira.checkVersionString():
+        lintMessage += "\nWARNING: Version string problem for %s " % jira.getId()
+
+    if (jira.checkMissingComponent() or jira.checkMissingAssignee()):
+        errorMessage=[]
+        jira.checkMissingComponent() and errorMessage.append("component")
+        jira.checkMissingAssignee() and errorMessage.append("assignee")
+        lintMessage += "\nERROR: missing %s for %s " %  (" and ".join(errorMessage) , jira.getId())
+
     if (len(jira.getReleaseNote())>0):
       reloutputs.writeKeyRaw(jira.getProject(),"\n---\n\n")
       reloutputs.writeKeyRaw(jira.getProject(), line)
       line ='\n%s\n\n' % (tableclean(jira.getReleaseNote()))
       reloutputs.writeKeyRaw(jira.getProject(), line)
 
+  if (options.lint is True):
+      print lintMessage
+      print "======================================="
+      print "Error:%d, Warning:%d \n" % (errorCount, warningCount)
+
+      if (errorCount>0):
+          cleanOutputDir(version)
+          sys.exit(1)
+
   reloutputs.writeAll("\n\n")
   reloutputs.close()
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba982062/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 0da6194..baf39e3 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -730,6 +730,8 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12170. hadoop-common's JNIFlags.cmake is redundant and can be
     removed (Alan Burlison via Colin P. McCabe)
 
+    HADOOP-11807. add a lint mode to releasedocmaker (ramtin via aw)
+
   OPTIMIZATIONS
 
     HADOOP-11785. Reduce the number of listStatus operation in distcp


Mime
View raw message