Last active
November 10, 2019 08:47
-
-
Save zamuro/1bb129f9141dedb0f4c4a0091f291edf to your computer and use it in GitHub Desktop.
Use chucknorris.io API to get random git commit messages
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/ruby | |
## PLACE THIS ON $HOME/bin (or wherever your $PATH executables are) and set appropiate permissions | |
require 'net/http' | |
require 'json' | |
def chuck | |
url = URI('https://api.chucknorris.io/jokes/random') | |
request = Net::HTTP.get(url) | |
response = JSON.parse(request) | |
response['value'] | |
end | |
system('git add .') | |
system("git commit -m '#{chuck}'") | |
system('git push origin $1') # being $1 a parameter for shell command. e.g.: chuckommit master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment