Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
- merge new-product-generation-in-branch-release into trunk
Browse files Browse the repository at this point in the history
- feature: added -i --independent-branches option. This option will force
  to check if the last release was made from the same branch we are
  releasing from. This is required if you develop a new software generation
  in a branch which is independent from the trunk. Previous version of
  keas.build where only able to handle branch releases as bug fix releases
  and didn't make sure that we don't mix trunk and branch releases. Now with
  the -i option we force that all released packages will be made or reused
  based on the current trunk or branch (-b trunk,branch)
- added more logging infos for find or skip next version which makes is simpler
  to see what's going on
- prepare 0.3.0 release
  • Loading branch information
projekt01 committed Dec 26, 2012
1 parent e8684aa commit 6a3edfe
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 22 deletions.
14 changes: 12 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
CHANGES
=======

0.2.3 (unreleased)
0.3.0 (2012-12-27)
------------------

- Nothing changed yet.
- feature: added -i --independent-branches option. This option will force
to check if the last release was made from the same branch we are
releasing from. This is required if you develop a new software generation
in a branch which is independent from the trunk. Previous version of
keas.build where only able to handle branch releases as bug fix releases
and didn't make sure that we don't mix trunk and branch releases. Now with
the -i option we force that all released packages will be made or reused
based on the current trunk or branch (-b trunk,branch)

- added more logging infos for find or skip next version which makes is simpler
to see what's going on


0.2.2 (2011-08-29)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def read(*rnames):

setup(
name='keas.build',
version='0.2.3dev',
version='0.3.0',
author = "Stephan Richter and the Zope Community",
author_email = "zope-dev@zope.org",
description='A Build System',
Expand Down
5 changes: 5 additions & 0 deletions src/keas/build/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ def optionxform(self, optionstr):
dest="branch", metavar="BRANCH", default=None,
help="When specified, this branch will be always used.")

parser.add_option(
"-i", "--independent-branches", action="store_true",
dest="independent", metavar="INDEPENDENT", default=False,
help="When specified, the system makes sure the last release is based on the given branch.")

parser.add_option(
"--no-upload", action="store_true",
dest="noUpload", default=False,
Expand Down
2 changes: 2 additions & 0 deletions src/keas/build/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ installations)::
-n, --next-version When set, the system guesses the next version to generate.
-b BRANCH, --use-branch=BRANCH
When specified, this branch will be always used.
-i BRANCHES --independent-branches=BRANCH1 BRANCH2,
When specified, the system guesses the next version from all this branches.
--no-upload When set, the generated configuration files are not uploaded.
--no-branch-update When set, the branch is not updated with a new version after a release is created.

Expand Down
94 changes: 75 additions & 19 deletions src/keas/build/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,11 @@ def getBranches(self):
return branches

def hasChangedSince(self, version, branch):
# setup.py gets changed on the branch after the tag is created, so
# that the branch always has a later revision. So let's check the
# source directory instead.
# check if svn revision gets changed on the branch after the tag
# was created, so that the branch always has a later revision. Note
# that our last release was updating the version in setup.py which also
# forces a change after adding the tag. So let's check the source
# directory instead.
branchUrl = self.getBranchURL(branch) + '/src'
tagUrl = self.getTagURL(version)
changed = self.getRevision(branchUrl)[1] > self.getRevision(tagUrl)[1]
Expand All @@ -234,6 +236,36 @@ def hasChangedSince(self, version, branch):
branch, version))
return changed

def isLastReleaseFromBranch(self, version, branch):
# check if the dev marked version in setup.py from the given branch
# compares with our version we will guess. If so, this means no
# other branch was used for release this package.
branchURL = self.getBranchURL(branch)
if branchURL.endswith('/'):
branchURL = branchURL[:-1]
pyURL = '%s/setup.py' % branchURL
req = urllib2.Request(pyURL)
if self.packageIndexUsername:
base64string = base64.encodestring(
'%s:%s' % (self.packageIndexUsername,
self.packageIndexPassword))[:-1]
req.add_header("Authorization", "Basic %s" % base64string)
setuppy = urllib2.urlopen(req).read()
nextVersion = re.search("version ?= ?'(.*)',", setuppy)
if not nextVersion:
logger.error("No version = found in setup.py, cannot update!")
# prevent mess up, force ensure new release
return False
else:
nextVersion = nextVersion.groups()[0]
setupVersion = '%sdev' % base.guessNextVersion(version)
if setupVersion == nextVersion:
return True
else:
logger.info("Last release %s wasn't released from branch %r " % (
version, branch))
return False

def createRelease(self, version, branch):
logger.info('Creating release %r for %r from branch %r' %(
version, self.pkg, branch))
Expand Down Expand Up @@ -299,7 +331,7 @@ def createRelease(self, version, branch):
else:
logger.warn('Unknown uploadType: ' + self.uploadType)

# 5. Update the start branch to the next devel version
# 5. Update the start branch to the next development (dev) version
if not self.options.noBranchUpdate:
logger.info("Updating branch version metadata")
# 5.1. Check out the branch.
Expand Down Expand Up @@ -328,6 +360,9 @@ def createRelease(self, version, branch):
rmtree(buildDir)

def runCLI(self, configFile, askToCreateRelease=False, forceSvnAuth=False):
logger.info('-' * 79)
logger.info(self.pkg)
logger.info('-' * 79)
logger.info('Start releasing new version of ' + self.pkg)
# 1. Read the configuration file.
logger.info('Loading configuration file: ' + configFile)
Expand Down Expand Up @@ -391,23 +426,44 @@ def runCLI(self, configFile, askToCreateRelease=False, forceSvnAuth=False):
defaultVersion = forceVersion

if versions and not defaultVersion:
# 3.2. If the branch was specified, check whether it changed since
# the last release.
changed = False
if self.options.branch:
logger.info('Checking for changes since version %s; please wait...', versions[-1])
changed = self.hasChangedSince(
versions[-1], self.options.branch)
if not changed:
logger.info("No changes detected.")
else:
logger.info("Not checking for changes since version %s because no branch was specified.", versions[-1])
# 3.3. If the branch changed and the next version should be
# suggested, let's find the next version.
if self.options.nextVersion and changed:
defaultVersion = base.guessNextVersion(versions[-1])
if self.options.nextVersion:
# 3.2. If the branch was specified, check whether it changed
# since the last release or if independent is set, if the last
# release is based on the current branch
changed = False
if self.options.branch:
logger.info("Checking for changes since version %s; please "
"wait...", versions[-1])
changed = self.hasChangedSince(versions[-1],
self.options.branch)
if self.options.independent and not changed:
# only check if not already marked as changed
logger.info("Checking if last release is based on "
"branch %s; please wait...",
self.options.branch)
if not self.isLastReleaseFromBranch(versions[-1],
self.options.branch):
changed = True
if not changed:
logger.info("No changes detected.")
else:
logger.info("Not checking for changes since version %s "
"because no -b or --use-branch was specified.",
versions[-1])
# 3.3. If the branch changed and the next version should be
# suggested, let's find the next version.
if changed:
defaultVersion = base.guessNextVersion(versions[-1])
else:
defaultVersion = versions[-1]
else:
logger.info("Not checking for changes because -n or "
"--next-version was not used")
defaultVersion = versions[-1]
else:
logger.info(
"Not checking for changes because --force-version was used")

branch = self.options.branch
while True:
version = base.getInput(
Expand Down

0 comments on commit 6a3edfe

Please sign in to comment.