Progress bar for svn checkout in text mode

2019-07-02 21:24发布

问题:

I'm writing a bash script that needs to fetch source code from several remote subversion repositories. I use svn checkout -q to avoid displaying long lists of files that clutter the output but now I'm looking for a clean way to display progress info to the user during each svn checkout. Something in the vein of wget and curl's progress indicators. I'll have users in OSX and Linux. pv is available on both but so far, I haven't found how to use it with svn checkout. I should also say that I'm not looking for tools that use GUI windows, but text-only tools.

Any suggestions would be very welcome! Thanks!

回答1:

try:

svn list -v -R URL

you can parse the result, and do a progress by file count.



回答2:

Closest thing I've found: http://www.danielkraaij.nl/2014/03/30/subversion-progressbar-in-bash/

n=$(svn info -R svn://svn/project/trunk | grep "URL: " | uniq | wc -l)

n=$(svn info -R svn://svn/project/trunk | grep "URL: " | uniq | wc -l)
i=1
while read line filename
    do
    counter=$(( 100*(++i)/n))
    echo -e "($counter %)\n"
    echo -e "filename: $filename \n"
done < <(svn co svn://svn/project/trunk /var/www/project)

dialog --backtitle "Subversion Installer" --title "SVN Checkout" --gauge "Getting total file count" 7 120 < <(
    n=$(svn info -R svn://svn/project/trunk | grep "URL: " | uniq | wc -l)
    i=1
    while read line filename
        do
        counter=$(( 100*(++i)/n))
        echo "XXX"
        echo "$counter"
        echo "filename: $filename"
        echo "XXX"

    done < <(svn co svn://svn/project/trunk /var/www/project)
)