]>
git.wh0rd.org - home.git/blob - .bin/vcs-url
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 if [[ -z ${remote} ]] ; then
69 # Maybe the repo doesn't use "origin
". Try harder.
70 local branch=$(git rev-parse --abbrev-ref HEAD)
71 remote=$(git config "branch.
${branch}.remote
")
72 if [[ -n ${remote} ]] ; then
73 remote=$(git config "remote.
${remote}.url
")
76 local remotes=$(git config --get-regexp 'remote\..*\.url')
77 if [[ -n ${remotes} ]]; then
78 remote=$(echo "${remotes}" | awk '{print $2; exit}')
84 *://uclibc.org/*|*://git.uclibc.org/*|\
85 *://busybox.net/*|*://git.busybox.net/*|\
86 *://buildroot.org/*|*://git.buildroot.org/*|\
87 *://buildroot.net/*|*://git.buildroot.net/*)
88 repo=$(echo "${remote}" | sed -e 's,^[^:]*://[^/]*/,,' -e 's:[.]git$::')
91 uclibc) url+="uclibc.org
" ;;
92 buildroot) url+="buildroot.org
" ;;
93 *) url+="busybox.net
" ;;
95 url+="/${repo}/commit
/?id
="
97 *://git@git.gentoo.org/*|\
98 *://anongit.gentoo.org/*)
99 repo=$(echo "${remote}" | sed 's:.*git[.a-z]*.gentoo.org/::')
100 url="https
://gitweb.gentoo.org
/${repo}/commit
/?id
="
102 git@github.com[:/]*|\
104 repo=$(echo "${remote}" | sed -e 's,^git@github.com[:/],,' -e 's,^https://github.com/,,' -e 's,^git://github.com/,,' -e 's:[.]git$::')
105 url="https
://github.com
/${repo}/commit
/"
107 git@gitlab.com[:/]*|\
109 repo=$(echo "${remote}" | sed -e 's,^git@gitlab.com[:/],,' -e 's,^https://gitlab.com/,,' -e 's,^git://gitlab.com/,,' -e 's:[.]git$::')
110 url="https
://gitlab.com
/${repo}/commit
/"
112 git://git.sv.gnu.org/*|git://git.savannah.gnu.org/*)
113 repo=$(echo "${remote}" | sed -r -e 's,^git://git.(sv|savannah).gnu.org/,,' -e 's:[.]git$::')
114 url="http
://git.savannah.gnu.org
/cgit
/${repo}.git
/commit
/?h
="
116 git://git.sv.nongnu.org/*|git://git.savannah.nongnu.org/*)
117 repo=$(echo "${remote}" | sed -r -e 's,^git://git.(sv|savannah).nongnu.org/,,' -e 's:[.]git$::')
118 url="http
://git.savannah.nongnu.org
/cgit
/${repo}.git
/commit
/?h
="
120 git://git.code.sf.net/p/*|ssh://*@git.code.sf.net/p/*)
121 repo=$(echo "${remote}" | sed -r -e 's,(git://|ssh://([^@]*@)?)git.code.sf.net/p/([^/]*)/.*,\3,')
122 url="https
://sourceforge.net
/p
/${repo}/code
/ci
/"
124 *://sourceware.org/*)
125 repo=$(echo "${remote}" | sed -e 's,.*/,,' -e 's,[.]git$,,')
126 url="https
://sourceware.org
/git
/?p
=${repo}.git
;a
=commit
;h
="
129 repo=$(echo "${remote}" | sed -e 's,.*/,,' -e 's,[.]git$,,')
130 url="https
://gcc.gnu.org
/git
/?p
=${repo}.git
;a
=commit
;h
="
132 *.googlesource.com/*)
133 url="${remote%.git}/+/"
135 *://git.enlightenment.org/*)
136 repo=$(echo "${remote}" | sed -e 's,^[^/]*//[^/]*/,,' -e 's,[.]git$,,')
137 url="https
://git.enlightenment.org
/${repo}.git
/commit
/?id
="
140 repo=$(echo "${remote}" | sed -e 's,^[^/]*//[^/]*/,,' -e 's,[.]git$,,')
141 url="https
://git.qemu.org
/?p
=${repo}.git
;a
=commit
;h
="
143 *://git.kernel.org/*)
144 repo=$(echo "${remote}" | sed -e 's,^[^/]*//[^/]*/,,' -e 's,[.]git$,,')
145 url="https
://git.kernel.org
/${repo}.git
/commit
/?id
="
148 echo "Unknown remote
: '${remote}'"
153 git log -n3 ${1:-HEAD} | sed "s
,^commit
,${url},"
157 if [[ $# -eq 0 ]] ; then
161 URL = "http
://sources.gentoo.org
/" gensub(/.*svnroot\/([^/]*).*/, "\\1", 1);
162 } else if ($1 == "Revision
:") {
164 URL = URL "?
rev=" (rev + 1) "&view
=rev"
177 URL = "http
://sources.gentoo.org
" $1 "?
"
178 } else if ($1 == "Revision
:") {
180 URL = URL "r1
=" rev "&r2
=" (rev + 1)
189 Usage: $0 [options] [args]
202 while [[ $# -gt 0 ]] ; do
216 if [[ ${vcs} == "auto
" ]] ; then
217 if [[ -d CVS ]] ; then
219 elif svn info >&/dev/null ; then