From efeb207ab666fa9c2fcaf79ae2bbdcac726dede5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=98=89=E7=90=A6?= Date: Thu, 13 Apr 2023 01:48:41 +0000 Subject: [PATCH] update src/ac/acl/commit_msg/check_commit_msg.py. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙嘉琦 --- src/ac/acl/commit_msg/check_commit_msg.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ac/acl/commit_msg/check_commit_msg.py b/src/ac/acl/commit_msg/check_commit_msg.py index 7257d7a..70de40d 100644 --- a/src/ac/acl/commit_msg/check_commit_msg.py +++ b/src/ac/acl/commit_msg/check_commit_msg.py @@ -52,8 +52,9 @@ class CheckCommitMsg(BaseCheck): commit = commit.replace('\r', '') commit = commit.replace('\n', '') # get commit and add to dist for follow using - command = "gitlint --commit " + commit + " -C " + gitlint_dir + "/.gitlint" - res = subprocess.Popen(command, cwd=work_dir, shell=True, stderr=subprocess.PIPE) + command = "--commit " + commit + " -C " + gitlint_dir + "/.gitlint" + command_list = ["gitlint", command] + res = subprocess.Popen(command_list, cwd=work_dir, shell=False, stderr=subprocess.PIPE) out = res.stderr.readlines() if len(out) > 0 : out_str = "" @@ -71,12 +72,14 @@ class CheckCommitMsg(BaseCheck): # prepare git branch environment repo_dir = self._work_dir + "/" + self._repo logger.info("repoDir: %s", repo_dir) - branch_log_cmd = "git fetch origin +refs/heads/{}:refs/remotes/origin/{}".format(self._tbranch, self._tbranch) - branch_log_pro = subprocess.Popen(branch_log_cmd, cwd=repo_dir, shell=True, stdout=subprocess.PIPE) + branch_log_cmd = "origin +refs/heads/{}:refs/remotes/origin/{}".format(self._tbranch, self._tbranch) + branch_log_cmd_list = ["git fetch", branch_log_cmd] + branch_log_pro = subprocess.Popen(branch_log_cmd_list, cwd=repo_dir, shell=False, stdout=subprocess.PIPE) logger.info("git featch res: ") logger.info(branch_log_pro.stdout.read()) - branch_log_cmd = "git log HEAD...origin/" + self._tbranch + " --no-merges --pretty=%H" - branch_log_pro = subprocess.Popen(branch_log_cmd, cwd=repo_dir, shell=True, stdout=subprocess.PIPE) + branch_log_cmd = "HEAD...origin/" + self._tbranch + " --no-merges --pretty=%H" + branch_log_cmd_list = ["git log", branch_log_cmd] + branch_log_pro = subprocess.Popen(branch_log_cmd_list, cwd=repo_dir, shell=False, stdout=subprocess.PIPE) branch_log_res = branch_log_pro.stdout.readlines() conf_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../conf/")) commit_check_dist = self.get_commit_msg_result(branch_log_res, repo_dir, conf_dir) -- Gitee