Skip to content

Instantly share code, notes, and snippets.

@mgarciaisaia
Created December 5, 2014 03:35
Show Gist options
  • Save mgarciaisaia/46d0fb26c48746eb53c7 to your computer and use it in GitHub Desktop.
Save mgarciaisaia/46d0fb26c48746eb53c7 to your computer and use it in GitHub Desktop.
Locally clone all repos from a BitBucket team
#!/usr/bin/env ruby
# USAGE: ./clone ORG_NAME
# ( ./clone instedd )
require 'open-uri'
require 'json'
team = ARGV[0] || raise("Must specify organization name")
puts "Fetching https://bitbucket.org/!api/1.0/users/#{team}..."
data = JSON.parse(open("https://bitbucket.org/!api/1.0/users/#{team}").read)
data["repositories"].each do | repo |
# delete "echo" for _actually_ cloning them
system("echo #{repo["scm"]} clone https://bitbucket.org/#{team}/#{repo["slug"]}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment