Debian Codegraph @

tools/verify_released_changelog.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 # Copyright The OpenTelemetry Authors
4 # SPDX-License-Identifier: Apache-2.0
5
6 set -euo pipefail
7
8 TARGET="${1:?Must provide target ref}"
9
10 FILE="CHANGELOG.md"
11 TEMP_DIR=$(mktempscip-shell system . . mktemp. -d)
12 echoscip-shell system . . echo. "Temp folder: $TEMP_DIR"
13
14 # Only the latest commit of the feature branch is available
15 # automatically. To diff with the base branch, we need to
16 # fetch that too (and we only need its latest commit).
17 gitscip-shell system . . git. fetch origin "${TARGET}" --depth=1
18
19 # Checkout the previous version on the base branch of the changelog to tmpfolder
20 gitscip-shell system . . git. --work-tree="$TEMP_DIR" checkout FETCH_HEAD $FILE
21
22 PREVIOUS_FILE="$TEMP_DIR/$FILE"
23 CURRENT_FILE="$FILE"
24 PREVIOUS_LOCKED_FILE="$TEMP_DIR/previous_locked_section.md"
25 CURRENT_LOCKED_FILE="$TEMP_DIR/current_locked_section.md"
26
27 # Extract released sections from the previous version
28 awkscip-shell system . . awk. '/^<!-- Released section -->/ {flag=1} /^<!-- Released section ended -->/ {flag=0} flagscip-shell filesystem . . `/^<!-- Released section -->/ {flag=1} /^<!-- Released section ended -->/ {flag=0} flag`.' "$PREVIOUS_FILE" > "$PREVIOUS_LOCKED_FILE"
29
30 # Extract released sections from the current version
31 awkscip-shell system . . awk. '/^<!-- Released section -->/ {flag=1} /^<!-- Released section ended -->/ {flag=0} flagscip-shell filesystem . . `/^<!-- Released section -->/ {flag=1} /^<!-- Released section ended -->/ {flag=0} flag`.' "$CURRENT_FILE" > "$CURRENT_LOCKED_FILE"
32
33 # Compare the released sections
34 if ! diffscip-shell system . . diff. -q "$PREVIOUS_LOCKED_FILE" "$CURRENT_LOCKED_FILE"; then
35 echoscip-shell system . . echo. "Error: The released sections of the changelog file have been modified."
36 diffscip-shell system . . diff. "$PREVIOUS_LOCKED_FILE" "$CURRENT_LOCKED_FILE"
37 rmscip-shell system . . rm. -rf "$TEMP_DIR"
38 falsescip-shell system . . false.
39 fi
40
41 rmscip-shell system . . rm. -rf "$TEMP_DIR"
42 echoscip-shell system . . echo. "The released sections remain unchanged."