fix: sync repo target-paht error

This commit is contained in:
engigu
2025-12-25 18:13:07 +08:00
parent f096d6dea4
commit d8840209b5
3 changed files with 20 additions and 2 deletions
+2 -1
View File
@@ -79,7 +79,8 @@ COPY docker-entrypoint.sh .
COPY sync.py /opt/sync.py
RUN chmod +x /opt/sync.py \
&& chmod +x docker-entrypoint.sh \
&& touch "dont-not-delete-anythings"
&& touch "dont-not-delete-anythings" \
&& echo "set encoding=utf-8" >> /etc/vim/vimrc
EXPOSE 8052
+15 -1
View File
@@ -12,6 +12,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"time"
@@ -354,12 +355,25 @@ func (es *ExecutorService) executeRepoTask(task *models.Task) *ExecutionResult {
return result
}
// 处理目标路径:为空则使用 scripts 目录,相对路径则基于 scripts 目录
targetPath := config.TargetPath
if targetPath == "" {
targetPath = constant.ScriptsWorkDir
} else if !filepath.IsAbs(targetPath) {
targetPath = filepath.Join(constant.ScriptsWorkDir, targetPath)
}
// 转换为绝对路径
absTargetPath, err := filepath.Abs(targetPath)
if err != nil {
absTargetPath = targetPath
}
// 构建 sync.py 命令参数
args := []string{
"/opt/sync.py",
"--source-type", config.SourceType,
"--source-url", config.SourceURL,
"--target-path", config.TargetPath,
"--target-path", absTargetPath,
}
// Git 分支
+3
View File
@@ -255,6 +255,9 @@ def main():
args = parser.parse_args()
# 打印原始命令行参数
print("参数:", " ".join(sys.argv[1:]))
if args.source_type == "git":
sync_git(args)
else: