Skip to content

Instantly share code, notes, and snippets.

@mgreensmith
Created October 30, 2013 21:04
Show Gist options
  • Save mgreensmith/7240245 to your computer and use it in GitHub Desktop.
Save mgreensmith/7240245 to your computer and use it in GitHub Desktop.
Shows the timestamp of the HEAD commit of a remote branch in GitHub, without having to fetch it locally. Uses the octokit API client.
#!/usr/bin/env ruby
require 'rubygems'
require 'octokit'
REPO = 'analog-analytics/merchant-portal'
BRANCH = 'master'
# get a token with:
# curl -u '<username>' -d '{"scopes":["repo"],"note":"for CLI use"}' https://api.github.com/authorizations
#token = File.read( File.expand_path("~/.chef/deployer/github.token"))
token = 'a1b23ch78edfhcHAHAHAHA_NOT_REALLY_MY_TOKEN'
github = Octokit::Client.new( :access_token => token )
latest_commit_sha = github.ref(REPO,"heads/#{BRANCH}").object.sha
latest_commit = github.commit(REPO,latest_commit_sha)
puts latest_commit.commit.author.date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment