3 err() { echo "error: $*" >&2; exit 1; }
6 [[ $# -gt 1 ]] && err "accepted args: <file>[:rev1[:rev2]]"
8 # spec has the form file:rev1[:rev2]
9 # rev2 defaults to rev1-1
15 if [[ ! -e ${file} ]] ; then
16 echo "file '${file}' does not exist"
20 [[ ${file} == */* ]] && dir=${file%/*}
24 if [[ -z ${rev2} ]] ; then
28 set -- $(grep /${file}/ CVS/Entries)
32 if [[ ${rev2} == "0" ]] ; then
36 # existing file, bump rev automatically
37 rev2="1.$((${rev2#1.}+1))"
40 local rev2r=${rev2#1.}
41 local rev1=${3:-1.$((rev2r - 1))}
43 local cvsroot=$(<${dir}/CVS/Repository)
44 if [[ ${cvsroot} == gentoo-x86* ]] ; then
45 cvsroot=${cvsroot#gentoo-x86}
50 [[ ${rev2} == "1.1" || ${rev1} == "${rev2}" ]] \
51 && urirev="?rev=${rev2}" \
52 || urirev="?r1=${rev1}&r2=${rev2}"
53 echo "https://sources.gentoo.org/${cvsroot}/${file}${urirev}"
63 [[ $# -gt 1 ]] && err "accepted args: <rev>"
66 local remote=$(git config remote.origin.url)
68 *://uclibc.org/*|*://git.uclibc.org/*|\
69 *://busybox.net/*|*://git.busybox.net/*|\
70 *://buildroot.org/*|*://git.buildroot.org/*|\
71 *://buildroot.net/*|*://git.buildroot.net/*)
72 repo=$(echo "${remote}" | sed -e 's,^[^:]*://[^/]*/,,' -e 's:[.]git$::')
75 uclibc) url+="uclibc.org" ;;
76 buildroot) url+="buildroot.org" ;;
77 *) url+="busybox.net" ;;
79 url+="/${repo}/commit/?id="
81 *://git@git.gentoo.org/*|\
82 *://anongit.gentoo.org/*)
83 repo=$(echo "${remote}" | sed 's:.*git[.a-z]*.gentoo.org/::')
84 url="https://gitweb.gentoo.org/${repo}/commit/?id="
88 repo=$(echo "${remote}" | sed -e 's,^git@github.com[:/],,' -e 's,^https://github.com/,,' -e 's,^git://github.com/,,' -e 's:[.]git$::')
89 url="https://github.com/${repo}/commit/"
93 repo=$(echo "${remote}" | sed -e 's,^git@gitlab.com[:/],,' -e 's,^https://gitlab.com/,,' -e 's,^git://gitlab.com/,,' -e 's:[.]git$::')
94 url="https://gitlab.com/${repo}/commit/"
96 git://git.sv.gnu.org/*|git://git.savannah.gnu.org/*)
97 repo=$(echo "${remote}" | sed -r -e 's,^git://git.(sv|savannah).gnu.org/,,' -e 's:[.]git$::')
98 url="http://git.savannah.gnu.org/cgit/${repo}.git/commit/?h="
100 git://git.code.sf.net/p/*|ssh://*@git.code.sf.net/p/*)
101 repo=$(echo "${remote}" | sed -r -e 's,(git://|ssh://([^@]*@)?)git.code.sf.net/p/([^/]*)/.*,\3,')
102 url="https://sourceforge.net/p/${repo}/code/ci/"
104 *://sourceware.org/*)
105 repo=$(echo "${remote}" | sed -e 's,.*/,,' -e 's,[.]git$,,')
106 url="https://sourceware.org/git/?p=${repo}.git;a=commit;h="
108 *.googlesource.com/*)
109 url="${remote%.git}/+/"
111 *://git.enlightenment.org/*)
112 repo=$(echo "${remote}" | sed -e 's,^[^/]*//[^/]*/,,' -e 's,[.]git$,,')
113 url="https://git.enlightenment.org/${repo}.git/commit/?id="
116 repo=$(echo "${remote}" | sed -e 's,^[^/]*//[^/]*/,,' -e 's,[.]git$,,')
117 url="http://git.qemu.org/?p=${repo}.git;a=commit;h="
120 echo "Unknown remote: ${remote}"
125 git log -n3 ${1:-HEAD} | sed "s,^commit ,${url},"
129 if [[ $# -eq 0 ]] ; then
133 URL = "http://sources.gentoo.org/" gensub(/.*svnroot\/([^/]*).*/, "\\1", 1);
134 } else if ($1 == "Revision:") {
136 URL = URL "?rev=" (rev + 1) "&view=rev"
149 URL = "http://sources.gentoo.org" $1 "?"
150 } else if ($1 == "Revision:") {
152 URL = URL "r1=" rev "&r2=" (rev + 1)
161 Usage: $0 [options] [args]
174 while [[ $# -gt 0 ]] ; do
188 if [[ ${vcs} == "auto" ]] ; then
189 if [[ -d CVS ]] ; then
191 elif svn info >&/dev/null ; then