Retrieve recent v8 release information based on tags.

BUG=chromium:451975
TBR=tandrii@chromium.org
NOTRY=true
LOG=n

TEST=./script_test.py
TEST=tools/release/releases.py -c path/to/src

Review URL: https://codereview.chromium.org/869613007

Cr-Commit-Position: refs/heads/master@{#26325}
This commit is contained in:
machenbach 2015-01-29 06:21:31 -08:00 committed by Commit bot
parent eaae397c42
commit 60bd272f3a
3 changed files with 72 additions and 36 deletions

View File

@ -591,6 +591,24 @@ class Step(GitRecipesMixin):
except GitFailedException:
self.WaitForResolvingConflicts(patch_file)
def GetRecentReleases(self, max_age):
# Make sure tags are fetched.
self.Git("fetch origin +refs/tags/*:refs/tags/*")
# Current timestamp.
time_now = int(self._side_effect_handler.GetUTCStamp())
# List every tag from a given period.
revisions = self.Git("rev-list --max-age=%d --tags" %
int(time_now - max_age)).strip()
def IsTagged(revision):
return VERSION_RE.match(
self.Git("describe --tags %s" % revision).strip())
# Filter out revisions who's tag is off by one or more commits.
return filter(IsTagged, revisions.splitlines())
def GetLatestVersion(self):
# Use cached version if available.
if self["latest_version"]:

View File

@ -217,21 +217,6 @@ class RetrieveV8Releases(Step):
git_hash, master_position, master_hash, branch, version,
patches, body), self["patch"]
def GetReleasesFromMaster(self):
# TODO(machenbach): Implement this in git as soon as we tag again on
# master.
# tag_text = self.SVN("log https://v8.googlecode.com/svn/tags -v
# --limit 20")
# releases = []
# for (tag, revision) in re.findall(BLEEDING_EDGE_TAGS_RE, tag_text):
# git_hash = self.vc.SvnGit(revision)
# Add bleeding edge release. It does not contain patches or a code
# review link, as tags are not uploaded.
# releases.append(self.GetReleaseDict(
# git_hash, revision, git_hash, self.vc.MasterBranch(), tag, "", ""))
return []
def GetReleasesFromBranch(self, branch):
self.GitReset(self.vc.RemoteBranch(branch))
if branch == self.vc.MasterBranch():
@ -265,28 +250,58 @@ class RetrieveV8Releases(Step):
self.GitCheckoutFileSafe(VERSION_FILE, "HEAD")
return releases
def GetReleaseFromRevision(self, revision):
releases = []
try:
if (VERSION_FILE not in self.GitChangedFiles(revision) or
not self.GitCheckoutFileSafe(VERSION_FILE, revision)):
print "Skipping revision %s" % revision
return [] # pragma: no cover
branches = map(
str.strip,
self.Git("branch -r --contains %s" % revision).strip().splitlines(),
)
branch = ""
for b in branches:
if b == "origin/candidates":
branch = "candidates"
break
if b.startswith("branch-heads/"):
branch = b.split("branch-heads/")[1]
break
else:
print "Could not determine branch for %s" % revision
release, _ = self.GetRelease(revision, branch)
releases.append(release)
# Allow Ctrl-C interrupt.
except (KeyboardInterrupt, SystemExit): # pragma: no cover
pass
# Clean up checked-out version file.
self.GitCheckoutFileSafe(VERSION_FILE, "HEAD")
return releases
def RunStep(self):
self.GitCreateBranch(self._config["BRANCHNAME"])
branches = self.vc.GetBranches()
releases = []
if self._options.branch == 'recent':
# Get only recent development on candidates, beta and stable.
if self._options.max_releases == 0: # pragma: no cover
self._options.max_releases = 10
beta, stable = SortBranches(branches)[0:2]
releases += self.GetReleasesFromBranch(stable)
releases += self.GetReleasesFromBranch(beta)
releases += self.GetReleasesFromBranch(self.vc.CandidateBranch())
releases += self.GetReleasesFromBranch(self.vc.MasterBranch())
# List every release from the last 7 days.
revisions = self.GetRecentReleases(max_age=7 * 24 * 60 * 60)
for revision in revisions:
releases += self.GetReleaseFromRevision(revision)
elif self._options.branch == 'all': # pragma: no cover
# Retrieve the full release history.
for branch in branches:
for branch in self.vc.GetBranches():
releases += self.GetReleasesFromBranch(branch)
releases += self.GetReleasesFromBranch(self.vc.CandidateBranch())
releases += self.GetReleasesFromBranch(self.vc.MasterBranch())
else: # pragma: no cover
# Retrieve history for a specified branch.
assert self._options.branch in (branches +
assert self._options.branch in (self.vc.GetBranches() +
[self.vc.CandidateBranch(), self.vc.MasterBranch()])
releases += self.GetReleasesFromBranch(self._options.branch)

View File

@ -407,7 +407,7 @@ class ScriptTest(unittest.TestCase):
return "1999-07-31"
def GetUTCStamp(self):
return "100000"
return "1000000"
def Expect(self, *args):
"""Convenience wrapper."""
@ -1233,42 +1233,45 @@ Cr-Commit-Position: refs/heads/candidates@{#345}
Cmd("git fetch", ""),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], ""),
Cmd("git branch -r", " branch-heads/3.21\n branch-heads/3.3\n"),
Cmd("git reset --hard branch-heads/3.3", ""),
Cmd("git log --format=%H", "hash1\nhash_234"),
Cmd("git diff --name-only hash1 hash1^", ""),
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
Cmd("git rev-list --max-age=395200 --tags",
"bad_tag\nhash_234\nhash_123\nhash_345\n"),
Cmd("git describe --tags bad_tag", "3.23.42-1-deadbeef"),
Cmd("git describe --tags hash_234", "3.3.1.1"),
Cmd("git describe --tags hash_123", "3.21.2"),
Cmd("git describe --tags hash_345", "3.22.3"),
Cmd("git diff --name-only hash_234 hash_234^", VERSION_FILE),
Cmd("git checkout -f hash_234 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 1, 1)),
Cmd("git branch -r --contains hash_234", " branch-heads/3.3\n"),
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
Cmd("git log -1 --format=%s hash_234", ""),
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
Cmd("git log -1 --format=%ci hash_234", "18:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(22, 5)),
Cmd("git reset --hard branch-heads/3.21", ""),
Cmd("git log --format=%H", "hash_123\nhash4\nhash5\n"),
Cmd("git diff --name-only hash_123 hash_123^", VERSION_FILE),
Cmd("git checkout -f hash_123 -- %s" % VERSION_FILE, "",
cb=ResetVersion(21, 2)),
Cmd("git branch -r --contains hash_123", " branch-heads/3.21\n"),
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
Cmd("git log -1 --format=%s hash_123", ""),
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
Cmd("git log -1 --format=%ci hash_123", "03:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(22, 5)),
Cmd("git reset --hard origin/candidates", ""),
Cmd("git log --format=%H", "hash_345\n"),
Cmd("git diff --name-only hash_345 hash_345^", VERSION_FILE),
Cmd("git checkout -f hash_345 -- %s" % VERSION_FILE, "",
cb=ResetVersion(22, 3)),
Cmd("git branch -r --contains hash_345", " origin/candidates\n"),
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
Cmd("git log -1 --format=%s hash_345", ""),
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
Cmd("git log -1 --format=%ci hash_345", ""),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(22, 5)),
Cmd("git reset --hard origin/master", ""),
Cmd("git status -s -uno", "", cwd=chrome_dir),
Cmd("git checkout -f master", "", cwd=chrome_dir),
Cmd("git pull", "", cwd=chrome_dir),