From 0ea158724f307a2ad12be8d79ec3ae8c28c8928e Mon Sep 17 00:00:00 2001 From: whyour Date: Tue, 5 Apr 2022 00:21:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 13 +++++++++---- shell/task.sh | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index 48d7f680..5897fac1 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -401,7 +401,7 @@ export default class CronService { } } - private getKey(command: string) { + private getKey(command: string): string { const start = command.lastIndexOf('/') !== -1 ? command.lastIndexOf('/') + 1 : 0; const end = @@ -409,10 +409,15 @@ export default class CronService { ? command.lastIndexOf('.') : command.length; - const tmpStr = command.startsWith('/') ? command.substring(1) : command; - const index = tmpStr.indexOf('/') !== -1 ? tmpStr.indexOf('/') : 0; + const tmpStr = command.substring(0, start - 1); + let index = 0; + if (tmpStr.lastIndexOf('/') !== -1 && tmpStr.startsWith('http')) { + index = tmpStr.lastIndexOf('/'); + } else if (tmpStr.lastIndexOf(':') !== -1 && tmpStr.startsWith('git@')) { + index = tmpStr.lastIndexOf(':'); + } if (index) { - return `${tmpStr.substring(0, index)}_${command.substring(start, end)}`; + return `${tmpStr.substring(index + 1)}_${command.substring(start, end)}`; } else { return command.substring(start, end); } diff --git a/shell/task.sh b/shell/task.sh index dd2382f0..9946a4e0 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -93,7 +93,7 @@ run_normal() { log_dir_tmp_path="${file_param}" fi fi - log_dir_tmp_path="${log_dir_tmp_path%%/*}" + log_dir_tmp_path="${log_dir_tmp_path%/*}" log_dir_tmp_path="${log_dir_tmp_path##*/}" [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" log_dir="${log_dir_tmp%.*}" @@ -162,7 +162,7 @@ run_concurrent() { log_dir_tmp_path="${file_param}" fi fi - log_dir_tmp_path="${log_dir_tmp_path%%/*}" + log_dir_tmp_path="${log_dir_tmp_path%/*}" log_dir_tmp_path="${log_dir_tmp_path##*/}" [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" log_dir="${log_dir_tmp%.*}" @@ -231,7 +231,7 @@ run_designated() { log_dir_tmp_path="${file_param}" fi fi - log_dir_tmp_path="${log_dir_tmp_path%%/*}" + log_dir_tmp_path="${log_dir_tmp_path%/*}" log_dir_tmp_path="${log_dir_tmp_path##*/}" [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" log_dir="${log_dir_tmp%.*}" @@ -294,7 +294,7 @@ run_else() { log_dir_tmp_path="${file_param}" fi fi - log_dir_tmp_path="${log_dir_tmp_path%%/*}" + log_dir_tmp_path="${log_dir_tmp_path%/*}" log_dir_tmp_path="${log_dir_tmp_path##*/}" [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" log_dir="${log_dir_tmp%.*}"