Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 29 lines (23 sloc) 0.628 kb
#!/usr/bin/env ruby
gem "octokit", ">= 2.7"
require "octokit"
DIR = "#{ENV["HOME"]}/src/gists"
def git(*args)
args.unshift "git"
puts args*" " if ARGV.include? "-d"
Kernel.system(*args)
end
def access_token
ENV.fetch("GIST_TOKEN") { File.read("#{ENV["HOME"]}/.gist").strip }
end
Octokit::Client.new(
access_token: access_token,
auto_paginate: true
).gists.each do |gist|
id = gist.id
if File.directory? "#{DIR}/gist-#{id}"
git "--git-dir=#{DIR}/gist-#{id}/.git", "--work-tree=#{DIR}/gist-#{id}", "pull", "-q"
else
git "clone", "-q", "git@gist.github.com:#{id}.git", "#{DIR}/gist-#{id}"
end
end
Jump to Line
Something went wrong with that request. Please try again.