bash - Looking to convert a Simple SVN tool to Git -
so purpose of tool pull static file use in each release track sox information.
here code used use:
firstofyear=`date +%y-01-01` today=`date +%y-%m-%d` startdate=${firstofyear} enddate=${today} # change these app (as appears in svn) , code file names app=fooapp code=fa # clean last run rm ${code}_*.txt rm tt${code}_*.txt #setup header last="0.0" echo "${code} releases ${startdate} - ${enddate}" >> tt${code}_release_list.txt release in `svn log -v --revision {${startdate}}:{${enddate}} http://svn.mynet.com/repos/${app}/tags |grep "a /tags" | sed 's/.*gs\/\([0-9|.]*\).*/\1/g'` if [ ${last} != ${release} ]; svn export http://svn.mynet.com/repos/${app}/tags/"$release"/docs/release_notes.txt ${code}_"$release"_release_notes.txt cat ${code}_"$release"_release_notes.txt | ./../gensummary.pl >> ${code}_summary.txt cat ${code}_"$release"_release_notes.txt | ./../genreleaselist.pl >> tt${code}_release_list.txt echo http://svn.mynet.com/repos/${app}/tags/"$release"/docs/release_notes.txt >> ${code}_summary.txt echo ================================================= >> ${code}_summary.txt fi last=$release done
so explain...this script looks through svn repository between dates specified , pulls tag's created then. pulls key file repository.
we have/are migrating git , using git-workflow in end of cycle have group of tags on master branch.
now think way can pull off same stuff did svn clone repository can poll information...
anyone have other suggestions? way, using bitbucket our central repository.
ok, think i've got working solution. of course, you'll have clone repo locally first, within repo this:
firstofyear=`date +%y-01-01` today=`date +%y-%m-%d` startdate=${firstofyear} enddate=${today} commit in `git tag --list |xargs git show --since=$startdate --before=$enddate --format='commit: %h'|grep 'commit: '|cut -d' ' -f2`; git show $commit:docs/release_notes.txt >> /tmp/output_file done
here's breakdown of ugly mess in for
loop:
1: list tags:
git tag --list
2: pass tags git show
, filter out not in dates you're looking for, , print out commit prefix commit:
xargs git show --since=$startdate --before=$enddate --format='commit: %h'
3: parse out commit hashes output
grep 'commit: '|cut -d' ' -f2`
now have list of commits tagged in date range wanted , can use git cat-file
dump out release_notes.txt
of each tag.
you should able add in other special processing need.
---edit---
if need tag name in name of output file can following:
firstofyear=`date +%y-01-01` today=`date +%y-%m-%d` startdate=${firstofyear} enddate=${today} tag_and_commit in `git tag --list |xargs git show --since=$startdate --before=$enddate|perl -ne '$_=join("", <>); while(/^tag (\w+).*?^commit (\w+)/gsm) { print "$1-$2\n" }'`; ifs='-' read -r -a arr <<< "$tag_and_commit" tag=${arr[0]} commit=${arr[1]} git show $commit:docs/release_notes.txt >> /tmp/$tag-output_file done
note getting ugly of in bash script (probably in part due weak bash skills). might better long term convert perl/ruby/whatever script.
Comments
Post a Comment