]> git.proxmox.com Git - mirror_edk2.git/commitdiff
PatchCheck - add error message for invalid parameter
authorJaben Carsey <jaben.carsey@intel.com>
Thu, 2 Aug 2018 23:21:06 +0000 (07:21 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 8 Aug 2018 03:41:28 +0000 (11:41 +0800)
Currently if an invalid parameter is passed, it gives a stack trace.
This changes it to an error message.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Tested-by: Liming Gao <liming.gao@intel.com>
BaseTools/Scripts/PatchCheck.py

index 7b7fba8b70445177aa1100b9ffb74b54cd2c0c9f..96b3cdf1fd8a52d1e39b185c11196cb623b96648 100755 (executable)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Check a patch for various format issues\r
 #\r
-#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials are licensed and made\r
 #  available under the terms and conditions of the BSD License which\r
@@ -528,6 +528,8 @@ class CheckGitCommits:
                 print('Checking git commit:', commit)\r
             patch = self.read_patch_from_git(commit)\r
             self.ok &= CheckOnePatch(commit, patch).ok\r
+        if not commits:\r
+            print("Couldn't find commit matching: '{}'".format(rev_spec))\r
 \r
     def read_commit_list_from_git(self, rev_spec, max_count):\r
         # Run git to get the commit patch\r
@@ -536,7 +538,7 @@ class CheckGitCommits:
             cmd.append('--max-count=' + str(max_count))\r
         cmd.append(rev_spec)\r
         out = self.run_git(*cmd)\r
-        return out.split()\r
+        return out.split() if out else []\r
 \r
     def read_patch_from_git(self, commit):\r
         # Run git to get the commit patch\r
@@ -548,7 +550,8 @@ class CheckGitCommits:
         p = subprocess.Popen(cmd,\r
                      stdout=subprocess.PIPE,\r
                      stderr=subprocess.STDOUT)\r
-        return p.communicate()[0].decode('utf-8', 'ignore')\r
+        Result = p.communicate()\r
+        return Result[0].decode('utf-8', 'ignore') if Result[0] and Result[0].find("fatal")!=0 else None\r
 \r
 class CheckOnePatchFile:\r
     """Performs a patch check for a single file.\r