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 | ||
ajoute le suivi des commits ...
|
63 |
function showGitlab () { |
64 |
echo -e "${1^^}\n${1//[[:alnum:]]/-}" |
|
65 |
revparse=$(git -C "$source_path/$1" rev-parse HEAD) |
|
66 |
curl --silent https://gitlab.com/api/v4/projects/flightgear%2F${1,,}/repository/commits \ |
|
67 |
| jq -r '.[] | (.id + "|" + .title + "|" + .created_at)' \ |
|
68 |
| awk -v revparse=$revparse -F '|' ' |
|
69 |
{ |
|
70 |
printf("%s %s (%s)\n", |
|
71 |
$1 == revparse ? "*" : " ", |
|
72 |
$2, |
|
73 |
strftime("%e %B", mktime(gensub(/[^0-9]/, " ", "g", $3)))) |
|
74 |
} |
|
75 |
' |
|
76 |
} |
|
77 | ||
déplacement depuis dépôt con...
|
78 |
cat << EOF |
ajoute le suivi des commits ...
|
79 |
$(showGitlab OpenSceneGraph) |
80 | ||
déplacement depuis dépôt con...
|
81 |
$(showRSS simgear) |
82 | ||
83 |
$(showRSS flightgear) |
|
84 | ||
85 |
$(showRSS fgdata) |
|
86 |
EOF |