|
3 | 3 | set -euo pipefail |
4 | 4 |
|
5 | 5 | function first_artifact_id() { |
6 | | - local bom_file="$1" |
7 | | - grep '<artifactId>' "$bom_file" | head -n 2 | tail -n 1 | sed 's/.*<artifactId>\(.*\)<\/artifactId>.*/\1/' |
| 6 | + local bom_file="$1" |
| 7 | + grep '<artifactId>' "$bom_file" | head -n 2 | tail -n 1 | sed 's/.*<artifactId>\(.*\)<\/artifactId>.*/\1/' |
8 | 8 | } |
9 | 9 |
|
10 | 10 | function add_dir() { |
11 | | - local dir="$1" |
12 | | - if [[ ! -d "$dir" ]]; then |
13 | | - echo "Directory $dir does not exist." |
14 | | - exit 1 |
15 | | - fi |
| 11 | + local dir="$1" |
| 12 | + if [[ ! -d "$dir" ]]; then |
| 13 | + echo "Directory $dir does not exist." |
| 14 | + exit 1 |
| 15 | + fi |
16 | 16 |
|
17 | | - if [[ $ignore_dirs =~ $dir ]]; then |
18 | | - echo "Skipping $dir" |
19 | | - return |
20 | | - fi |
| 17 | + if [[ $ignore_dirs =~ $dir ]]; then |
| 18 | + echo "Skipping $dir" |
| 19 | + return |
| 20 | + fi |
21 | 21 |
|
22 | | - if [[ ! -f "$dir/pom.xml" ]]; then |
23 | | - echo "File $dir/pom.xml does not exist." |
24 | | - exit 1 |
25 | | - fi |
| 22 | + if [[ ! -f "$dir/pom.xml" ]]; then |
| 23 | + echo "File $dir/pom.xml does not exist." |
| 24 | + exit 1 |
| 25 | + fi |
26 | 26 |
|
27 | | - artifact_id=$(first_artifact_id "$dir/pom.xml") |
28 | | - if [[ -z "$artifact_id" ]]; then |
29 | | - echo "No artifactId found in $dir/pom.xml" |
30 | | - exit 1 |
31 | | - fi |
| 27 | + artifact_id=$(first_artifact_id "$dir/pom.xml") |
| 28 | + if [[ -z "$artifact_id" ]]; then |
| 29 | + echo "No artifactId found in $dir/pom.xml" |
| 30 | + exit 1 |
| 31 | + fi |
32 | 32 |
|
33 | | - echo "Found artifactId '$artifact_id' in $dir/pom.xml" |
34 | | - # add to want |
35 | | - if [[ -z "${want+x}" ]]; then |
36 | | - want="$artifact_id" |
37 | | - else |
38 | | - want="$want |
| 33 | + echo "Found artifactId '$artifact_id' in $dir/pom.xml" |
| 34 | + # add to want |
| 35 | + if [[ -z "${want+x}" ]]; then |
| 36 | + want="$artifact_id" |
| 37 | + else |
| 38 | + want="$want |
39 | 39 | $artifact_id" |
40 | | - fi |
| 40 | + fi |
41 | 41 | } |
42 | 42 |
|
43 | 43 | declare want |
44 | 44 | ignore_dirs="prometheus-metrics-parent" |
45 | 45 |
|
46 | 46 | for dir in prometheus-metrics*; do |
47 | | - add_dir "$dir" |
| 47 | + add_dir "$dir" |
48 | 48 | done |
49 | | -for dir in prometheus-metrics-tracer/prometheus-metrics* ; do |
50 | | - if [[ -d "$dir" ]]; then |
51 | | - add_dir "$dir" |
52 | | - fi |
| 49 | +for dir in prometheus-metrics-tracer/prometheus-metrics*; do |
| 50 | + if [[ -d "$dir" ]]; then |
| 51 | + add_dir "$dir" |
| 52 | + fi |
53 | 53 | done |
54 | 54 |
|
55 | 55 | want=$(echo "$want" | sort | uniq) |
56 | | -have="$(grep '<artifactId>prometheus-metrics' prometheus-metrics-bom/pom.xml | sed 's/.*<artifactId>\(.*\)<\/artifactId>.*/\1/'| sort)" |
| 56 | +have="$(grep '<artifactId>prometheus-metrics' prometheus-metrics-bom/pom.xml | sed 's/.*<artifactId>\(.*\)<\/artifactId>.*/\1/' | sort)" |
57 | 57 |
|
58 | 58 | if [[ "$want" != "$have" ]]; then |
59 | | - echo "The BOM file prometheus-metrics-bom/bom.xml does not match the current directory contents." |
60 | | - echo "Expected: $want" |
61 | | - echo "Found: $have" |
| 59 | + echo "The BOM file prometheus-metrics-bom/bom.xml does not match the current directory contents." |
| 60 | + echo "Expected: $want" |
| 61 | + echo "Found: $have" |
62 | 62 |
|
63 | | - diff -u <(echo "$have" ) <(echo "$want") |
| 63 | + diff -u <(echo "$have") <(echo "$want") |
64 | 64 |
|
65 | | - exit 1 |
| 65 | + exit 1 |
66 | 66 | else |
67 | | - echo "BOM file is up to date." |
| 67 | + echo "BOM file is up to date." |
68 | 68 | fi |
0 commit comments