def add_repository(self, repository, summary): """Add repository changes into the builder.""" message_list = summary.commit_messages normalized_messages = CommitMessage.normalize_message_list( message_list) self.__entries.append( ChangelogRepositoryData(repository, summary, normalized_messages))
def test_merged_branch(self): git = self.git all_tags = git.query_tag_commits(self.git_dir, TAG_VERSION_PATTERN) self.run_git('checkout {branch}'.format(branch=self.MERGED_BRANCH)) commit_id = git.query_local_repository_commit_id(self.git_dir) _, messages = git.query_local_repository_commits_to_existing_tag_from_id( self.git_dir, commit_id, all_tags) self.assertEqual(1, len(messages)) normalized_messages = CommitMessage.normalize_message_list(messages) self.assertEqual(3, len(normalized_messages)) expected_messages = [ (' '*4 + 'feat(testC): added major_file\n' '\n' + ' '*4 + 'Interestingly enough, this is a BREAKING CHANGE.'), ' '*4 + 'feat(testB): added minor_file', ' '*4 + 'fix(testA): added patch_file' ] prototype = messages[0] for index, msg in enumerate(normalized_messages): self.assertEqual(prototype.author, msg.author) self.assertEqual(expected_messages[index], msg.message) # The dates might be off by one sec because of roundoff with # the sequential commits. Typically the times will be the same # but we check for the drift explicitly so the assertion failure # would make more sense should it be neither. prototype_date = dateutil.parser.parse(prototype.date) msg_date = dateutil.parser.parse(msg.date) one_sec = datetime.timedelta(0, 1) if msg_date + one_sec != prototype_date: self.assertEqual(prototype.date, msg.date)
def test_merged_branch(self): git = self.git all_tags = git.query_tag_commits(self.git_dir, TAG_VERSION_PATTERN) self.run_git('checkout {branch}'.format(branch=self.MERGED_BRANCH)) commit_id = git.query_local_repository_commit_id(self.git_dir) _, messages = git.query_local_repository_commits_to_existing_tag_from_id( self.git_dir, commit_id, all_tags) self.assertEqual(1, len(messages)) normalized_messages = CommitMessage.normalize_message_list(messages) self.assertEqual(3, len(normalized_messages)) expected_messages = [ (' ' * 4 + 'feat(testC): added major_file\n' '\n' + ' ' * 4 + 'Interestingly enough, this is a BREAKING CHANGE.'), ' ' * 4 + 'feat(testB): added minor_file', ' ' * 4 + 'fix(testA): added patch_file' ] prototype = messages[0] for index, msg in enumerate(normalized_messages): self.assertEqual(prototype.author, msg.author) self.assertEqual(expected_messages[index], msg.message) # The dates might be off by one sec because of roundoff with # the sequential commits. Typically the times will be the same # but we check for the drift explicitly so the assertion failure # would make more sense should it be neither. prototype_date = dateutil.parser.parse(prototype.date) msg_date = dateutil.parser.parse(msg.date) one_sec = datetime.timedelta(0, 1) if msg_date + one_sec != prototype_date: self.assertEqual(prototype.date, msg.date)
def add_repository(self, repository, summary): """Add repository changes into the builder.""" message_list = summary.commit_messages normalized_messages = CommitMessage.normalize_message_list(message_list) self.__entries.append(ChangelogRepositoryData( repository, summary, normalized_messages))