-
Notifications
You must be signed in to change notification settings - Fork 5
/
cvsversion.tcl
executable file
·105 lines (92 loc) · 2.27 KB
/
cvsversion.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
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
#!/usr/bin/tclsh
# By David N. Welton <davidw@dedasys.com>
# $Id: cvsversion.tcl,v 1.2 2002/01/03 12:44:37 davidw Exp $
set newversionvar 0
proc newversion { } {
global newversionvar
puts stderr "New version"
set newversionvar 1
}
proc diffentries { {dir .} } {
global newversionvar
puts stderr "Diffentries for $dir"
set currentdir [ pwd ]
cd $dir
if { ! [ file exists ./CVS/Entries ] } {
puts stderr "You must be in a directory with a path to ./CVS/Entries."
}
if { ! [ file exists ./.OLDEntries ] } {
puts stderr "No OLDEntries file. It will be created."
set fl [ open ./.OLDEntries w ]
close $fl
}
set entries [ open ./CVS/Entries ]
set blob ""
while { [ gets $entries ln ] != -1 } {
lappend blob $ln
}
close $entries
set oldentries [ open ./.OLDEntries ]
set blob2 ""
while { [ gets $oldentries ln ] != -1 } {
lappend blob2 $ln
}
close $oldentries
if { $blob != $blob2 } {
newversion
}
foreach ln $blob {
# the regexp below scans for directories in CVS Entries files
if { [ regexp {^D/(.*)////$} "$ln" match dir ] } {
diffentries $dir
}
}
file copy -force ./CVS/Entries ./.OLDEntries
cd $currentdir
}
diffentries
if { $newversionvar == 0 } {
puts stderr "No changes, exiting."
} else {
if { [ file exists ./VERSION ] } {
set versionfile [ open ./VERSION "r" ]
gets $versionfile versionstring
close $versionfile
} else {
set versionstring "0.0.0"
}
if { ! [ regexp {([0-9]+)\.([0-9]+)\.([0-9]+)} $versionstring match major minor point ] } {
puts stderr "Problem with versionstring '$versionstring', exiting"
exit 1
}
set versionfile [ open ./VERSION "w" ]
while { 1 } {
puts -nonewline stderr "Current version: $major.$minor.$point. "
puts -nonewline stderr {Increment [M]ajor, m[I]nor, [P]oint release, or [A]bort? >>> }
gets stdin answer
switch [ string tolower $answer ] {
m {
incr major
set minor 0
set point 0
break
}
i {
incr minor
set point 0
break
}
p {
incr point
break
}
a {
puts stderr "Aborted"
break
}
}
}
puts $versionfile "$major.$minor.$point"
close $versionfile
puts stderr "Done, version is $major.$minor.$point"
}