File: get-changelog

package info (click to toggle)
rshim-user-space 2.2.2%2Bdebian-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 504 kB
  • sloc: ansic: 7,730; sh: 622; perl: 62; makefile: 43
file content (65 lines) | stat: -rwxr-xr-x 1,729 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
#
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Parse the top entry of debian/changelog and build a release note.
#
# Usage:
#   ./make_release_body.sh debian/changelog
#
# Output:
#   Prints the release body to stdout.

CHANGELOG_FILE="$1"
[ -z "$CHANGELOG_FILE" ] && {
  echo "Usage: $0 debian/changelog"
  exit 1
}

awk '
  BEGIN {
    top_version = ""
    second_version = ""
    in_top_entry = 0
  }

  # Match lines like: rshim (2.2.1) ...
  # Extract the version inside parentheses.
  # The first occurrence is top_version, the second is second_version.
  /^rshim \(/ {
    # Extract version from: rshim (X.Y.Z) ...
    match($0, /^rshim \(([^)]+)\)/, arr)
    this_version = arr[1]

    if (top_version == "") {
      top_version = this_version
      in_top_entry = 1
      next
    } else if (second_version == "") {
      second_version = this_version
      # As soon as we see the second version, we can stop collecting.
      # Because that means the top entry ends right before this line.
      exit
    }
  }

  # While we are in the top entry, collect the bullet points until we see -- or the next version.
  in_top_entry == 1 {
    # If we see a line starting with --, it means the top entry ended.
    if ($0 ~ /^ -- /) {
      in_top_entry = 0
      next
    }
    # Otherwise, collect the lines (these are the bullet points).
    top_entry_text = top_entry_text $0 "\n"
  }

  END {
    # If we never found a second_version, set it to something to avoid blank output.
    if (second_version == "") {
      second_version = "previous"
    }

    print "## Changelog (" top_version " compared to " second_version "):\n" top_entry_text
  }
' "$CHANGELOG_FILE"