Skip to content

Instantly share code, notes, and snippets.

@alebian
Last active July 18, 2020 13:59
Show Gist options
  • Save alebian/0d980893cad6da91ab88cdd05fa05513 to your computer and use it in GitHub Desktop.
Save alebian/0d980893cad6da91ab88cdd05fa05513 to your computer and use it in GitHub Desktop.
#!/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