I’m trying to commit git patches via a bash script. This is not a git question! Here is what I want to do, I have a list of files in a directory. I want read those files one by one extract a particular line out of it and then commit.
Here is what I got so far;
patches=/{location}/*.patch
for patch in $patches
do
echo "Processing $patch file..."
git apply $patch
git add --all
git commit -m | egrep -o "(^Subject: \[PATCH [0-9]\/[0-9]\].)(.*)$" $f
echo "Committed $patch file..."
done
Couldn’t get the egrep regex working to pass on the proper commit message.
Here is an example line from a patch file;
..... Subject: [PATCH 1/3] XSR-2756 Including ldap credentials in property file. ......
I just want to capture “XSR-2756 Including ldap credentials in property file.” and use as a commit description to git.
Assuming you have GNU grep, use a Perl look-behind: