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

Side by Side Diff: tools/release/common_includes.py

Issue 1403293009: [Release] Make release scripts aware of packed tags (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Renamed test Created 5 years, 1 month 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 | « no previous file | tools/release/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 import urllib2 43 import urllib2
44 44
45 from git_recipes import GitRecipesMixin 45 from git_recipes import GitRecipesMixin
46 from git_recipes import GitFailedException 46 from git_recipes import GitFailedException
47 47
48 CHANGELOG_FILE = "ChangeLog" 48 CHANGELOG_FILE = "ChangeLog"
49 DAY_IN_SECONDS = 24 * 60 * 60 49 DAY_IN_SECONDS = 24 * 60 * 60
50 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$") 50 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$")
51 PUSH_MSG_NEW_RE = re.compile(r"^Version \d+\.\d+\.\d+$") 51 PUSH_MSG_NEW_RE = re.compile(r"^Version \d+\.\d+\.\d+$")
52 VERSION_FILE = os.path.join("include", "v8-version.h") 52 VERSION_FILE = os.path.join("include", "v8-version.h")
53 VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$")
54 53
55 # V8 base directory. 54 # V8 base directory.
56 V8_BASE = os.path.dirname( 55 V8_BASE = os.path.dirname(
57 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 56 os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
58 57
59 58
60 def TextToFile(text, file_name): 59 def TextToFile(text, file_name):
61 with open(file_name, "w") as f: 60 with open(file_name, "w") as f:
62 f.write(text) 61 f.write(text)
63 62
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return subprocess.check_output(cmd_line, shell=True, cwd=cwd) 198 return subprocess.check_output(cmd_line, shell=True, cwd=cwd)
200 else: 199 else:
201 return subprocess.check_call(cmd_line, shell=True, cwd=cwd) 200 return subprocess.check_call(cmd_line, shell=True, cwd=cwd)
202 except subprocess.CalledProcessError: 201 except subprocess.CalledProcessError:
203 return None 202 return None
204 finally: 203 finally:
205 sys.stdout.flush() 204 sys.stdout.flush()
206 sys.stderr.flush() 205 sys.stderr.flush()
207 206
208 207
208 def SanitizeVersionTag(tag):
209 version_without_prefix = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$")
210 version_with_prefix = re.compile(r"^tags\/\d+\.\d+\.\d+(?:\.\d+)?$")
211
212 if version_without_prefix.match(tag):
213 return tag
214 elif version_with_prefix.match(tag):
215 return tag[len("tags/"):]
216 else:
217 return None
218
219
220 def NormalizeVersionTags(version_tags):
221 normalized_version_tags = []
222
223 # Remove tags/ prefix because of packed refs.
224 for current_tag in version_tags:
225 version_tag = SanitizeVersionTag(current_tag)
226 if version_tag != None:
227 normalized_version_tags.append(version_tag)
228
229 return normalized_version_tags
230
231
209 # Wrapper for side effects. 232 # Wrapper for side effects.
210 class SideEffectHandler(object): # pragma: no cover 233 class SideEffectHandler(object): # pragma: no cover
211 def Call(self, fun, *args, **kwargs): 234 def Call(self, fun, *args, **kwargs):
212 return fun(*args, **kwargs) 235 return fun(*args, **kwargs)
213 236
214 def Command(self, cmd, args="", prefix="", pipe=True, cwd=None): 237 def Command(self, cmd, args="", prefix="", pipe=True, cwd=None):
215 return Command(cmd, args, prefix, pipe, cwd=cwd) 238 return Command(cmd, args, prefix, pipe, cwd=cwd)
216 239
217 def ReadLine(self): 240 def ReadLine(self):
218 return sys.stdin.readline().strip() 241 return sys.stdin.readline().strip()
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 623
601 # Takes a file containing the patch to apply as first argument. 624 # Takes a file containing the patch to apply as first argument.
602 def ApplyPatch(self, patch_file, revert=False): 625 def ApplyPatch(self, patch_file, revert=False):
603 try: 626 try:
604 self.GitApplyPatch(patch_file, revert) 627 self.GitApplyPatch(patch_file, revert)
605 except GitFailedException: 628 except GitFailedException:
606 self.WaitForResolvingConflicts(patch_file) 629 self.WaitForResolvingConflicts(patch_file)
607 630
608 def GetVersionTag(self, revision): 631 def GetVersionTag(self, revision):
609 tag = self.Git("describe --tags %s" % revision).strip() 632 tag = self.Git("describe --tags %s" % revision).strip()
610 if VERSION_RE.match(tag): 633 return SanitizeVersionTag(tag)
611 return tag
612 else:
613 return None
614 634
615 def GetRecentReleases(self, max_age): 635 def GetRecentReleases(self, max_age):
616 # Make sure tags are fetched. 636 # Make sure tags are fetched.
617 self.Git("fetch origin +refs/tags/*:refs/tags/*") 637 self.Git("fetch origin +refs/tags/*:refs/tags/*")
618 638
619 # Current timestamp. 639 # Current timestamp.
620 time_now = int(self._side_effect_handler.GetUTCStamp()) 640 time_now = int(self._side_effect_handler.GetUTCStamp())
621 641
622 # List every tag from a given period. 642 # List every tag from a given period.
623 revisions = self.Git("rev-list --max-age=%d --tags" % 643 revisions = self.Git("rev-list --max-age=%d --tags" %
624 int(time_now - max_age)).strip() 644 int(time_now - max_age)).strip()
625 645
626 # Filter out revisions who's tag is off by one or more commits. 646 # Filter out revisions who's tag is off by one or more commits.
627 return filter(lambda r: self.GetVersionTag(r), revisions.splitlines()) 647 return filter(lambda r: self.GetVersionTag(r), revisions.splitlines())
628 648
629 def GetLatestVersion(self): 649 def GetLatestVersion(self):
630 # Use cached version if available. 650 # Use cached version if available.
631 if self["latest_version"]: 651 if self["latest_version"]:
632 return self["latest_version"] 652 return self["latest_version"]
633 653
634 # Make sure tags are fetched. 654 # Make sure tags are fetched.
635 self.Git("fetch origin +refs/tags/*:refs/tags/*") 655 self.Git("fetch origin +refs/tags/*:refs/tags/*")
636 version = sorted(filter(VERSION_RE.match, self.vc.GetTags()), 656
657 all_tags = self.vc.GetTags()
658 only_version_tags = NormalizeVersionTags(all_tags)
659
660 version = sorted(only_version_tags,
637 key=SortingKey, reverse=True)[0] 661 key=SortingKey, reverse=True)[0]
638 self["latest_version"] = version 662 self["latest_version"] = version
639 return version 663 return version
640 664
641 def GetLatestRelease(self): 665 def GetLatestRelease(self):
642 """The latest release is the git hash of the latest tagged version. 666 """The latest release is the git hash of the latest tagged version.
643 667
644 This revision should be rolled into chromium. 668 This revision should be rolled into chromium.
645 """ 669 """
646 latest_version = self.GetLatestVersion() 670 latest_version = self.GetLatestVersion()
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 for (number, step_class) in enumerate([BootstrapStep] + step_classes): 896 for (number, step_class) in enumerate([BootstrapStep] + step_classes):
873 steps.append(MakeStep(step_class, number, self._state, self._config, 897 steps.append(MakeStep(step_class, number, self._state, self._config,
874 options, self._side_effect_handler)) 898 options, self._side_effect_handler))
875 for step in steps[options.step:]: 899 for step in steps[options.step:]:
876 if step.Run(): 900 if step.Run():
877 return 0 901 return 0
878 return 0 902 return 0
879 903
880 def Run(self, args=None): 904 def Run(self, args=None):
881 return self.RunSteps(self._Steps(), args) 905 return self.RunSteps(self._Steps(), args)
OLDNEW
« no previous file with comments | « no previous file | tools/release/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698