| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 the V8 project authors. All rights reserved. | 2 # Copyright 2015 the V8 project authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import tempfile | 9 import tempfile |
| 10 import urllib2 | 10 import urllib2 |
| 11 | 11 |
| 12 from common_includes import * | 12 from common_includes import * |
| 13 | 13 |
| 14 class Preparation(Step): | 14 class Preparation(Step): |
| 15 MESSAGE = "Preparation." | 15 MESSAGE = "Preparation." |
| 16 | 16 |
| 17 def RunStep(self): | 17 def RunStep(self): |
| 18 fetchspecs = [ | 18 self.Git("fetch origin +refs/heads/*:refs/heads/*") |
| 19 "+refs/heads/*:refs/heads/*", | |
| 20 "+refs/pending/*:refs/pending/*", | |
| 21 "+refs/pending-tags/*:refs/pending-tags/*", | |
| 22 ] | |
| 23 self.Git("fetch origin %s" % " ".join(fetchspecs)) | |
| 24 self.GitCheckout("origin/master") | 19 self.GitCheckout("origin/master") |
| 25 self.DeleteBranch("work-branch") | 20 self.DeleteBranch("work-branch") |
| 26 | 21 |
| 27 | 22 |
| 28 class PrepareBranchRevision(Step): | 23 class PrepareBranchRevision(Step): |
| 29 MESSAGE = "Check from which revision to branch off." | 24 MESSAGE = "Check from which revision to branch off." |
| 30 | 25 |
| 31 def RunStep(self): | 26 def RunStep(self): |
| 32 self["push_hash"] = (self._options.revision or | 27 self["push_hash"] = (self._options.revision or |
| 33 self.GitLog(n=1, format="%H", branch="origin/master")) | 28 self.GitLog(n=1, format="%H", branch="origin/master")) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) | 143 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) |
| 149 changelog_entry = changelog_entry.lstrip() | 144 changelog_entry = changelog_entry.lstrip() |
| 150 | 145 |
| 151 if changelog_entry == "": # pragma: no cover | 146 if changelog_entry == "": # pragma: no cover |
| 152 self.Die("Empty ChangeLog entry.") | 147 self.Die("Empty ChangeLog entry.") |
| 153 | 148 |
| 154 # Safe new change log for adding it later to the candidates patch. | 149 # Safe new change log for adding it later to the candidates patch. |
| 155 TextToFile(changelog_entry, self.Config("CHANGELOG_ENTRY_FILE")) | 150 TextToFile(changelog_entry, self.Config("CHANGELOG_ENTRY_FILE")) |
| 156 | 151 |
| 157 | 152 |
| 153 class PushBranchRef(Step): |
| 154 MESSAGE = "Create branch ref." |
| 155 |
| 156 def RunStep(self): |
| 157 cmd = "push origin %s:refs/heads/%s" % (self["push_hash"], self["version"]) |
| 158 if self._options.dry_run: |
| 159 print "Dry run. Command:\ngit %s" % cmd |
| 160 else: |
| 161 self.Git(cmd) |
| 162 |
| 163 |
| 158 class MakeBranch(Step): | 164 class MakeBranch(Step): |
| 159 MESSAGE = "Create the branch." | 165 MESSAGE = "Create the branch." |
| 160 | 166 |
| 161 def RunStep(self): | 167 def RunStep(self): |
| 162 self.Git("reset --hard origin/master") | 168 self.Git("reset --hard origin/master") |
| 163 self.Git("checkout -b work-branch %s" % self["push_hash"]) | 169 self.Git("new-branch work-branch --upstream origin/%s" % self["version"]) |
| 164 self.GitCheckoutFile(CHANGELOG_FILE, self["latest_version"]) | 170 self.GitCheckoutFile(CHANGELOG_FILE, self["latest_version"]) |
| 165 self.GitCheckoutFile(VERSION_FILE, self["latest_version"]) | 171 self.GitCheckoutFile(VERSION_FILE, self["latest_version"]) |
| 166 self.GitCheckoutFile(WATCHLISTS_FILE, self["latest_version"]) | 172 self.GitCheckoutFile(WATCHLISTS_FILE, self["latest_version"]) |
| 167 | 173 |
| 168 | 174 |
| 169 class AddChangeLog(Step): | 175 class AddChangeLog(Step): |
| 170 MESSAGE = "Add ChangeLog changes to release branch." | 176 MESSAGE = "Add ChangeLog changes to release branch." |
| 171 | 177 |
| 172 def RunStep(self): | 178 def RunStep(self): |
| 173 changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE")) | 179 changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE")) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 if not text: # pragma: no cover | 222 if not text: # pragma: no cover |
| 217 self.Die("Commit message editing failed.") | 223 self.Die("Commit message editing failed.") |
| 218 self["commit_title"] = text.splitlines()[0] | 224 self["commit_title"] = text.splitlines()[0] |
| 219 TextToFile(text, self.Config("COMMITMSG_FILE")) | 225 TextToFile(text, self.Config("COMMITMSG_FILE")) |
| 220 | 226 |
| 221 self.GitCommit(file_name = self.Config("COMMITMSG_FILE")) | 227 self.GitCommit(file_name = self.Config("COMMITMSG_FILE")) |
| 222 os.remove(self.Config("COMMITMSG_FILE")) | 228 os.remove(self.Config("COMMITMSG_FILE")) |
| 223 os.remove(self.Config("CHANGELOG_ENTRY_FILE")) | 229 os.remove(self.Config("CHANGELOG_ENTRY_FILE")) |
| 224 | 230 |
| 225 | 231 |
| 226 class FixBrokenTag(Step): | |
| 227 MESSAGE = "Check for a missing tag and fix that instead." | |
| 228 | |
| 229 def RunStep(self): | |
| 230 commit = None | |
| 231 try: | |
| 232 commit = self.GitLog( | |
| 233 n=1, format="%H", | |
| 234 grep=self["commit_title"], | |
| 235 branch="origin/%s" % self["version"], | |
| 236 ) | |
| 237 except GitFailedException: | |
| 238 # In the normal case, the remote doesn't exist yet and git will fail. | |
| 239 pass | |
| 240 if commit: | |
| 241 print "Found %s. Trying to repair tag and bail out." % self["version"] | |
| 242 self.Git("tag %s %s" % (self["version"], commit)) | |
| 243 self.Git("push origin refs/tags/%s" % self["version"]) | |
| 244 return True | |
| 245 | |
| 246 | |
| 247 class PushBranch(Step): | 232 class PushBranch(Step): |
| 248 MESSAGE = "Push changes." | 233 MESSAGE = "Push changes." |
| 249 | 234 |
| 250 def RunStep(self): | 235 def RunStep(self): |
| 251 pushspecs = [ | 236 cmd = "cl land --bypass-hooks -f" |
| 252 "refs/heads/work-branch:refs/pending/heads/%s" % self["version"], | |
| 253 "%s:refs/pending-tags/heads/%s" % (self["push_hash"], self["version"]), | |
| 254 "%s:refs/heads/%s" % (self["push_hash"], self["version"]), | |
| 255 ] | |
| 256 cmd = "push origin %s" % " ".join(pushspecs) | |
| 257 if self._options.dry_run: | 237 if self._options.dry_run: |
| 258 print "Dry run. Command:\ngit %s" % cmd | 238 print "Dry run. Command:\ngit %s" % cmd |
| 259 else: | 239 else: |
| 260 self.Git(cmd) | 240 self.Git(cmd) |
| 261 | 241 |
| 262 | 242 |
| 263 class TagRevision(Step): | 243 class TagRevision(Step): |
| 264 MESSAGE = "Tag the new revision." | 244 MESSAGE = "Tag the new revision." |
| 265 | 245 |
| 266 def RunStep(self): | 246 def RunStep(self): |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 } | 292 } |
| 313 | 293 |
| 314 def _Steps(self): | 294 def _Steps(self): |
| 315 return [ | 295 return [ |
| 316 Preparation, | 296 Preparation, |
| 317 PrepareBranchRevision, | 297 PrepareBranchRevision, |
| 318 IncrementVersion, | 298 IncrementVersion, |
| 319 DetectLastRelease, | 299 DetectLastRelease, |
| 320 PrepareChangeLog, | 300 PrepareChangeLog, |
| 321 EditChangeLog, | 301 EditChangeLog, |
| 302 PushBranchRef, |
| 322 MakeBranch, | 303 MakeBranch, |
| 323 AddChangeLog, | 304 AddChangeLog, |
| 324 SetVersion, | 305 SetVersion, |
| 325 EnableMergeWatchlist, | 306 EnableMergeWatchlist, |
| 326 CommitBranch, | 307 CommitBranch, |
| 327 FixBrokenTag, | |
| 328 PushBranch, | 308 PushBranch, |
| 329 TagRevision, | 309 TagRevision, |
| 330 CleanUp, | 310 CleanUp, |
| 331 ] | 311 ] |
| 332 | 312 |
| 333 | 313 |
| 334 if __name__ == "__main__": # pragma: no cover | 314 if __name__ == "__main__": # pragma: no cover |
| 335 sys.exit(CreateRelease().Run()) | 315 sys.exit(CreateRelease().Run()) |
| OLD | NEW |