forked from great-northern-diver/loon
-
Notifications
You must be signed in to change notification settings - Fork 2
/
changeVersion.tcl
executable file
·73 lines (54 loc) · 1.7 KB
/
changeVersion.tcl
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
#! /usr/bin/env tclsh
# Change in R description
set fDE [open "R/DESCRIPTION"]
set DE [read $fDE]
if {[regexp -line {^Version: .+$} $DE matched]} {
set oldVersion [string range $matched 9 end]
} else {
error "Version number not found"
}
puts "Old Version: $oldVersion"
if {[llength $argv] eq 0} {
## Increment current version
set nums [split $oldVersion .]
set new_nums [lreplace $nums end end\
[expr {[lindex $nums end]+1}]]
set newVersion [join $new_nums .]
} else {
set newVersion [lindex $argv 0]
}
puts "New Version: $newVersion"
if {![regsub -all -- $matched $DE\
[format "Version: %s" $newVersion]\
newDESCRIPTION]} {
error "could not replace version number in DESCRIPTION"
}
if {![regsub -all -- "\nDate: .+?\n" $newDESCRIPTION\
[format "\nDate: %s\n"\
[clock format [clock seconds] -format "%Y-%m-%d"]]\
newDESCRIPTION]} {
error "could not replace date in DESCRIPTION"
}
close $fDE
## Now overwrite the file
set fDE [open "R/DESCRIPTION" w]
puts -nonewline $fDE $newDESCRIPTION
close $fDE
## Now use sed to replace in place.
set pattern [format "s/loon_\%s\\.tar\\.gz/loon_%s\\.tar\\.gz/g"\
[regsub -all -- \\. $oldVersion \\.]\
[regsub -all -- \\. $newVersion \\.]]
# Change in website beta
# exec sed $pattern website/md/beta.md > website/md/beta.md
# Change in Makefile
exec sed -i .bak $pattern Makefile
# Change in makePkgIndex.tcl
cd Tcl
exec sed -i .bak s/$oldVersion/$newVersion/g makePkgIndex.tcl
exec tclsh makePkgIndex.tcl
cd ..
puts "\n\n DIFF on affected files\n ===================== \n\n"
set diff [exec git diff --unified=0 Makefile R/DESCRIPTION\
Tcl/makePkgIndex.tcl]
puts [exec egrep {^(\+|-)} << $diff]
puts "\n\n"