Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: tools/push-to-trunk/push_to_trunk.py

Issue 868693002: Calculate new version based on latest tag when pushing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/push-to-trunk/common_includes.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 the V8 project authors. All rights reserved. 2 # Copyright 2013 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 18 matching lines...) Expand all
29 import argparse 29 import argparse
30 import os 30 import os
31 import sys 31 import sys
32 import tempfile 32 import tempfile
33 import urllib2 33 import urllib2
34 34
35 from common_includes import * 35 from common_includes import *
36 36
37 PUSH_MSG_GIT_SUFFIX = " (based on %s)" 37 PUSH_MSG_GIT_SUFFIX = " (based on %s)"
38 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$") 38 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$")
39 VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$")
39 40
40 class Preparation(Step): 41 class Preparation(Step):
41 MESSAGE = "Preparation." 42 MESSAGE = "Preparation."
42 43
43 def RunStep(self): 44 def RunStep(self):
44 self.InitialEnvironmentChecks(self.default_cwd) 45 self.InitialEnvironmentChecks(self.default_cwd)
45 self.CommonPrepare() 46 self.CommonPrepare()
46 47
48 # Make sure tags are fetched.
49 self.Git("fetch origin +refs/tags/*:refs/tags/*")
50
47 if(self["current_branch"] == self.Config("TRUNKBRANCH") 51 if(self["current_branch"] == self.Config("TRUNKBRANCH")
48 or self["current_branch"] == self.Config("BRANCHNAME")): 52 or self["current_branch"] == self.Config("BRANCHNAME")):
49 print "Warning: Script started on branch %s" % self["current_branch"] 53 print "Warning: Script started on branch %s" % self["current_branch"]
50 54
51 self.PrepareBranch() 55 self.PrepareBranch()
52 self.DeleteBranch(self.Config("TRUNKBRANCH")) 56 self.DeleteBranch(self.Config("TRUNKBRANCH"))
53 57
54 58
55 class FreshBranch(Step): 59 class FreshBranch(Step):
56 MESSAGE = "Create a fresh branch." 60 MESSAGE = "Create a fresh branch."
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 # This points to the git hash of the last push on trunk. 106 # This points to the git hash of the last push on trunk.
103 self["last_push_trunk"] = last_push 107 self["last_push_trunk"] = last_push
104 # This points to the last bleeding_edge revision that went into the last 108 # This points to the last bleeding_edge revision that went into the last
105 # push. 109 # push.
106 # TODO(machenbach): Do we need a check to make sure we're not pushing a 110 # TODO(machenbach): Do we need a check to make sure we're not pushing a
107 # revision older than the last push? If we do this, the output of the 111 # revision older than the last push? If we do this, the output of the
108 # current change log preparation won't make much sense. 112 # current change log preparation won't make much sense.
109 self["last_push_bleeding_edge"] = last_push_bleeding_edge 113 self["last_push_bleeding_edge"] = last_push_bleeding_edge
110 114
111 115
112 # TODO(machenbach): Code similarities with bump_up_version.py. Merge after 116 class GetLatestVersion(Step):
113 # turning this script into a pure git script. 117 MESSAGE = "Get latest version from tags."
114 class GetCurrentBleedingEdgeVersion(Step):
115 MESSAGE = "Get latest bleeding edge version."
116 118
117 def RunStep(self): 119 def RunStep(self):
120 versions = sorted(filter(VERSION_RE.match, self.vc.GetTags()),
121 key=SortingKey, reverse=True)
122 self.StoreVersion(versions[0], "latest_")
123 self["latest_version"] = self.ArrayToVersion("latest_")
124
125 # The version file on master can be used to bump up major/minor at
126 # branch time.
118 self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch()) 127 self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
128 self.ReadAndPersistVersion("master_")
129 self["master_version"] = self.ArrayToVersion("master_")
119 130
120 # Store latest version. 131 if SortingKey(self["master_version"]) > SortingKey(self["latest_version"]):
121 self.ReadAndPersistVersion("latest_") 132 self["latest_version"] = self["master_version"]
122 self["latest_version"] = self.ArrayToVersion("latest_") 133 self.StoreVersion(self["latest_version"], "latest_")
123 print "Bleeding edge version: %s" % self["latest_version"] 134
135 print "Determined latest version %s" % self["latest_version"]
124 136
125 137
126 class IncrementVersion(Step): 138 class IncrementVersion(Step):
127 MESSAGE = "Increment version number." 139 MESSAGE = "Increment version number."
128 140
129 def RunStep(self): 141 def RunStep(self):
130 # Retrieve current version from last trunk push.
131 self.GitCheckoutFile(VERSION_FILE, self["last_push_trunk"])
132 self.ReadAndPersistVersion()
133 self["trunk_version"] = self.ArrayToVersion("")
134
135 if self["latest_build"] == "9999": # pragma: no cover
136 # If version control on bleeding edge was switched off, just use the last
137 # trunk version.
138 self["latest_version"] = self["trunk_version"]
139
140 if SortingKey(self["trunk_version"]) < SortingKey(self["latest_version"]):
141 # If the version on bleeding_edge is newer than on trunk, use it.
142 self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
143 self.ReadAndPersistVersion()
144
145 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will "
146 "fire up your EDITOR on %s so you can make arbitrary "
147 "changes. When you're done, save the file and exit your "
148 "EDITOR.)" % VERSION_FILE)):
149
150 text = FileToText(os.path.join(self.default_cwd, VERSION_FILE))
151 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
152 r"\g<space>%s" % str(int(self["build"]) + 1),
153 text)
154 TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE))
155 else:
156 self.Editor(os.path.join(self.default_cwd, VERSION_FILE))
157
158 # Variables prefixed with 'new_' contain the new version numbers for the 142 # Variables prefixed with 'new_' contain the new version numbers for the
159 # ongoing trunk push. 143 # ongoing trunk push.
160 self.ReadAndPersistVersion("new_") 144 self["new_major"] = self["latest_major"]
145 self["new_minor"] = self["latest_minor"]
146 self["new_build"] = str(int(self["latest_build"]) + 1)
161 147
162 # Make sure patch level is 0 in a new push. 148 # Make sure patch level is 0 in a new push.
163 self["new_patch"] = "0" 149 self["new_patch"] = "0"
164 150
165 self["version"] = "%s.%s.%s" % (self["new_major"], 151 self["version"] = "%s.%s.%s" % (self["new_major"],
166 self["new_minor"], 152 self["new_minor"],
167 self["new_build"]) 153 self["new_build"])
168 154
169 155
170 class PrepareChangeLog(Step): 156 class PrepareChangeLog(Step):
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 "PATCH_FILE": "/tmp/v8-push-to-trunk-tempfile-patch-file", 398 "PATCH_FILE": "/tmp/v8-push-to-trunk-tempfile-patch-file",
413 "COMMITMSG_FILE": "/tmp/v8-push-to-trunk-tempfile-commitmsg", 399 "COMMITMSG_FILE": "/tmp/v8-push-to-trunk-tempfile-commitmsg",
414 } 400 }
415 401
416 def _Steps(self): 402 def _Steps(self):
417 return [ 403 return [
418 Preparation, 404 Preparation,
419 FreshBranch, 405 FreshBranch,
420 PreparePushRevision, 406 PreparePushRevision,
421 DetectLastPush, 407 DetectLastPush,
422 GetCurrentBleedingEdgeVersion, 408 GetLatestVersion,
423 IncrementVersion, 409 IncrementVersion,
424 PrepareChangeLog, 410 PrepareChangeLog,
425 EditChangeLog, 411 EditChangeLog,
426 StragglerCommits, 412 StragglerCommits,
427 SquashCommits, 413 SquashCommits,
428 NewBranch, 414 NewBranch,
429 ApplyChanges, 415 ApplyChanges,
430 AddChangeLog, 416 AddChangeLog,
431 SetVersion, 417 SetVersion,
432 CommitTrunk, 418 CommitTrunk,
433 SanityCheck, 419 SanityCheck,
434 Land, 420 Land,
435 TagRevision, 421 TagRevision,
436 CleanUp, 422 CleanUp,
437 ] 423 ]
438 424
439 425
440 if __name__ == "__main__": # pragma: no cover 426 if __name__ == "__main__": # pragma: no cover
441 sys.exit(PushToTrunk().Run()) 427 sys.exit(PushToTrunk().Run())
OLDNEW
« no previous file with comments | « tools/push-to-trunk/common_includes.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698