-
Notifications
You must be signed in to change notification settings - Fork 2
/
R-fixup-NEWS
executable file
·81 lines (75 loc) · 2.25 KB
/
R-fixup-NEWS
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
#!/bin/bash -x
# This script fixes up doc/NEWS.Rd in r-release-branch and r-devel
# The script must be called with a single argument, containing the
# dot-separated major.minor.pl version string, e.g. "R-fixup-NEWS 3.6.2"
# These two lines require local customization
LOCALDIR=$HOME
RELDIR=$HOME/R-release/
#--- no changes should be necessary below this line
REL=$*
BASEDIR=$LOCALDIR/r-release-branch
SRCDIR=$BASEDIR/R
BASEDIR_D=$LOCALDIR/r-devel
SRCDIR_D=$BASEDIR_D/R
umask 022
# Safeguard against invokation w/o argument
test -n "$REL" || exit
for SRC in $SRCDIR $SRCDIR_D ; do
cd $SRC
svn up doc/NEWS.Rd
# NB: Three layers of quoting hell: shell, R, and grep, hence the octuple \
# NB2: logic is different for .0 releases, must run AFTER branching
Rscript - << EOF
NEWS <- readLines("doc/NEWS.Rd")
pl <- strsplit("$REL","\\\\.")[[1]][3]
if (pl != "0") {
fixme <- grep("^\\\\\\\\section.* patched", NEWS)
if (length(fixme) == 0) stop("Cannot find section head for CHANGES IN R patched in $SRC")
if (length(fixme) > 1) stop("Multiple matches for CHANGES IN R patched in $SRC")
NEWS[fixme] <- sub("CHANGES IN R.*patched", "CHANGES IN R $REL", NEWS[fixme])
writeLines(NEWS,"doc/NEWS.Rd")
} else {
fixme <- grep("^\\\\\\\\section.* R-devel", NEWS)
if (length(fixme) == 0) stop("Cannot find section head for CHANGES IN R-devel in $SRC")
if (length(fixme) > 1) stop("Multiple matches for CHANGES IN R-devel in $SRC")
NEWS[fixme] <- sub("CHANGES IN R-devel", "CHANGES IN R $REL", NEWS[fixme])
if ("$SRC" == "$SRCDIR_D"){
template <- c(
"\\\\section{\\\\Rlogo CHANGES IN R-devel}{",
" \\\\subsection{SIGNIFICANT USER-VISIBLE CHANGES}{",
" \\\\itemize{",
" \\\\item .",
" }",
" }",
"",
" \\\\subsection{NEW FEATURES}{",
" \\\\itemize{",
" \\\\item .",
" }",
" }",
"",
" \\\\subsection{INSTALLATION}{",
" \\\\itemize{",
" \\\\item .",
" }",
" }",
"",
" \\\\subsection{PACKAGE INSTALLATION}{",
" \\\\itemize{",
" \\\\item .",
" }",
" }",
"",
" \\\\subsection{C-LEVEL FACILITIES}{",
" \\\\itemize{",
" \\\\item .",
" }",
" }",
"}")
NEWS <- append(NEWS, template, after = fixme - 1)
}
writeLines(NEWS,"doc/NEWS.Rd")
}
EOF
svn commit -m "fixup section header in NEWS" doc/NEWS.Rd
done