Last active
July 18, 2020 13:59
-
-
Save alebian/0d980893cad6da91ab88cdd05fa05513 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def checkout_to_master_and_delete_current_branch | |
current_branch = `git rev-parse --abbrev-ref HEAD`.strip | |
`git checkout master` | |
puts "Deleting branch #{current_branch}" | |
`git branch -D #{current_branch}` | |
puts "Fetching master" | |
`git fetch -p` | |
puts "Pulling master" | |
`git pull origin master` | |
end | |
def swap_file_names(file1, file2) | |
File.rename(File.new(file2), 'swap_file_aux') | |
File.rename(File.new(file1), file2) | |
File.rename(File.new('swap_file_aux'), file1) | |
end | |
case ARGV[0] | |
when 'checkout_to_master_and_delete_current_branch' | |
checkout_to_master_and_delete_current_branch | |
when 'swap_file_names' | |
swap_file_names(ARGV[1], ARGV[2]) | |
else | |
puts 'Wrong option' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment