From 63b82d5399a35af4b7b73f087f58e2d35a6bfb1b Mon Sep 17 00:00:00 2001 From: Gilbert Young <109980169+bud-primordium@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:57:52 +0800 Subject: [PATCH] Exclude certain file types and folders from linguist detection --- .gitattributes | 24 ++++++++++++------------ .utils/linguist_updater.py | 6 ++++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.gitattributes b/.gitattributes index 82f0d84..5e87094 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,17 +1,17 @@ # 排除语言统计的文件夹 -Assignment_1\Problem_2\doxygen_output/** linguist-vendored -Assignment_1\Problem_2\ford_output/** linguist-vendored -Assignment_2\Problem_1\doxygen_output/** linguist-vendored -Assignment_2\Problem_2\doxygen_output/** linguist-vendored -Assignment_3\Problem_2\doxygen_output/** linguist-vendored -Assignment_3\Problem_3\src\documenter_output/** linguist-vendored +Assignment_1/Problem_2/doxygen_output/** linguist-vendored +Assignment_1/Problem_2/ford_output/** linguist-vendored +Assignment_2/Problem_1/doxygen_output/** linguist-vendored +Assignment_2/Problem_2/doxygen_output/** linguist-vendored +Assignment_3/Problem_2/doxygen_output/** linguist-vendored +Assignment_3/Problem_3/src/documenter_output/** linguist-vendored # 排除语言统计的HTML文件 -Assignment_1\Problem_2\Doxygen.html linguist-generated -Assignment_1\Problem_2\Ford.html linguist-generated -Assignment_2\Problem_1\Doxygen.html linguist-generated -Assignment_2\Problem_2\Doxygen.html linguist-generated -Assignment_3\Problem_2\Doxygen.html linguist-generated -Assignment_3\Problem_3\Documenter.html linguist-generated +Assignment_1/Problem_2/Doxygen.html linguist-generated +Assignment_1/Problem_2/Ford.html linguist-generated +Assignment_2/Problem_1/Doxygen.html linguist-generated +Assignment_2/Problem_2/Doxygen.html linguist-generated +Assignment_3/Problem_2/Doxygen.html linguist-generated +Assignment_3/Problem_3/Documenter.html linguist-generated # Generated by linguist_updater \ No newline at end of file diff --git a/.utils/linguist_updater.py b/.utils/linguist_updater.py index 87b1966..06e4b9e 100644 --- a/.utils/linguist_updater.py +++ b/.utils/linguist_updater.py @@ -17,9 +17,10 @@ def get_vendored_paths(root_dir, vendored_dirs): continue for folder in vendored_dirs: if folder in dirs: + # 转换路径分隔符为正斜杠 relative_path = os.path.relpath( os.path.join(root, folder), start=root_dir - ) + ).replace("\\", "/") vendored_paths.append(f"{relative_path}/** linguist-vendored\n") return vendored_paths @@ -33,9 +34,10 @@ def get_generated_file_paths(root_dir, generated_files): continue for file in files: if file in generated_files: + # 转换路径分隔符为正斜杠 relative_path = os.path.relpath( os.path.join(root, file), start=root_dir - ) + ).replace("\\", "/") generated_paths.append(f"{relative_path} linguist-generated\n") return generated_paths