def test_is_branch_synced_in_sync(self): """Check that synchronicity is tested correctly""" with OutputCapture() as output: result = is_branch_synced(self.user_repo) self.assertTrue(result) self.assertEqual( output.captured, '' )
def test_is_branch_synced_out_of_sync(self): """Check that synchronicity is tested correctly""" # add a remote commit self._commit(self.remote_repo, msg='Second commit') self.remote_repo.remote().push() with OutputCapture() as output: result = is_branch_synced(self.user_repo) self.assertFalse(result) self.assertEqual( output.captured, '' )
def test_is_branch_synced_non_existing_local_branch(self): """Check that if a branch does not exist locally it reports so""" with LogCapture() as output: result = is_branch_synced( self.user_repo, 'non-existing-branch' ) self.assertTrue(result) self.assertIn( 'non-existing-branch branch does not exist locally', self._get_logging_as_string(output) ) # output is shown on info level self.assertEqual( output.records[0].levelname, 'DEBUG' )
def test_update_buildout(self): """Check that repository is updated with commit message""" path = self.user_buildout_repo.working_tree_dir message = 'New versions: 345' with wrap_folder(path): with open('versions.cfg', 'w') as versions: versions.write('[versions]') full_release = FullRelease() full_release.commit_message = message full_release.update_buildout() commit = self.user_buildout_repo.commit() self.assertEqual( commit.message.strip(), message ) self.assertTrue(is_branch_synced(self.user_buildout_repo))
def check_pending_local_changes(self): """Check that the distributions do not have local changes""" logger.info('') msg = 'Check pending local changes' logger.info(msg) logger.info('-' * len(msg)) clean_distributions = [] for distribution_path in self.distributions: # nice to have: add some sort of progress bar like plone.releaser repo = Repo(distribution_path) dirty = False local_changes = False if repo.is_dirty(): dirty = True if not is_branch_synced(repo, branch=self.branch): local_changes = True if dirty or local_changes: msg = '{0} has non-committed/unpushed changes, ' \ 'it will not be released.' msg = msg.format(DISTRIBUTION.format(distribution_path)) logger.info(msg) continue clean_distributions.append(distribution_path) # if nothing is about to be released, do not filter the distributions if not self.test: if len(self.distributions) != len(clean_distributions): if not ask('Do you want to continue?', default=True): sys.exit() self.distributions = clean_distributions logger.debug('Distributions: ') logger.debug('\n'.join(self.distributions))
def test_is_branch_synced_non_existing_remote_branch(self): """Check that if a branch does not exist remotely it reports so""" # create a local branch branch_name = 'local-branch' self.user_repo.create_head(branch_name) self.user_repo.heads[branch_name].checkout() with LogCapture() as output: result = is_branch_synced( self.user_repo, branch_name ) self.assertFalse(result) self.assertIn( '{0} branch does not exist remotely'.format(branch_name), self._get_logging_as_string(output) ) # output is shown on info level self.assertEqual( output.records[0].levelname, 'DEBUG' )