Repository: yetus Updated Branches: refs/heads/master 7355288fe -> 26aef2689
YETUS-303. better sorting options for releasedocmaker Signed-off-by: Sean Busbey <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/yetus/repo Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/e58875dd Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/e58875dd Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/e58875dd Branch: refs/heads/master Commit: e58875ddcd549ef22d4bbca393aaabee2b78ee85 Parents: 7355288 Author: Allen Wittenauer <[email protected]> Authored: Fri Mar 18 12:36:48 2016 -0700 Committer: Sean Busbey <[email protected]> Committed: Fri Apr 1 22:14:13 2016 -0500 ---------------------------------------------------------------------- .../in-progress/releasedocmaker.md | 38 ++++++++++ release-doc-maker/releasedocmaker.py | 75 ++++++++++++++------ 2 files changed, 91 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/yetus/blob/e58875dd/asf-site-src/source/documentation/in-progress/releasedocmaker.md ---------------------------------------------------------------------- diff --git a/asf-site-src/source/documentation/in-progress/releasedocmaker.md b/asf-site-src/source/documentation/in-progress/releasedocmaker.md index 2a5f0cd..71d6619 100644 --- a/asf-site-src/source/documentation/in-progress/releasedocmaker.md +++ b/asf-site-src/source/documentation/in-progress/releasedocmaker.md @@ -114,6 +114,44 @@ $ releasedocmaker.py --project HBASE --version 1.0.0 --usetoday After using this option and release, don't forget to change JIRA's release date to match! +# Sorted Output + +Different projects may find one type of sort better than another, depending upon their needs. releasedocmaker supports two types of sorts and each provides two different options in the direction for that sort. + +## Resolution Date-base Sort + +By default, releasedocmaker will sort the output based upon the resolution date of the issue starting with older resolutions. This is the same as giving these options: + +```bash +$ releasedocmaker --sorttype=releasedate --sortorder=older +``` + +The order can be reversed so that newer issues appear on top by providing the 'newer' flag: + +```bash +$ releasedocmaker --sorttype=releasedate --sortorder=newer +``` + +In the case of multiple projects given on the command line, the projects will be interspersed. + +## Issue Number-based Sort + +An alternative to the date-based sort is to sort based upon the issue id. This may be accomplished via: + +```bash +$ releasedocmaker --sorttype=issueid --sortorder=asc +``` + +This will now sort by the issue id, listing them in lowest to highest (or ascending) order. + +The order may be reversed to list them in highest to lowest (or descending) order by providing the appropriate flag: + +```bash +$ releasedocmaker --sorttype=issueid --sortorder=dec +``` + +In the case of multiple projects given on the command line, the projects will be grouped and then sorted by issue id. + # Lint Mode In order to ensure proper formatting while using mvn site, releasedocmaker puts in periods (.) for fields that are empty or unassigned. This can be unsightly and not proper for any given project. There are also other things, such as missing release notes for incompatible changes, that are less than desirable. http://git-wip-us.apache.org/repos/asf/yetus/blob/e58875dd/release-doc-maker/releasedocmaker.py ---------------------------------------------------------------------- diff --git a/release-doc-maker/releasedocmaker.py b/release-doc-maker/releasedocmaker.py index 07a1124..5f28a73 100755 --- a/release-doc-maker/releasedocmaker.py +++ b/release-doc-maker/releasedocmaker.py @@ -36,10 +36,16 @@ try: except NameError: from sets import Set as set +import dateutil.parser + + + RELEASE_VERSION = {} NAME_PATTERN = re.compile(r' \([0-9]+\)') RELNOTE_PATTERN = re.compile('^\<\!\-\- ([a-z]+) \-\-\>') JIRA_BASE_URL = "https://issues.apache.org/jira" +SORTTYPE = 'resolutiondate' +SORTORDER = 'older' ASF_LICENSE = ''' <!--- @@ -98,13 +104,14 @@ def textsanitize(_str): # if release notes have a special marker, # we'll treat them as already in markdown format def processrelnote(_str): - fmt = RELNOTE_PATTERN.match(_str) - if fmt is None: - return textsanitize(_str) - else: - return { - 'markdown' : markdownsanitize(_str), - }.get(fmt.group(1),textsanitize(_str)) + fmt = RELNOTE_PATTERN.match(_str) + if fmt is None: + return textsanitize(_str) + else: + return { + 'markdown': markdownsanitize(_str), + }.get( + fmt.group(1), textsanitize(_str)) def mstr(obj): if obj is None: @@ -260,17 +267,32 @@ class Jira(object): return mstr(ret) def __cmp__(self, other): - selfsplit = self.get_id().split('-') - othersplit = other.get_id().split('-') - result = cmp(selfsplit[0], othersplit[0]) - if result != 0: - return result - else: - if selfsplit[1] < othersplit[1]: - return True - elif selfsplit[1] > othersplit[1]: - return False - return False + result = 0 + + if SORTTYPE == 'issueid': + # compare by issue name-number + selfsplit = self.get_id().split('-') + othersplit = other.get_id().split('-') + result = cmp(selfsplit[0], othersplit[0]) + if result == 0: + result = cmp(int(selfsplit[1]), int(othersplit[1])) + if result != 0: + if SORTORDER == 'dec': + if result == 1: + result = -1 + else: + result = 1 + elif SORTTYPE == 'resolutiondate': + dts = dateutil.parser.parse(self.fields['resolutiondate']) + dto = dateutil.parser.parse(other.fields['resolutiondate']) + result = cmp(dts, dto) + if result != 0: + if SORTORDER == 'newer': + if result == 1: + result = -1 + else: + result = 1 + return result def get_incompatible_change(self): if self.incompat is None: @@ -398,21 +420,21 @@ class Outputs(object): if params is None: params = {} self.params = params - self.base = open(base_file_name%params, 'w') + self.base = open(base_file_name % params, 'w') self.others = {} for key in keys: both = dict(params) both['key'] = key - self.others[key] = open(file_name_pattern%both, 'w') + self.others[key] = open(file_name_pattern % both, 'w') def write_all(self, pattern): both = dict(self.params) both['key'] = '' - self.base.write(pattern%both) + self.base.write(pattern % both) for key in self.others.keys(): both = dict(self.params) both['key'] = key - self.others[key].write(pattern%both) + self.others[key].write(pattern % both) def write_key_raw(self, key, _str): self.base.write(_str) @@ -501,6 +523,10 @@ def parse_args(): help="projects in JIRA to include in releasenotes", metavar="PROJECT") parser.add_option("-r", "--range", dest="range", action="store_true", default=False, help="Given versions are a range") + parser.add_option("--sortorder", dest="sortorder", type="string", metavar="TYPE", + default=SORTORDER, help="Sorting order for sort type (default: %s)"%SORTORDER) + parser.add_option("--sorttype", dest="sorttype", type="string", metavar="TYPE", + default=SORTTYPE, help="Sorting type for issues (default: %s)"%SORTTYPE) parser.add_option("-t", "--projecttitle", dest="title", type="string", help="Title to use for the project (default is Apache PROJECT)") parser.add_option("-u", "--usetoday", dest="usetoday", action="store_true", @@ -570,6 +596,11 @@ def main(): versions = [Version(v) for v in options.versions] versions.sort() + global SORTTYPE + SORTTYPE = options.sorttype + global SORTORDER + SORTORDER = options.sortorder + if options.title is None: title = projects[0] else:
