I'm trying to make a script that will read the output of git log
and place this is an XML file.
Here is an example of the script.
#!/bin/bash
repo=(/srv/git/repositories)
list1=($repo/test.git)
cd "$list1"
echo '<?xml version="1.0" ?><rss version="2.0"><channel>' >> /tmp/test.xml
for i in $(git log --pretty=format:"%h")
do
for e in $(git log | grep "Author:" | awk '{print $2}')
do
#for f in $(git log --pretty=format:"%cn")
#do
#for g in $(git log --pretty=format:"%cD")
#do
cat << EOF >> /tmp/test.xml
<item><title>$i</title><description></description><author>$e</author><pubDate></pubDate></item>
EOF
#done
#done
done
done
echo '</channel></rss>' >> /tmp/test.xml
When I do this this, the result is that each commit number and Author will be read and echoed multiple times. So I will get an .xml file like this: Lots of the same commit number!
<rss version="2.0">
<channel>
<item>
<title>906feb6</title>
<description/>
<author>test</author>
<pubDate/>
</item>
<item>
<title>906feb6</title>
<description/>
<author>test</author>
<pubDate/>
</item>
<item>
<title>906feb6</title>
<description/>
<author>test</author>
<pubDate/>
</item>
<item>
<title>**906feb6**</title>
<description/>
<author>test1</author>
<pubDate/>
</item>
<item>
<title>**906feb6**</title>
<description/>
<author>test1</author>
<pubDate/>
<item>
<title>**ffb521e**</title>
<description/>
<author>test1</author>
<pubDate/>
</item>
<channel></rss>
What I want is that each commit number has an author, a description, and a publication date. But it has to get its information from those commands.
I want a output like this, could someone help?
<item>
<title>906feb6</title>
<description/>test commit 1</description>
<author>test1</author>
<pubDate>Mar, 18<pubDate/>
<item>
<title>**ffb521e**</title>
<description>test commit 2</description>
<author>test2</author>
<pubDate>Mar, 18<pubDate/>
</item>