Skip to content

Commit 0e77aac

Browse files
committed
Add an optional caching step
If the folder .cache exists, it will be used to store the results of newest-releases.sh (with no arguments) and version-timestamps.sh (with particular arguments). Subsequent executions will dump the cached content, rather than querying the Internet again. This behavior is useful to do local development more rapidly.
1 parent 3810cb3 commit 0e77aac

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

newest-releases.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@
1111

1212
dir=$(cd "$(dirname "$0")" && pwd)
1313

14+
cacheFile=
15+
test -d .cache &&
16+
cacheFile=.cache/newest-releases &&
17+
test -f "$cacheFile" && cat "$cacheFile" && exit 1
18+
1419
test "$1" &&
1520
pomURL=$1 ||
1621
pomURL=https://raw.githubusercontent.com/scijava/pom-scijava/master/pom.xml
1722

1823
pomFile=$(mktemp -t status.scijava.org-XXXX)
1924
curl -fs "$pomURL" > "$pomFile"
2025

21-
mvn -B -U -Dverbose=true -f "$pomFile" -s settings.xml \
26+
result=$(mvn -B -U -Dverbose=true -f "$pomFile" -s settings.xml \
2227
-Dmaven.version.rules=file://$dir/rules.xml \
2328
versions:display-dependency-updates |
2429
# Standardize the output format for too-long G:A strings.
@@ -32,6 +37,8 @@ mvn -B -U -Dverbose=true -f "$pomFile" -s settings.xml \
3237
# Catch when there is no version update.
3338
sed 's/ *\.\.\.\.* *\([^ ]*\) */,\1,\1/' |
3439
# Sort the results.
35-
sort
40+
sort)
41+
42+
echo "$result" | tee $cacheFile
3643

3744
rm "$pomFile"

version-timestamps.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ do
172172
rest=${gav#*:}
173173
a=${rest%%:*}
174174
v=${rest#*:}
175-
processGAV "$g" "$a" "$v"
175+
cacheFile=.cache/"version-timestamps-$g-$a-$v"
176+
if [ -f "$cacheFile" ]; then cat "$cacheFile"
177+
elif [ -d .cache ]; then processGAV "$g" "$a" "$v" | tee "$cacheFile"
178+
else processGAV "$g" "$a" "$v"
179+
fi
176180
;;
177181
*)
178182
echo "[WARNING] Ignoring invalid argument: $1" 2>&1

0 commit comments

Comments
 (0)