• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2013 the V8 project authors. All rights reserved.
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are
5# met:
6#
7#     * Redistributions of source code must retain the above copyright
8#       notice, this list of conditions and the following disclaimer.
9#     * Redistributions in binary form must reproduce the above
10#       copyright notice, this list of conditions and the following
11#       disclaimer in the documentation and/or other materials provided
12#       with the distribution.
13#     * Neither the name of Google Inc. nor the names of its
14#       contributors may be used to endorse or promote products derived
15#       from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29import argparse
30import json
31import os
32import re
33import sys
34import urllib
35
36from common_includes import *
37import create_release
38
39
40class Preparation(Step):
41  MESSAGE = "Preparation."
42
43  def RunStep(self):
44    # Fetch unfetched revisions.
45    self.vc.Fetch()
46
47
48class FetchCandidate(Step):
49  MESSAGE = "Fetching V8 lkgr ref."
50
51  def RunStep(self):
52    # The roll ref points to the candidate to be rolled.
53    self.Git("fetch origin +refs/heads/lkgr:refs/heads/lkgr")
54    self["candidate"] = self.Git("show-ref -s refs/heads/lkgr").strip()
55
56
57class LastReleaseBailout(Step):
58  MESSAGE = "Checking last V8 release base."
59
60  def RunStep(self):
61    last_release = self.GetLatestReleaseBase()
62    commits = self.GitLog(
63        format="%H", git_hash="%s..%s" % (last_release, self["candidate"]))
64
65    if not commits:
66      print "Already pushed current candidate %s" % self["candidate"]
67      return True
68
69
70class CreateRelease(Step):
71  MESSAGE = "Creating release if specified."
72
73  def RunStep(self):
74    print "Creating release for %s." % self["candidate"]
75
76    args = [
77      "--author", self._options.author,
78      "--reviewer", self._options.reviewer,
79      "--revision", self["candidate"],
80      "--force",
81    ]
82
83    if self._options.work_dir:
84      args.extend(["--work-dir", self._options.work_dir])
85
86    if self._options.push:
87      self._side_effect_handler.Call(
88          create_release.CreateRelease().Run, args)
89
90
91class AutoPush(ScriptsBase):
92  def _PrepareOptions(self, parser):
93    parser.add_argument("-p", "--push",
94                        help="Create release. Dry run if unspecified.",
95                        default=False, action="store_true")
96
97  def _ProcessOptions(self, options):
98    if not options.author or not options.reviewer:  # pragma: no cover
99      print "You need to specify author and reviewer."
100      return False
101    options.requires_editor = False
102    return True
103
104  def _Config(self):
105    return {
106      "PERSISTFILE_BASENAME": "/tmp/v8-auto-push-tempfile",
107    }
108
109  def _Steps(self):
110    return [
111      Preparation,
112      FetchCandidate,
113      LastReleaseBailout,
114      CreateRelease,
115    ]
116
117
118if __name__ == "__main__":  # pragma: no cover
119  sys.exit(AutoPush().Run())
120