diff options
author | Ryan S. Arnold <ryan.arnold@linaro.org> | 2016-12-21 23:13:38 -0600 |
---|---|---|
committer | Ryan S. Arnold <ryan.arnold@linaro.org> | 2016-12-21 23:13:38 -0600 |
commit | 4f29c7d385d2c67b431b7243df36647f2285e183 (patch) | |
tree | 861467e422c7a1d894d26ce099de741b6030b076 | |
parent | 6e9ebdb087f3ad8ffb5afe7d6f69c84644082b00 (diff) |
Derive -rc1 release-notes from a previous release branch.
The -rc1 candidate in an RNSeries will always track a snapshot
(per the rules in toNextCandidate()) and snapshots don't have
branches in the release-notes repository. Subsequenct candidates
(-rc2, -rcN) (and releases) will track a previous candidate which
will have a branch in the release-notes repository. For -rc1
candidate series we need to determine where to derive the
release-notes.
The -rc1 of the first GCC X.1 series needs to have the
release-notes derived from the template README.series.textile.
The -rc1 of subsequent series needs to have the release-notes
derived from the previous release in order to maintain
continuity of the release-notes across every series in the
GCC release.
We look to see if there is a previous release in the series
and if we don't find one we derive from the template.
Change-Id: I1c3d721d6c8a13763c9508d4d0bd49e7fc5c681f
-rw-r--r-- | linaropy/git/gitrepo.py | 4 | ||||
-rw-r--r-- | linaropy/rn/linaroseries.py | 9 | ||||
-rw-r--r-- | linaropy/rn/rnseries.py | 107 | ||||
-rw-r--r-- | linaropy/vers.py | 11 | ||||
-rw-r--r-- | rn.py | 4 |
5 files changed, 107 insertions, 28 deletions
diff --git a/linaropy/git/gitrepo.py b/linaropy/git/gitrepo.py index 37333b3..69e47bb 100644 --- a/linaropy/git/gitrepo.py +++ b/linaropy/git/gitrepo.py @@ -61,6 +61,10 @@ class GitRepo(object): return False return True + # See if the specified branch exists as a remote. + def remote_branch_exists(self, branch): + return self.branch_exists(self.remote_branchname(branch)) + def getbranch(self): try: with cd(self.repodir): diff --git a/linaropy/rn/linaroseries.py b/linaropy/rn/linaroseries.py index c8ea3e1..5c7f2ab 100644 --- a/linaropy/rn/linaroseries.py +++ b/linaropy/rn/linaroseries.py @@ -172,6 +172,15 @@ class LinaroSeries(Series): def toNext(self, seriestype, date=None, strict=False): return self.dispatchnext[seriestype](date, strict) + # This will return new LinaroSeries release from the previous month. + def toPreviousMonthsRelease(self): + prev_release = copy.deepcopy(self) + prev_release.seriestype = Series.series.index("release") + prev_release.spin.zero() + prev_release.rc.zero() + prev_release.date = self.date + relativedelta(months=-1) + + return prev_release def linaro_series_from_tag(tag=None): series = series_from_tag(tag) diff --git a/linaropy/rn/rnseries.py b/linaropy/rn/rnseries.py index 247fb6b..87dacb8 100644 --- a/linaropy/rn/rnseries.py +++ b/linaropy/rn/rnseries.py @@ -141,25 +141,92 @@ class RNSeries(object): self.track_series.branchname()) if not self.rn_series: logging.info("Looking for branch %s" % self.track_series.branchname()) - # The workdir for the first candidate series will be derived from - # the changes made to the master branch templates. The workdir for - # subsequent candidates and releases will be made based on the - # existing candidate or release branch. + + # The -rc1 candidate in an RNSeries will always track a snapshot + # (per the rules in toNextCandidate()) and snapshots don't have + # branches in the release-notes repository. Subsequenct candidates + # (-rc2, -rcN) (and releases) will track a previous candidate which + # will have a branch in the release-notes repository. For -rc1 + # candidate series we need to determine where to derive the + # release-notes. if not self.rn_clone.branch_exists(remote_track): - logging.info( - "Creating RNSeries based on branch " - + self.rn_template.getbranch()) + + # The -rc1 of the first GCC X.1 series needs to have the + # release-notes derived from the template README.series.textile. + # The -rc1 of subsequent series needs to have the release-notes + # derived from the previous release in order to maintain + # continuity of the release-notes across every series in the + # GCC release. + + # We look to see if there is a previous release in the series + # and if we don't find one we derive from the template. + + found_previous=None + prev_release = self.next_series + # Look two years back because that's the length of a supported + # release. + next_minor = self.next_series.package.version.minor + for x in xrange(1,25): + + # Search for the nearest previous release. We need to + # iterate through the minor variations blindly + # (unfortunately) because the release process doesn't follow + # a strict schedule with regard to date and minor number. + prev_release=prev_release.toPreviousMonthsRelease() + + while True: + try: + logging.info("looking for previous release branch " + "'%s'" % prev_release.branchname()) + if self.rn_clone.remote_branch_exists( + prev_release.branchname()): + logging.info ("previous release branch " + "'%s' exists." % prev_release.branchname()) + found_previous=prev_release + break + + prev_release.package.version.decrement_minor() + except ValueError: + break + + # Early exit if we've found a release. + if found_previous: + break + + # Restore the starting 'minor' for the next month. + prev_release.package.version.minor=next_minor + + if not found_previous: + track=self.rn_template.getbranch() + print_info( + "Deriving your release-notes from template branch " + "%s%s%s%s" + % (BOLD, RED, track, NC)) + else: + + # TODO: if we find a release series we need to increment the + # spin an search for that branch to determine whether there + # was a release respin. Keep incrementing until we discover + # no new spins and then we can select the previously + # identified spin. + logging.warning("Fixme: If the previous release had a spin " + "we aren't yet able to detect it yet.") + track=found_previous.branchname() + print_info( + "Deriving your release-notes from release branch " + "%s%s%s%s" + % (BOLD, RED, track, NC)) self.rn_series = Workdir( proj=self.proj, clone=self.rn_clone, workdir=self.next_series.shorttype(), - track=self.rn_template.getbranch(), + track=track, branchname=self.next_series.branchname()) else: - logging.info( - "Creating RNSeries based on branch " - + remote_track) + print_info( + "Deriving your release-notes from branch %s%s%s%s" + % (BOLD, RED, track, NC)) self.rn_series = Workdir( proj=self.proj, @@ -168,19 +235,9 @@ class RNSeries(object): track=remote_track, branchname=self.next_series.branchname()) - print_info( - " If you updated the template README.textile.series file" - " the changes will not be reflected in this series") - print_info( - " README.textile.series as this series is derived from" - " the %s%s%s%s" % (BOLD, RED, remote_track, NC)) - print_info( - " series release notes. Please make the changes to the" - " series README.textile.series file as well.") - - # TODO: Ask if the user would like to merge the changes in - # the template README.textile.series file instead of the - # long-winded warning above. + # TODO: Detect if the user changed the template README.textile or + # template README.textile.series and ask if they want to merge the + # changes into the new rn_series files. if not headless: answer = yninput( @@ -189,6 +246,8 @@ class RNSeries(object): if answer == "y": self.rn_series.edit(self._series) + # TODO: If there are multiple commits, the subsequent calls should use + # commit --amend. Add an 'amend' parameter to GitRepo::commit(). return self.rn_series.commit( "Added NEWS items for %s." % self.next_series.branchname()) diff --git a/linaropy/vers.py b/linaropy/vers.py index 097181c..27fc0ce 100644 --- a/linaropy/vers.py +++ b/linaropy/vers.py @@ -105,9 +105,13 @@ class Version(object): numtoks = numtoks - 1 return vers -# Helper function which returns a Version. - + def decrement_minor(self): + if self.minor and self.minor >= 1: + self.minor = self.minor - 1 + else: + raise ValueError("Minor must be greater than or equal to zero.") +# Helper function which returns a Version. def versionFromStr(version): if not isinstance(version, basestring): raise TypeError('input must be of type basestring') @@ -222,6 +226,9 @@ class Vers(object): def increment(self): self.val = self.val + 1 + def zero(self): + self.val = 0 + # Return the "-<val>" string or an empty string. def __str__(self): # Don't return @@ -62,10 +62,10 @@ def generate(track, to_date, to_series, gccsource, persist): logging.info("fsf revision is " + gccclone.get_fsf_revision()) if gccclone.tag_exists(track): - logging.info("%s is a tag. Creating Series from tag.") + logging.info("%s is a tag. Creating Series from tag." % track) track_series = linaro_series_from_tag(track) else: - logging.info("%s is a branch. Creating Series from branchname.") + logging.info("%s is a branch. Creating Series from branchname." % track) track_series = linaroSeriesFromBranchname(track) try: |