Skip to content

Commit

Permalink
Builder|Fixed: Find previous build of same version for changelog
Browse files Browse the repository at this point in the history
The script was assuming the next oldest build is good for generating
the commit list.
  • Loading branch information
skyjake committed Mar 16, 2012
1 parent ca5c38f commit 552fd45
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 27 deletions.
67 changes: 44 additions & 23 deletions distrib/autobuild.py
Expand Up @@ -37,18 +37,18 @@ def create_build_event():
# Tag the source with the build identifier.
git_tag(todaysBuild)

prevBuild = builder.find_newest_event()['tag']
print 'The previous build is:', prevBuild
#prevBuild = builder.find_newest_event()['tag']
#print 'The previous build is:', prevBuild

if prevBuild == todaysBuild:
prevBuild = ''
#if prevBuild == todaysBuild:
# prevBuild = ''

# Prepare the build directory.
ev = builder.Event(todaysBuild)
ev.clean()

if prevBuild:
update_changes(prevBuild, todaysBuild)
#if prevBuild:
update_changes()


def todays_platform_release():
Expand Down Expand Up @@ -92,25 +92,47 @@ def todays_platform_release():
git_checkout(builder.config.BRANCH)


def update_changes(fromTag=None, toTag=None, debChanges=False):
def find_previous_tag(toTag, version):
builds = builder.events_by_time()
i = 0
while i < len(builds):
ev = builds[i][1]
if ev.tag() != toTag and (ev.version() is None or version is None or
ev.version().startswith(version)):
# This is good.
return ev.tag()
i += 1
# Nothing suitable found. Fall back to a more lax search.
return find_previous_tag(toTag, None)


def update_changes(debChanges=False):
"""Generates the list of commits for the latest build."""

if debChanges:
# Make sure we have the latest changes.
git_pull()
fromTag = aptrepo_find_latest_tag()
toTag = builder.config.BRANCH # Everything up to now.
else:
# Use the two most recent builds by default.
if fromTag is None or toTag is None:
builds = builder.events_by_time()
if len(builds) < 2: return
fromTag = builds[1][1].tag()
toTag = builds[0][1].tag()

changes = builder.Changes(fromTag, toTag)
toTag = todays_build_tag()

import build_version
build_version.find_version(quiet=True)

# Let's find the previous event of this version.
fromTag = find_previous_tag(toTag, build_version.DOOMSDAY_VERSION_FULL_PLAIN)

#if debChanges:
# # Make sure we have the latest changes.
# git_pull()
# fromTag = aptrepo_find_latest_tag(build_version.DOOMSDAY_VERSION_FULL_PLAIN)
# toTag = builder.config.BRANCH # Everything up to now.
#else:
# # Use the two most recent builds by default.
# if fromTag is None or toTag is None:
# fromTag, toTag = find_latest_tags(build_version.DOOMSDAY_VERSION_FULL_PLAIN)

if fromTag is None or toTag is None:
# Range not defined.
return

changes = builder.Changes(fromTag, toTag)

if debChanges:
# Only update the Debian changelog.
changes.generate('deb')
Expand All @@ -125,7 +147,6 @@ def update_changes(fromTag=None, toTag=None, debChanges=False):
os.system('dch --check-dirname-level 0 -v %s -b "%s"' % (debVer, msg))
else:
# Save version information.
build_version.find_version(quiet=True)
print >> file(builder.Event(toTag).file_path('version.txt'), 'wt'), \
build_version.DOOMSDAY_VERSION_FULL
print >> file(builder.Event(toTag).file_path('releaseType.txt'), 'wt'), \
Expand All @@ -138,7 +159,7 @@ def update_changes(fromTag=None, toTag=None, debChanges=False):
def update_debian_changelog():
"""Updates the Debian changelog at (distrib)/debian/changelog."""
# Update debian changelog.
update_changes(None, None, True)
update_changes(debChanges=True)


def rebuild_apt_repository():
Expand Down
11 changes: 7 additions & 4 deletions distrib/builder/event.py
Expand Up @@ -72,10 +72,8 @@ def version_from_filename(self, name):
ver = self.extract_version_from_filename(name)
if not ver and self.package_from_filename(name) == 'doomsday':
# Fall back to the event version, if it exists.
fn = self.file_path('version.txt')
if os.path.exists(fn):
return file(fn).read().strip()
# Could not be determined.
ev = self.version()
if ev: return ev
return ver

def extract_version_from_filename(self, name):
Expand All @@ -94,6 +92,11 @@ def extract_version_from_filename(self, name):
def tag(self):
return self.name

def version(self):
fn = self.file_path('version.txt')
if os.path.exists(fn): return file(fn).read().strip()
return None

def name(self):
return self.name

Expand Down

0 comments on commit 552fd45

Please sign in to comment.