File: check_news.sh

package info (click to toggle)
postgis 3.5.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 69,528 kB
  • sloc: ansic: 162,229; sql: 93,970; xml: 53,139; cpp: 12,646; perl: 5,658; sh: 5,369; makefile: 3,435; python: 1,205; yacc: 447; lex: 151; pascal: 58
file content (129 lines) | stat: -rwxr-xr-x 3,741 bytes parent folder | download | duplicates (5)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh

usage() {
  echo "Usage: $0 [-v] [--ticket-refs] [--ticket-refs-skip-commits=<file>] [<sourcedir>]"
  echo "Sourcedir defaults to one directory above this script"
}


### COMMAND LINE PARSING
VERBOSE=no
TICKET_REFS=no
RD= # Root source dir
TICKET_REFS_SKIP_COMMITS=/dev/null
while [ $# -gt 0 ]; do
  if [ "$1" = "--help" ]; then
    usage
    exit 0
  elif [ "$1" = "-v" ]; then
    VERBOSE=yes
  elif [ "$1" = "--ticket-refs" ]; then
    TICKET_REFS="yes"
  elif [ "$1" = "--ticket-refs-skip-commits" ]; then
    shift
    TICKET_REFS_SKIP_COMMITS=$( cd $( dirname $1 ) && pwd )
  elif [ -z "${RD}" ]; then
    RD=$1
  else
    echo "ERROR: unrecognized extra argument $1" >&2
    usage >&2
    exit 1
  fi
  shift
done

if [ -z "${RD}" ]; then
  RD=`dirname $0`/..
fi

cd ${RD}

# Extract dates from NEWS file and check they
# are sorted correctly
pdate=$(date '+%Y/%m/%d') # most recent timestamp
prel=Unreleased
grep -B1 '^[0-9]\{4\}/[0-9]\{2\}/[0-9]\{2\}' NEWS |
  while read rel; do
    read date
    read sep
    ts=$( echo "${date}" | tr -d '/' )
    pts=$( echo "${pdate}" | tr -d '/' )
    if test $ts -gt $pts; then
      echo "FAIL: ${rel} (${date}) appears after ${prel} (${pdate})"
      exit 1
    fi
    if test "${VERBOSE}" = yes; then
      echo "INFO: ${rel} (${date}) before ${prel} (${pdate})"
    fi
    pts=${ts}
    prel=${rel}
  done
test $? = 0 || exit 1
echo "PASS: NEWS file entries are in good order"

if test "${TICKET_REFS}" = "yes"; then

  last_news_release=$( grep \
    -B1 '^[0-9]\{4\}/[0-9]\{2\}/[0-9]\{2\}' NEWS |
    head -1 | awk '{print $2}' )
  echo "INFO: Checking ticket refs in commits since tag '$last_news_release'"

  # If git is available, check that every ticket reference in
  # commit logs is also found in the NEWS file
  if which git > /dev/null && test -e .git; then
    git rev-list HEAD --not $last_news_release |
      grep -vwFf $TICKET_REFS_SKIP_COMMITS |
      xargs git log --no-walk --pretty='format:%B' |
      sed -En 's|#([0-9]+)|\a\1\n|;/\n/!b;s|.*\a||;P;D' |
      sort -nru |
    { failures=0; while read ref; do
      ref="#${ref}"
      if ! grep -qw "${ref}" NEWS; then
        # See if it is found in any stable branch older than this one
        # and hint if found
        foundin=
        for b in $(
            git branch --list stable-* |
            sort -n | sed '/^\*/q' | tac |
            grep -v '\*'
            )
        do
          if git show $b:NEWS |
              grep -qw "${ref}"
          then
            foundin=$b
            break
          fi
        done
        if test -n "$foundin"; then
          # Check if the match is in a published version
          if git show $foundin:NEWS |
              sed '/^[0-9]\{4\}\/[0-9]\{2\}\/[0-9]\{2\}/q' |
              grep -qw "${ref}"
          then
            # The match is in a still unpublished section, this should
            # not be considered an error in development, but should be
            # fixed before closing the releasing.
            echo "WARN: Ticket ${ref} missing from NEWS (but found in dev section of branch $foundin)"
          else
            echo "FAIL: Ticket ${ref} missing from NEWS (and found in release from branch $foundin!)"
          fi
        else
          echo "FAIL: Ticket ${ref} MISSING from NEWS (here and in older branches)"
        fi
        failures=$((failures+1))
        #exit 1
      else
        if test "${VERBOSE}" = yes; then
          echo "INFO: Ticket ${ref} found in NEWS"
        fi
      fi
    done; exit $failures; }
    test $? = 0 || exit $?
    echo "PASS: All ticket references in commits log found in NEWS"
  else
    echo "SKIP: GIT history cannot be checked (missing git or missing ${RD}/.git)"
  fi
fi

exit 0