From 79ebc822275e7fd25f28505589e0223d88b58a48 Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 9 Oct 2026 10:40:08 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E9=80=82=E9=85=8D=20macOS=20=E7=BC=96?= =?UTF-8?q?=E8=AF=91=EF=BC=88=E6=B5=8B=E8=AF=95=E6=9C=9F=E6=9C=9B=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E5=B9=B3=E5=8F=B0=E8=B7=AF=E5=BE=84=E5=88=86=E9=9A=94?= =?UTF-8?q?=E7=AC=A6=E3=80=81=E7=BB=9F=E4=B8=80=20LF=20=E8=A1=8C=E5=B0=BE?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 12 ++++++++++++ internal/core/paths_test.go | 21 ++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bf6f8a3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +# 统一按 LF 存储、按 LF 检出,避免 Windows / macOS 之间整文件 diff 噪音 +* text=auto eol=lf + +# 明确的二进制文件 +*.png binary +*.ico binary +*.exe binary +*.jpg binary +*.jpeg binary +*.gif binary +*.icns binary +*.zip binary diff --git a/internal/core/paths_test.go b/internal/core/paths_test.go index f04dff4..e9f13f7 100644 --- a/internal/core/paths_test.go +++ b/internal/core/paths_test.go @@ -2,6 +2,7 @@ package core import ( "os" + "path/filepath" "strings" "testing" @@ -31,23 +32,25 @@ func TestBuildDir(t *testing.T) { want string }{ {"{title}", "[Noxe] 0820 Qingxiao [AI Generated]"}, - {"{artist}/{title}", `Noxe\[Noxe] 0820 Qingxiao [AI Generated]`}, - {"{group}/{title}", `CriticalHAI\[Noxe] 0820 Qingxiao [AI Generated]`}, - {"{category}/{group}/{title}", `misc\CriticalHAI\[Noxe] 0820 Qingxiao [AI Generated]`}, - {"{tags:2}/{artist}/{title}", `qingxiao_rover\Noxe\[Noxe] 0820 Qingxiao [AI Generated]`}, - {"{tags}/{artist}/{title}", `qingxiao_rover_big breasts_x-ray_ai generated\Noxe\[Noxe] 0820 Qingxiao [AI Generated]`}, + {"{artist}/{title}", `Noxe/[Noxe] 0820 Qingxiao [AI Generated]`}, + {"{group}/{title}", `CriticalHAI/[Noxe] 0820 Qingxiao [AI Generated]`}, + {"{category}/{group}/{title}", `misc/CriticalHAI/[Noxe] 0820 Qingxiao [AI Generated]`}, + {"{tags:2}/{artist}/{title}", `qingxiao_rover/Noxe/[Noxe] 0820 Qingxiao [AI Generated]`}, + {"{tags}/{artist}/{title}", `qingxiao_rover_big breasts_x-ray_ai generated/Noxe/[Noxe] 0820 Qingxiao [AI Generated]`}, {"{tag1}-{tag2}", "qingxiao-rover"}, {"{artist} - {gid} - {title}", "Noxe - 4239274 - [Noxe] 0820 Qingxiao [AI Generated]"}, {"{gid}", "4239274"}, - {"{lang}/{title}", `chinese\[Noxe] 0820 Qingxiao [AI Generated]`}, - {"{unknown}/{title}", `{unknown}\[Noxe] 0820 Qingxiao [AI Generated]`}, // 未知占位符原样保留 + {"{lang}/{title}", `chinese/[Noxe] 0820 Qingxiao [AI Generated]`}, + {"{unknown}/{title}", `{unknown}/[Noxe] 0820 Qingxiao [AI Generated]`}, // 未知占位符原样保留 } for _, tt := range tests { t.Run(tt.tpl, func(t *testing.T) { got := BuildDir(tt.tpl, g) - if got != tt.want { - t.Errorf("\n got: %q\nwant: %q", got, tt.want) + // 期望值用 / 书写,再换成本机路径分隔符(Windows 是 \) + want := strings.ReplaceAll(tt.want, "/", string(filepath.Separator)) + if got != want { + t.Errorf("\n got: %q\nwant: %q", got, want) } }) }