File: mkchangelog

package info (click to toggle)
swi-prolog 6.6.6-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 82,312 kB
  • sloc: ansic: 322,250; perl: 245,822; sh: 6,651; java: 5,254; makefile: 4,423; cpp: 4,153; ruby: 1,594; yacc: 843; xml: 82; sed: 12; sql: 6
file content (202 lines) | stat: -rwxr-xr-x 3,415 bytes parent folder | download | duplicates (3)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash

# Generate old-style ChangeLog files from the GIT log. Ultimately we may
# wish to insert this into ChangeLog

footer=false
printdate=true
directory=.
modules=true
quiet=false
moduleoptions=
[ -z "$wiki"  ] && wiki=false
[ -z "$level" ] && level=+

export wiki level

done=false
while [ $done = false ]; do
    case "$1" in
	--footer)
		footer=true
		shift
		;;
	--nodate)
		printdate=false
		shift
		moduleoptions+="--nodate"
		;;
	--quiet)
		quiet=true
		shift
		;;
	--wiki)
		wiki=true
		shift
		;;
	--nomodules)
		modules=false
		shift
		;;
	--dir=*)
		directory="`echo $1 | sed 's/--dir=//'`"
		shift
		modules=false
		;;
	*)	done=true
		;;
    esac
done

tag="$1"

if [ -z "$tag" ]; then
   echo "Usage: `basename $0` option ... [version][..version] [path ...]"
   echo "Options:"
   echo "    --footer"
   echo "    --nodate"
   echo "    --nomodules"
   echo "    --dir=<dir>"
   exit 1
fi

# Ensure case-sensitive matching
LANG=C

case "$tag" in
   [0-9].[0-9]*.[0-9]*..[0-9].[0-9]*.[0-9]*)
	vfrom="$(echo $tag | sed 's/\.\..*//')"
	vto="$(echo $tag | sed 's/.*\.\.//')"
	;;
   V[0-9].[0-9]*.[0-9]*..V[0-9].[0-9]*.[0-9]*)
	vfrom="$(echo $tag | sed -e s/V//g -e 's/\.\..*//')"
	vto="$(echo $tag | sed -e s/V//g -e 's/.*\.\.//')"
	;;
   [0-9].[0-9]*.[0-9]*)
        vfrom="$tag"
	vto=
	;;
   V[0-9].[0-9]*.[0-9]*)
        vfrom="$(echo $tag | sed s/V//)"
	vto=
	;;
   *..*)
	vfrom="$(echo $tag | sed 's/\.\..*//')"
	vto="$(echo $tag | sed 's/.*\.\.//')"
	;;
esac
shift

vvtag()
{ case $1 in
    [0-9].[0-9]*.[0-9]*)
      echo V$1
      ;;
    *)
      echo $1
      ;;
  esac
}

if [ -z "$vto" ]; then
  opt=$(vvtag $vfrom)..
else
  opt="$(vvtag $vfrom)..$(vvtag $vto)"
fi

cd $directory

if [ "$quiet" = true ]; then
  git log "$opt" --pretty=format:"PATCH[%ad]%n%s%n%b" $* | \
	grep -q '^[A-Z][A-Z]*:'
  exit $?
fi

header ()
{ hdr="$*"

  if [ "$wiki" = true ]; then
    echo ---$level $hdr
  else
    hdr="$*"
    eq=`echo $hdr | sed 's/./=/g'`
    echo $eq
    echo $hdr
    echo $eq
  fi

  echo
}

(
if [ "$directory" = "." ]; then
  if [ -z "$vto" ]; then
    header "SWI-Prolog Changelog since version $vfrom"
  else
    header "SWI-Prolog Changelog from version $vfrom to $vto"
  fi
else
  header "Package `basename $directory`"
fi

git log "$opt" --pretty=format:"PATCH[%ad]%n%s%n%b" $* | awk '
BEGIN		{ doprint="false";
		  dateprinted="";
		}
/^PATCH[[]/	{ date="["  $2 " " $3 " " $5 "]";
		  doprint="false";
		  next;
	        }
/^[A-Z][A-Z]*:/	{ if ( dateprinted != date )
		  { if ( "'$printdate'" == "true" )
		    { printf("%s\n\n", date);
		    }
		    dateprinted = date;
		  }
		  printf(" * %s\n", $0);
		  doprint="true";
		  next;
		}
/.*/		{ if ( doprint == "true" )
		  { if ( $0 != "<unknown>" )
		    { printf("   %s\n", $0);
		    } else
		    { printf("\n");
		    }
		  }
		  next;
		}
' ) | fmt -ut

# Include submodules

mtag()
{ git ls-tree $1 $2 | awk '{print $3}'
}

if [ "$modules" = true ]; then
  level="$level+"

  echo

  for d in `git submodule -q foreach pwd`; do
    mfrom=$(mtag V$vfrom $d)
    if [ ! -z "$vto" ]; then
      mto=$(mtag V$vto $d)
    else
      mto=$(mtag HEAD $d)
    fi
    subopts=$mfrom..$mto

    if $0 --dir="$d" --quiet "$subopts"; then
      echo
      $0 --dir="$d" $moduleoptions "$subopts"
#   else
#     echo "Package `basename $d`: no changes"
    fi
  done
fi

if [ "$footer" = true ]; then
   header VERSION $tag
fi