#! /usr/bin/env python """ Automates updating a patch.""" from gitCmds import GitRepo import utilityFunctions as utilityFunctions import os import sys if not len(sys.argv) > 1: print "Please specify a Drupal.org patch URL" sys.exit(1) git = GitRepo(os.getcwd()) git.cleanup() patch_filename = utilityFunctions.download_patch(sys.argv[1]) git.checkout(branch='old_patch', is_new_branch=True) git.apply_patch(patch_filename) git.commit('Old Patch') git.checkout(branch='new_patch', is_new_branch=True) utilityFunctions.open_diff_files_phpstorm(git.git_dir, patch_filename) print "Ready for development in new_patch. git add new changes and run generateNewPatch.py when done."
import sys import glob git = GitRepo(os.getcwd()) # Check if we're in new_patch branch and if old_patch exists if not git.check_old_new_correct(): print "Something is wrong with the branches, are you on new_patch? Exiting." sys.exit(1) # Make sure before commit that old_patch and new_patch diff is zero. if not git.diff('old_patch') == '': print "Something is wrong : the new_patch HEAD and old_patch are different" print "Committing changes to new_patch" git.commit('New Patch') for patch_filename in glob.glob('*.patch'): print patch_filename # Input block issue_no = raw_input("Enter The Issue #: ") issue_slug = raw_input("Enter The Issue Slug: ") arch_extra_info = raw_input("Enter The Arch/Extra Info: ") old_patch_no = raw_input("Enter The Old Patch Comment #: ") new_patch_no = raw_input("Enter The New Patch Comment #: ") new_patch_filename = "-".join([ issue_no, issue_slug, new_patch_no,
git.checkout( branch=project_string, is_new_branch=True, commit_hash=hash_to_checkout ) patch_result_output = git.patch(patch_filename, dry_run=True) if 'patch failed:' in patch_result_output or 'error: ' in patch_result_output: print "Patch doesn't apply cleanly on OLD hash, restart and try an older date." sys.exit(1) else: print 'Patch applied cleanly on OLD hash, applying patch with git' git.apply_patch(patch_filename) choice = raw_input("Wish to continue and rebase? ").lower() if choice in yes_values_list: thread_url = raw_input("Thread URL (with comment anchor)? ") git.commit('Applying patch from ' + thread_url) print git.rebase() choice = raw_input("Rebase Clean? ").lower() if choice in yes_values_list: print "Generating New Patch\n" new_patch_filename_string = raw_input("Patch Filename: ") git.diff('8.0.x', new_patch_filename_string) print "Patch Generated!" sys.exit(0) else: print "Rebase paused, add files and rebase --continue" sys.exit(1) print "Exiting due to concerns." sys.exit(1) else: print "Patch applies cleanly, reverting working directory."
#! /usr/bin/env python """ Automates updating a patch.""" from gitCmds import GitRepo import utilityFunctions as utilityFunctions import os import sys if not len(sys.argv) > 1: print "Please specify a Drupal.org patch URL" sys.exit(1) git = GitRepo(os.getcwd()) git.cleanup() patch_filename = utilityFunctions.download_patch(sys.argv[1]) git.checkout(branch = 'old_patch', is_new_branch=True) git.apply_patch(patch_filename) git.commit('Old Patch') git.checkout(branch='new_patch', is_new_branch=True) utilityFunctions.open_diff_files_phpstorm(git.git_dir, patch_filename) print "Ready for development in new_patch. git add new changes and run generateNewPatch.py when done."
import sys import glob git = GitRepo(os.getcwd()) # Check if we're in new_patch branch and if old_patch exists if not git.check_old_new_correct(): print "Something is wrong with the branches, are you on new_patch? Exiting." sys.exit(1) # Make sure before commit that old_patch and new_patch diff is zero. if not git.diff('old_patch') == '': print "Something is wrong : the new_patch HEAD and old_patch are different" print "Committing changes to new_patch" git.commit('New Patch') for patch_filename in glob.glob('*.patch'): print patch_filename # Input block issue_no = raw_input("Enter The Issue #: ") issue_slug = raw_input("Enter The Issue Slug: ") arch_extra_info = raw_input("Enter The Arch/Extra Info: ") old_patch_no = raw_input("Enter The Old Patch Comment #: ") new_patch_no = raw_input("Enter The New Patch Comment #: ") new_patch_filename = "-".join( [ issue_no, issue_slug,
print "Looks like " + hash_to_checkout + ' is the commit we need to roll back to...' project_string = raw_input("Enter a project string for branch: ") git.checkout(branch=project_string, is_new_branch=True, commit_hash=hash_to_checkout) patch_result_output = git.patch(patch_filename, dry_run=True) if 'patch failed:' in patch_result_output or 'error: ' in patch_result_output: print "Patch doesn't apply cleanly on OLD hash, restart and try an older date." sys.exit(1) else: print 'Patch applied cleanly on OLD hash, applying patch with git' git.apply_patch(patch_filename) choice = raw_input("Wish to continue and rebase? ").lower() if choice in yes_values_list: thread_url = raw_input("Thread URL (with comment anchor)? ") git.commit('Applying patch from ' + thread_url) print git.rebase() choice = raw_input("Rebase Clean? ").lower() if choice in yes_values_list: print "Generating New Patch\n" new_patch_filename_string = raw_input("Patch Filename: ") git.diff('8.0.x', new_patch_filename_string) print "Patch Generated!" sys.exit(0) else: print "Rebase paused, add files and rebase --continue" sys.exit(1) print "Exiting due to concerns." sys.exit(1) else: print "Patch applies cleanly, reverting working directory."