Showing 2 changed files with 73 additions and 1 deletions
+69
.fgfs/fgcoderss
... ...
@@ -0,0 +1,69 @@
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
+4 -1
.fgfs/fgfs_function
... ...
@@ -14,6 +14,9 @@ function fgfs () {
14 14
             check)
15 15
                 test -r $HOME/.fgfs/jenkins-status && bash $HOME/.fgfs/jenkins-status
16 16
                 ;;
17
+            rss)
18
+                test -r $HOME/.fgfs/fgcoderss && bash $HOME/.fgfs/fgcoderss
19
+                ;;
17 20
             data)
18 21
                 for control_system update_command in ${(kv)control_system_data}; do
19 22
                     find $FGADDON \
... ...
@@ -202,7 +205,7 @@ function fgfs () {
202 205
                     unset control_system_data control_system update_command up
203 206
                     return
204 207
                     ;;
205
-                --update-(fgaddon|check))
208
+                --update-(fgaddon|check|rss))
206 209
                     update_fg ${fgfs_arg#--update-}
207 210
                     return
208 211
                     ;;