déplacement depuis dépôt con...
|
1 |
#!/bin/bash |
2 | ||
3 |
source_path=${1:-"$HOME/scripts/flightgear/source"} |
|
4 | ||
5 |
function xmlgetnext () { |
|
6 |
local IFS='>' |
|
7 |
read -d '<' TAG VALUE |
|
8 |
# by design, the first TAG/VALUE pair is empty |
|
9 |
# to avoid infinite loops at end of file parsing we return an error |
|
10 |
# the next time we find an empty TAG |
|
11 |
if test -z "$TAG"; then |
|
12 |
test ${xmlgetnext_firstentry:-1} -eq 1 && xmlgetnext_firstentry=0 || return 1; |
|
13 |
fi |
|
14 |
# process $TAG only if necessary |
|
15 |
local _TAG=$(printf '%q' $TAG) |
|
16 |
if test ${_TAG:0:1} = '$'; then |
|
17 |
TAG=$(tr '\n' ' ' <<< $TAG | sed 's/ */ /g; s/ *$//') |
|
18 |
fi |
|
19 |
} |
|
20 | ||
21 |
exit_trap () { |
|
22 |
rm $apixml |
|
23 |
} |
|
24 | ||
25 |
function showRSS () { |
|
26 |
echo -e "${1^^}\n${1//[[:alnum:]]/-}" |
|
27 |
revparse=$(git -C "$source_path/$1" rev-parse HEAD) |
|
28 |
wget -qO- https://sourceforge.net/p/flightgear/$1/feed | while xmlgetnext; do |
|
29 |
case "${TAG:0:1}" in |
|
30 |
''|'?'|'!') |
|
31 |
continue;; |
|
32 |
/) |
|
33 |
property=${property%/*};; |
|
34 |
*) |
|
35 |
if test "${TAG: -1}" != '/'; then |
|
36 |
property+=/${TAG%% *} |
|
37 |
fi;; |
|
38 |
esac |
|
39 | ||
40 |
case "$property" in |
|
41 |
'/rss/channel/item/title') |
|
42 |
title=$VALUE |
|
43 |
;; |
|
44 |
'/rss/channel/item/link') |
|
45 |
sha1=${VALUE/https:\/\/sourceforge.net\/p\/flightgear\/${1}\/ci\/} |
|
46 |
;; |
|
47 |
'/rss/channel/item/pubDate') |
|
48 |
pubDate=$(date +'%e %B' -d "$VALUE") |
|
49 |
;; |
|
50 |
esac |
|
51 | ||
52 |
if test "$TAG" = "/item"; then |
|
53 |
if test $revparse/ = $sha1; then |
|
54 |
title="* ${title}" |
|
55 |
else |
|
56 |
title=" ${title}" |
|
57 |
fi |
|
58 |
echo "$title (${pubDate/# })" |
|
59 |
fi |
|
60 |
done |
|
61 |
} |
|
62 | ||
63 |
cat << EOF |
|
64 |
$(showRSS simgear) |
|
65 | ||
66 |
$(showRSS flightgear) |
|
67 | ||
68 |
$(showRSS fgdata) |
|
69 |
EOF |