Files
sysconfig/git_ignore_find2merge.sh
luk 9742f6dab2 refactor: 脚本及配置文件命名统一用 _ 分隔
将 .sh/.bat 脚本与 .js/.plist/.Dockerfile 等文件中以 - 分隔的文件名
改为 _ 分隔,dcloud-renew 目录改为 dcloud、script_nuance 目录改为
nuance,并同步更新脚本内部引用与 README 路径。

Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
2026-08-25 15:11:50 +08:00

79 lines
1.9 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
echo ""
echo "Search in [ROOTPATH], merge [GLOBALPATH/.gitignore_global] and [ROOTPATH/*/.gitignore.local.txt] files to .gitignore"
echo ""
if [ -d "$1" ]
then
ROOTPATH=$1
else
echo "::*** Enter [root path] or [leave blank] for default [[`pwd`]] to start tree search for git repositories"
read -p "***:: " ROOTPATH
if [ "$ROOTPATH" ]
then
ROOTPATH=$(realpath $ROOTPATH)
else
ROOTPATH=`pwd`
fi
fi
if [ ! -d "$ROOTPATH" ]
then
echo "××× [[$ROOTPATH]] not exist! Exit now. ***"
exit
else
echo "√√√ ROOTPATH = [[$ROOTPATH]]"
fi
echo ""
GLOBALPATH_DEFAULT=https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/.gitignore_global
echo "::*** Enter [path to .gitignore_global] or [leave blank] for default [[$GLOBALPATH_DEFAULT]]"
read -p "***:: " GLOBALPATH
if [ "$GLOBALPATH" ]
then
if [ -d "$GLOBALPATH" ]
then
GLOBALPATH=$(realpath $GLOBALPATH)/.gitignore_global
fi
if [ ! -f "$GLOBALPATH" ]
then
echo "××× Not found [[$GLOBALPATH]]. Exit now..."
exit
else
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
fi
else
GLOBALPATH=GLOBALPATH_DEFAULT
fi
echo ""
echo "::*** Enter [y] to start updating, or [anything else] to quit"
read -p "***:: " YESNO
if [ "$YESNO" != 'y' ]
then
exit
fi
cd $ROOTPATH
echo "*** Starting from [[`pwd`]] ***"
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/.gitignore" ] # some git repo need to keep privacy, therefore judge from .gitignore, not from .git
then
echo "---- updating [[$repo/.gitignore]] ----"
if [ -f "$GLOBALPATH" ]
then
cat $GLOBALPATH > $repo/.gitignore
else
curl -sSL $GLOBALPATH | cat > $repo/.gitignore
fi
cat $repo/.gitignore.local.txt 2>/dev/null >> $repo/.gitignore
echo ""
fi
done
cd -