def ask_what_to_release(self): """Show changes both in CHANGES.rst and on git history For that checkout the repository, show both changes to see if everything worth writing in CHANGES.rst from git history is already there. """ logger.info('') msg = 'What to release' logger.info(msg) logger.info('-' * len(msg)) to_release = [] for distribution_path in self.distributions: dist_name = distribution_path.split('/')[-1] repo = Repo(distribution_path) git_changes = get_compact_git_history( repo, self.last_tags[dist_name], self.branch, ) cleaned_git_changes = filter_git_history(git_changes) # a git history without any meaningful commit should not be # released if cleaned_git_changes == '': continue logger.info(DISTRIBUTION.format(distribution_path)) change_log_path = '{0}/CHANGES.rst'.format(repo.working_tree_dir) try: changes = self._grab_changelog(change_log_path) except IOError: logger.debug('Changelog not found, skipping.') continue self.changelogs[dist_name] = changes[2:] # nice to have: show them side-by-side logger.info('') logger.info(cleaned_git_changes) logger.info('') logger.info('') logger.info(''.join(changes)) msg = '{0}: write the above git history on CHANGES.rst?' if self.test and ask(msg.format(dist_name)): changelog = UpdateDistChangelog( distribution_path, branch=self.branch, ) changelog.write_changes(history=cleaned_git_changes) elif not self.test and \ ask('Is the change log ready for release?'): to_release.append(distribution_path) if not self.test: self.distributions = to_release logger.debug('Distributions: ') logger.debug('\n'.join(self.distributions))
def test_get_compact_git_history(self): """Check that the history is retrieved properly""" self._commit(self.user_repo, msg='Second commit') tag_name = 'my-tag' self.user_repo.create_tag(tag_name) self._commit(self.user_repo, msg='Third commit') self._commit(self.user_repo, msg='Forth commit') git_history = get_compact_git_history( self.user_repo, tag_name, 'master', ) self.assertIn( 'Forth commit', git_history ) self.assertIn( 'Third commit', git_history ) self.assertIn( 'Second commit', git_history ) self.assertNotIn( 'First commit', git_history )