Created
September 13, 2013 20:48
-
-
Save tjl2/6555849 to your computer and use it in GitHub Desktop.
Add a commit comment with the GitHub API
This file contains hidden or 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
require 'rubygems' | |
require 'rest-client' | |
require 'json' | |
require 'pp' | |
@config = YAML.load(File.open('.github.yml')) | |
HOSTNAME = '' # add your GHE hostname here | |
USERNAME = '' # add your username here | |
PASSWORD = '' # add your password or OAuth token here | |
api_url = "http://#{USERNAME}:#{PASSWORD}@#{HOSTNAME}/api/v3/" | |
repo = '' # the name of the repo | |
sha = '' # the SHA of the commit | |
payload = { | |
'path' => 'something.rb', # the path to the file your comment applies to | |
'body' => 'This is your commment', | |
'position' => 1 # this is the line number of the of the diff output | |
} | |
json_response = JSON.parse(RestClient.post(@api_url + | |
"repos/#{USERNAME}/#{repo}/commits/#{sha}/comments", | |
payload.to_json, content_type: 'text/json')) | |
pp json_response | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment