Files
sysconfig/seafile_ignore_find2merge.sh
T
lukandAtomCode b49f8c9f11 seafile_ignore_find2merge 移植 Node 跨平台,global 增加 Flutter 产物忽略规则
- 新增 seafile_ignore_find2merge.js:忠实移植 .sh 语义(深度3树搜索、跳过
  node_modules 等目录、seafile-ignore.txt/.local.txt 触发合并、dry-run 模式),
  修正 .sh 三个问题:默认 global 是 URL 时 cat 失败(改用 fetch)、去掉误抄的
  .git 检测、根目录自身参与合并(find -name '[^.]*' 匹配不到根)
- .sh 同步修正后两项(.git 检测、根目录),保持与 .js 行为一致
- nixhome/seafile-ignore.global.txt 增加 Flutter/Dart 通用机器本地产物:
  .dart_tool/、.flutter-plugins-dependencies、Pods/、local.properties、
  .gradle/、.kotlin/(build/ 因 vue 仓库跟踪 build/ 而仅在项目层 local 忽略)
- 验证:/tmp 夹具树 .sh 与 .js 产物逐字节一致;productX 全树 dry-run 候选 87 条一致

Co-Authored-By: AtomCode (qwen3.8-27b) <[email protected]>
2026-10-07 09:58:09 +08:00

82 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
echo ""
echo "Search in [ROOTPATH], Merge [GLOBALPATH/seafile-ignore.global.txt] and [ROOTPATH/*/seafile-ignore.local.txt] files to [seafile-ignore.txt]"
echo ""
if [ -d "$1" ]
then
ROOTPATH=$1
else
echo "::*** Enter [root path] or [leave blank] for default [[`pwd`]] to start tree search for seafile-ignore.txt files"
read -p "***:: " ROOTPATH
if [ "$ROOTPATH" ]
then
ROOTPATH=$(realpath "${ROOTPATH/#\~/$HOME}")
else
ROOTPATH=`pwd`
fi
fi
if [ ! -d "$ROOTPATH" ]
then
echo "××× [[$ROOTPATH]] not exist! Exit now. ***"
exit
else
echo "√√√ ROOTPATH = [[$ROOTPATH]]"
fi
echo ""
echo "::*** Enter [path to seafile-ignore.global.txt] or [leave blank] for default [[https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]]"
read -p "***:: " GLOBALPATH
if [ "$GLOBALPATH" ]
then
GLOBALPATH=$(realpath "${GLOBALPATH/#\~/$HOME}")
echo $GLOBALPATH
if [ -d "$GLOBALPATH" ]
then
GLOBALPATH="$GLOBALPATH/seafile-ignore.global.txt"
fi
if [ -f "$GLOBALPATH" ]
then
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
else
echo "××× Not found [[$GLOBALPATH]]. Exit now..."
exit
fi
else
GLOBALPATH=https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt
fi
echo ""
echo "::*** Enter [y] to start updating, or [anything else] for dry-run"
read -p "***:: " YESNO
cd $ROOTPATH
echo "*** Starting from [[`pwd`]] ***"
echo ""
# 根目录自身也是候选(find -name '[^.]*' 匹配不到根目录 .,手动补上)
{ echo "."; find . -mindepth 0 -maxdepth 3 -type d -name '[^.]*'; } | grep -E -v 'node_modules|uni_modules|\.deploy_git|\.git|.svn|\.vscode|\.wrangler|unpackage|_webroot|_logstore|_datasotre|_archive|_filestore|_ssl' | while read repo
do
if [ -f "$repo/seafile-ignore.txt" ] || [ -f "$repo/seafile-ignore.local.txt" ]
then
echo "---- updating [[$repo/seafile-ignore.txt]] ----"
if [ "$YESNO" = 'y' ]
then
if [ -f "$GLOBALPATH" ]
then
cat $GLOBALPATH > $repo/seafile-ignore.txt
else
curl -sSL $GLOBALPATH | cat > $repo/seafile-ignore.txt
fi
if [ -f "$repo/seafile-ignore.local.txt" ]
then
cat $repo/seafile-ignore.local.txt 2>/dev/null >> $repo/seafile-ignore.txt
fi
fi
echo ""
fi
done
cd -