forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_version_to.py
131 lines (121 loc) · 5.08 KB
/
set_version_to.py
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
import argparse, sys
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--version',
help='numeric product version')
parser.add_argument('-t', '--text', default=None,
help='text product version')
args = parser.parse_args()
if not args.version:
parser.print_help()
exit(1)
if not args.text:
args.text = args.version
filename = "..\CommonAssemblyInfo.cs"
commonAssemblyInfo = open(filename, "r").readlines()
for i in range(len(commonAssemblyInfo)):
line = commonAssemblyInfo[i]
if line.find("[assembly: Assembly") != -1:
if line.find("AssemblyVersion(") != -1 or line.find("AssemblyFileVersion(") != -1:
data = line.split('"')
data[1] = args.version
commonAssemblyInfo[i] = '"'.join(data)
if line.find("AssemblyInformationalVersion(") != -1:
data = line.split('"')
data[1] = args.text
commonAssemblyInfo[i] = '"'.join(data)
outfile = open(filename, "w")
outfile.writelines(commonAssemblyInfo)
filename = "..\GitExtensionsShellEx\GitExtensionsShellEx.rc"
gitExtensionsShellEx = open(filename, "r").readlines()
verData = ["0"] * 4
verSplitted = args.version.split('.')
for i in range(len(verSplitted)):
verData[i] = verSplitted[i]
for i in range(len(gitExtensionsShellEx)):
line = gitExtensionsShellEx[i]
if line.find("FILEVERSION") != -1:
data = line.split(' ')
data[2] = ','.join(verData) + '\n'
gitExtensionsShellEx[i] = ' '.join(data)
elif line.find("PRODUCTVERSION") != -1:
data = line.split(' ')
data[2] = ','.join(verData) + '\n'
gitExtensionsShellEx[i] = ' '.join(data)
elif line.find('"FileVersion"') != -1:
data = line.split(', ', 1)
data[1] = '"' + '.'.join(verSplitted) + '"\n'
gitExtensionsShellEx[i] = ', '.join(data)
elif line.find('"ProductVersion"') != -1:
data = line.split(', ', 1)
data[1] = '"' + args.text + '"\n'
gitExtensionsShellEx[i] = ', '.join(data)
outfile = open(filename, "w")
outfile.writelines(gitExtensionsShellEx)
filename = "..\GitExtSshAskPass\SshAskPass.rc2"
gitExtSshAskPass = open(filename, "r").readlines()
verData = ["0"] * 4
verSplitted = args.version.split('.')
for i in range(len(verSplitted)):
verData[i] = verSplitted[i]
for i in range(len(gitExtSshAskPass)):
line = gitExtSshAskPass[i]
if line.find("FILEVERSION") != -1:
data = line.split(' ')
data[2] = ','.join(verData) + '\n'
gitExtSshAskPass[i] = ' '.join(data)
elif line.find("PRODUCTVERSION") != -1:
data = line.split(' ')
data[2] = ','.join(verData) + '\n'
gitExtSshAskPass[i] = ' '.join(data)
elif line.find('"FileVersion"') != -1:
data = line.split(', ', 1)
data[1] = '"' + '.'.join(verSplitted) + '"\n'
gitExtSshAskPass[i] = ', '.join(data)
elif line.find('"ProductVersion"') != -1:
data = line.split(', ', 1)
data[1] = '"' + args.text + '"\n'
gitExtSshAskPass[i] = ', '.join(data)
outfile = open(filename, "w")
outfile.writelines(gitExtSshAskPass)
for i in range(1, len(verSplitted)):
if len(verSplitted[i]) == 1:
verSplitted[i] = "0" + verSplitted[i]
filename = "MakeInstallers.cmd"
makeInstallers = open(filename, "r").readlines()
for i in range(len(makeInstallers)):
line = makeInstallers[i]
if line.find("set numericVersion=") != -1:
data = line.split('=')
data[1] = '.'.join(verSplitted) + '\n'
makeInstallers[i] = '='.join(data)
if line.find("set version=") != -1:
data = line.split('=')
data[1] = args.text + '\n'
makeInstallers[i] = '='.join(data)
outfile = open(filename, "w")
outfile.writelines(makeInstallers)
filename = "MakeMonoArchive.cmd"
makeInstallers = open(filename, "r").readlines()
for i in range(len(makeInstallers)):
line = makeInstallers[i]
if line.find("set version=") != -1:
data = line.split('=')
data[1] = args.text + '\n'
makeInstallers[i] = '='.join(data)
outfile = open(filename, "w")
outfile.writelines(makeInstallers)
filename = "..\GitExtensionsDoc\source\conf.py"
docoConf = open(filename, "r").readlines()
for i in range(len(docoConf)):
line = docoConf[i]
if line.find("release = ") != -1:
data = line.split(' = ')
data[1] = '.'.join(verSplitted)
docoConf[i] = " = '".join(data) + "'\n"
if line.find("version = ") != -1:
data = line.split(' = ')
data[1] = args.text
docoConf[i] = " = '".join(data) + "'\n"
outfile = open(filename, "w")
outfile.writelines(docoConf)