Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use tag commit date instead of tag date when finding PRs between tags #183

Merged
merged 2 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions cli/release_notes/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,37 @@ def last_tag(self):
def current_tag_info(self):
if not hasattr(self, '_current_tag_info'):
self._current_tag_info = self._get_tag_info(self.current_tag)
self._current_tag_info['commit'] = self._get_commit_info(
self._current_tag_info)
return self._current_tag_info

@property
def last_tag_info(self):
if not hasattr(self, '_last_tag_info'):
if self.last_tag:
self._last_tag_info = self._get_tag_info(self.last_tag)
self._last_tag_info['commit'] = self._get_commit_info(
self._last_tag_info)
else:
self._last_tag_info = None
return self._last_tag_info

def _get_commit_info(self, tag_info):
commit_sha = tag_info['tag']['object']['sha']
return self.call_api('/git/commits/{}'.format(commit_sha))

@property
def start_date(self):
tag_date = self.current_tag_info['tag']['tagger']['date']
return datetime.strptime(tag_date, "%Y-%m-%dT%H:%M:%SZ")
return self._get_commit_date(self.current_tag_info['commit'])

@property
def end_date(self):
if self.last_tag_info:
tag_date = self.last_tag_info['tag']['tagger']['date']
return datetime.strptime(tag_date, "%Y-%m-%dT%H:%M:%SZ")
return self._get_commit_date(self.last_tag_info['commit'])

def _get_commit_date(self, commit_info):
commit_date = commit_info['author']['date']
return datetime.strptime(commit_date, "%Y-%m-%dT%H:%M:%SZ")

def _get_tag_info(self, tag):
tag_info = {
Expand Down Expand Up @@ -195,7 +205,7 @@ def _include_pull_request(self, pull_request):
merged_date = datetime.strptime(merged_date, "%Y-%m-%dT%H:%M:%SZ")

# include PRs before current tag
if merged_date < self.start_date:
if merged_date <= self.start_date:
if self.end_date:
# include PRs after last tag
if merged_date > self.end_date:
Expand Down
Loading