#!/bin/bash # $Id$ # # Copyright 2005, Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # Written by Aron Griffis # # eviewcvs - generate viewcvs urls for some files # if [[ -t 1 ]]; then blue="" cyan="" green="" red="" off="" else unset blue cyan green red off fi startdir="$PWD" url="http://sources.gentoo.org/viewcvs.py" unset diffs declare -a hdr orev chdir() { cd "$1" || return # Figure out where we are, hopefully unset cwd root if [[ -f CVS/Repository ]]; then cwd=$(/dev/null | awk '/^head:/{print $2}') elif [[ -d .svn ]]; then frev=$(svn info "$f" 2>/dev/null | awk '/^Revision:/{print $2}') fi ;; esac [[ -n ${frev} ]] || continue # Here is the simple URL to view it echo "${url}/${fwd:+$fwd/}${green}${f}${off}?rev=${frev}&view=markup" # Also supply a diff URL if possible if [[ ${frev##*.} -gt 1 ]]; then orev=( ${frev//./ } ) # convert to array (( orev[${#orev[@]}-1]-- )) # decrement the last element orev=${orev[*]} # convert to string orev=${orev// /.} # revert spaces to dots diffs="${diffs:+$diffs }${url}/${fwd:+$fwd/}${blue}${f}${off}?r1=${orev}&r2=${frev}" fi done if [[ -n ${diffs} ]]; then echo "${diffs}" fi # vim:set expandtab sw=4 smarttab: