def release(): """Release/publish the code. """ # Rebase and push the master with tags to origin. print("Here are the remaining TODO items:") print(bash('TODO.sh')) print() if not util.yes("Do you still want to rebase and push the master with tags " "to origin (y/n)?"): util.delayed_exit() git.rebase('-i', 'origin/master') git.push('--tags', 'origin', 'master') # Upload to PyPI. if not util.yes("Do you want to upload to PyPI (this is permanent!) " "(y/n)?"): util.delayed_exit() setup.sdist.upload() # Reset the version number. # In natu/__init__.py: set_version('None') # In CHANGES.txt: newheading = ('TBD (in `GitHub <https://github.com/kdavies4/natu>`_ ' 'only) -- Updates:') newlink = ('.. _vx.x.x: ' 'https://github.com/kdavies4/natu/archive/vx.x.x.zip') rpls = [(r'(<http://semver.org>`_\.)', r'\1\n\n' + newheading), (r'(Initial release\n\n\n)', r'\1%s\n' % newlink)] util.replace('CHANGES.txt', rpls)
def release(): """Release/publish the code. """ # Rebase and push the master with tags to origin. print("Here are the remaining TODO items:") print(bash('TODO.sh')) print() if not util.yes( "Do you still want to rebase and push the master with tags " "to origin (y/n)?"): util.delayed_exit() git.rebase('-i', 'origin/master') git.push('--tags', 'origin', 'master') # Upload to PyPI. if not util.yes("Do you want to upload to PyPI (this is permanent!) " "(y/n)?"): util.delayed_exit() setup.sdist.upload() # Reset the version number. # In CHANGES.txt: newheading = ('TBD (in `GitHub <https://github.com/kdavies4/natu>`_ ' 'only) -- Updates:') newlink = ('.. _vx.x.x: ' 'https://github.com/kdavies4/natu/archive/vx.x.x.zip') rpls = [(r'(<http://semver.org>`_\.)', r'\1\n\n' + newheading), (r'(Initial release\n\n\n)', r'\1%s\n' % newlink)] util.replace('CHANGES.txt', rpls)
def test_sync_changes(self): master_head_before = self.remote.lookup_branch('master').head remote_branch = self.remote.lookup_branch(REMOTE_BRANCH) remote_branch_head_before = remote_branch.head current_b = self.repo.current_branch # It is not a ff so it should fail self.assertRaises(core.GlError, current_b.publish, remote_branch) # Get the changes git.rebase(remote_branch) # Retry (this time it should work) current_b.publish(remote_branch) self.assertItemsEqual(['master', REMOTE_BRANCH], self.remote.listall_branches()) self.assertEqual(master_head_before.id, self.remote.lookup_branch('master').head.id) self.assertNotEqual(remote_branch_head_before.id, remote_branch.head.id) self.assertEqual(current_b.head.id, remote_branch.head.id)
def test_sync_changes(self): master_head_before = self.remote.lookup_branch('master').head remote_branch = self.remote.lookup_branch(REMOTE_BRANCH) remote_branch_head_before = remote_branch.head current_b = self.repo.current_branch # It is not a ff so it should fail self.assertRaises(core.GlError, current_b.publish, remote_branch) # Get the changes git.rebase(remote_branch) # Retry (this time it should work) current_b.publish(remote_branch) self.assertItemsEqual( ['master', REMOTE_BRANCH], self.remote.listall_branches()) self.assertEqual( master_head_before.id, self.remote.lookup_branch('master').head.id) self.assertNotEqual( remote_branch_head_before.id, remote_branch.head.id) self.assertEqual(current_b.head.id, remote_branch.head.id)
def release(): """Release/publish the documentation to the webpage. """ # Save the current state. branch = git('rev-parse', '--abbrev-ref', 'HEAD').stdout.rstrip() git.stash('save', "Work in progress while updating gh-pages branch") # Check out the gh-pages branch. try: git.checkout('gh-pages') except ErrorReturnCode_128: # Create the branch if necessary. git.checkout('-b', 'gh-pages') # Remove the existing files in the base folder. extensions = ['*.html', '*.inv'] fnames = util.multiglob('..', extensions) for fname in fnames: os.remove(fname) # Copy the new files to the base folder. fnames = util.multiglob(BUILD_DIR, extensions) for fname in fnames: shutil.copy(fname, '..') # Track the new files. fnames = util.multiglob('..', extensions) git.add(*fnames) # Copy but rename the folders referenced in the HTML files. # Github only recognizes images, stylesheets, and javascripts as folders. folders = [('_images', 'images'), ('_static', 'javascripts'), ] for (src, dst) in folders: dst = os.path.join('..', dst) # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new folder. shutil.copytree(os.path.join(BUILD_DIR, src), dst) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. html_fnames = glob(os.path.join('..', '*.html')) util.replace(html_fnames, folders) # Copy and rename the examples folder. src = os.path.join(BUILD_DIR, 'examples') dst = '../examples2' # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new files. os.mkdir(dst) for fname in os.listdir(src): shutil.copy(os.path.join(src, fname), os.path.join(dst, fname)) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. util.replace(html_fnames, [(r'"\./examples/', r'"./examples2/')]) # Update the sitemap. print(python('sitemap_gen.py', config="sitemap_conf.xml")) # Commit the changes. try: git.commit('-a', m="Rebuilt documentation") except ErrorReturnCode_1: pass # No changes to commit # If desired, rebase and push the changes to origin. print("The gh-pages branch has been updated and is currently checked out.") if util.yes("Do you want to rebase it and push the changes to " "origin (y/n)?"): git.rebase('-i', 'origin/gh-pages') git.push.origin('gh-pages') # Return to the original state. git.checkout(branch) try: git.stash.pop() except ErrorReturnCode_1: pass # No stash was necessary in the first place. print("Now back on " + branch)
def release(): """Release/publish the documentation to the webpage. """ # Save the current state. branch = git('rev-parse', '--abbrev-ref', 'HEAD').stdout.rstrip() git.stash('save', "Work in progress while updating gh-pages branch") # Check out the gh-pages branch. try: git.checkout('gh-pages') except ErrorReturnCode_128: # Create the branch if necessary. git.checkout('-b', 'gh-pages') # Remove the existing files in the base folder. extensions = ['*.html', '*.inv'] fnames = util.multiglob('..', extensions) for fname in fnames: os.remove(fname) # Copy the new files to the base folder. fnames = util.multiglob(BUILD_DIR, extensions) for fname in fnames: shutil.copy(fname, '..') # Track the new files. fnames = util.multiglob('..', extensions) git.add(*fnames) # Copy but rename the folders referenced in the HTML files. # Github only recognizes images, stylesheets, and javascripts as folders. folders = [ ('_images', 'images'), ('_static', 'javascripts'), ] for (src, dst) in folders: dst = os.path.join('..', dst) # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new folder. shutil.copytree(os.path.join(BUILD_DIR, src), dst) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. html_fnames = glob(os.path.join('..', '*.html')) util.replace(html_fnames, folders) # Copy and rename the examples folder. src = os.path.join(BUILD_DIR, 'examples') dst = '../examples2' # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new files. os.mkdir(dst) for fname in os.listdir(src): shutil.copy(os.path.join(src, fname), os.path.join(dst, fname)) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. util.replace(html_fnames, [(r'"\./examples/', r'"./examples2/')]) # Update the sitemap. print((python('sitemap_gen.py', config="sitemap_conf.xml"))) # Commit the changes. try: git.commit('-a', m="Rebuilt documentation") except ErrorReturnCode_1: pass # No changes to commit # If desired, rebase and push the changes to origin. print("The gh-pages branch has been updated and is currently checked out.") if util.yes("Do you want to rebase it and push the changes to " "origin (y/n)?"): git.rebase('-i', 'origin/gh-pages') git.push.origin('gh-pages') # Return to the original state. git.checkout(branch) try: git.stash.pop() except ErrorReturnCode_1: pass # No stash was necessary in the first place. print(("Now back on " + branch))