youtube-dl: Fix to always choose the best resolution in the first place.
[nethome.git] / bin / changelogget
1 #! /bin/sh
2 # $Id$
3
4 v=true
5 if [ "$1" = "-q" ];then
6         v=false
7         shift
8 fi
9 changelog=""
10 if [ "$1" = "-n" ];then
11         changelog="$1"
12         shift
13 fi
14
15 function formatpatch
16 {
17         # --- src/gdb/ChangeLog   2008/04/24 08:46:17     1.9308
18         diffdecvs | if [ -z "$changelog" ];then perl -p -e '$r=qr/^(?:---|\Q+++\E) /o;$c=0 if m{$r}o;$c=1 if s{$r(?=\S+/ChangeLog(?:\t|$))}{### }o;s{^@@}{##} if $c;'; else cat; fi
19 }
20
21 if [ "$*" = "-f" ];then
22         formatpatch
23 else for arg in "$@";do
24         arg="$(echo "$arg"|sed 's/^https:/http:/')"
25         # http://sourceware.org/ml/gdb-cvs/2099-99/msg99999.html
26         if [ "$arg" != "${arg#http://sources.redhat.com/}" ];then
27                 arg="http://sourceware.org/${arg#http://sources.redhat.com/}"
28         fi
29         if [ "$arg" != "${arg#http://sourceware.org/ml/*-cvs/}" -a "$arg" != "${arg%.html}" ];then
30                 echo >&2 -n '+'
31                 echo "$arg"
32                 echo
33                 changelogget -q $changelog $(wget -q -O - "$arg" | sed -n -e 's/&amp;/\&/g' -e 's#^<a \+\(rel="nofollow"\)\? *href="\(.*\)">\2</a>$#\2#p')
34         elif [ "$arg" != "${arg#http://gcc.gnu.org/viewcvs[?]view=revision&revision=}" ];then
35                 echo >&2 -n '+'
36                 echo "$arg"
37                 echo
38                 changelogget -q $changelog $(wget -q -O - "$arg" | sed -n -e 's/&amp;/\&/g' -e 's#^.*<a href="\(/viewcvs/[^">]*\)"[^>]*>text changed<.*$#http://gcc.gnu.org\1#p')
39         elif [ "$arg" != "${arg#http://sourceware.org/ml/}" -a "$arg" != "${arg%.html}" ];then
40                 echo >&2 -n '#'
41                 echo "$arg"
42                 raw="$(wget -q -O - "$arg" | sed -n 's#^.*<a href="\(/cgi-bin/get-raw-msg[?][^"]*\)">Raw text</a>.*$#\1#p')"
43                 if [ -z "$raw" ];then
44                         echo >&2 "No raw URL found: $arg"
45                         exit 1
46                 fi
47                 wget -q -O - "http://sourceware.org$raw" | sed -n -e '/^Subject:/p' -e '/^$/,$p'
48         elif [ "$arg" != "${arg#http://sourceware.org/cgi-bin/cvsweb.cgi/src/}" ];then
49                 echo >&2 -n '.'
50                 wget -q -O - "$arg" | formatpatch
51         # http://gcc.gnu.org/viewcvs/trunk/ChangeLog?r1=154127&r2=154126&pathrev=154127
52         elif [ "$arg" != "${arg#http://gcc.gnu.org/viewcvs/}" ];then
53                 echo >&2 -n '.'
54                 wget -q -O - "$arg&view=patch" | formatpatch
55         else
56                 echo >&2 "Invalid URL: $arg"
57                 exit 1
58         fi
59 done;fi
60 if $v;then
61         echo >&2 OK
62 fi