0
我正在创建一个脚本,它将拉下最新的主代码分支,并检查是否有任何文件名是SQL。在确定文件名后,我将获取存储过程。目前我已经拉动代码并逐行读取输出,但是我的grep命令似乎无法找到sql文件名。这是我所拥有的从git pull输出中提取文件名
#!/bin/bash
# Pull all of the latest code for the master branch, and set the commit log to
# a variable
commit_log=$(git pull origin master --quiet)
#read the commit log line by line
echo $commit_log | while read line
do
if [ `echo "$line" | grep -E "(\.sql)$"` ]; then
echo "SQL"
fi
echo "LINE:" $line
done
我没有卡在bash上,我也可以在perl中做到这一点。
拉后,运行'git的差异--name只HEAD^1..HEAD',并从那里使用的文件名。 – rpkamp
@ScallioXTX我会补充说,你应该检查你的当前版本拉之前,然后显示你的版本和新头之间的差异。当拉你可以收到很多提交在一堆......或没有。这个任务并不是那么简单。如果你合并,你可能会进行修改,甚至不是最终历史的一部分。 git pull --rebase也可能是个问题。 – Lynch
在你的构造中,括号和反引号是错误的。把它们留下。 – michas