File: json-summaries.sh

package info (click to toggle)
libreswan 5.2-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 81,632 kB
  • sloc: ansic: 129,988; sh: 32,018; xml: 20,646; python: 10,303; makefile: 3,022; javascript: 1,506; sed: 574; yacc: 511; perl: 264; awk: 52
file content (46 lines) | stat: -rwxr-xr-x 1,004 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

set -eu

if test "$#" -lt 2; then
    cat >>/dev/stderr <<EOF

Usage:

   $0 <rutdir> [- | <summary.json> ...]

Using <rutdir> (to map the abbreviated hash in the result directory
name onto a full hash) merge the <summary.json> files into a single
summaries.json on STDOUT.

'-' indicates the list of summary.json files is on stdin.

The test output is left unchanged.

EOF
    exit 1
fi

bindir=$(cd $(dirname $0) && pwd)

rutdir=$(cd $1 && pwd) ; shift

if test $# -eq 1 -a x"$1" = x"-" ; then
    cat
else
    for d in "$@"; do
	echo "$d"
    done
fi | while read d; do
    dir=$(dirname $d)
    rev=$(${bindir}/gime-git-rev.sh ${dir})
    # expand to full hash
    hash=$(git -C ${rutdir} show --no-patch --format=%H ${rev})
    # let any existing hash override above
    jq --arg hash "${hash}" \
       '.hash = if .hash? then .hash else $hash end | .directory = (input_filename|split("/")|.[-2])' \
	$(realpath ${d})
done | {
    # always output an array, even when empty
    jq -s .
}