mr_github 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/bin/mr_github +4 -0
- data/lib/mr_github.rb +73 -0
- data/lib/mr_github/version.rb +3 -0
- data/mr_github.gemspec +22 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Josh Nichols
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# MrGithub
|
2
|
+
|
3
|
+
A tool for generating [mr](http://joeyh.name/code/mr/) a config that includes all GitHub repositories you can access. This makes it really easy to checkout and update all repositories you can access with a few commands.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it yourself as:
|
8
|
+
|
9
|
+
$ gem install mr_github
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
|
14
|
+
mr_github reads from a configuration at ~/.mr_github. It needs two configs like:
|
15
|
+
|
16
|
+
GITHUB_USERNAME=yourusername
|
17
|
+
GITHUB_PASSWORD=yourpassword
|
18
|
+
|
19
|
+
When those are set, there's a single command:
|
20
|
+
|
21
|
+
$ mr_github generate
|
22
|
+
|
23
|
+
This creates ~/.mrconfig containing all repositories the GITHUB_USER can access. You'll need mr installed to actually do the checkout. Most package managers have it available as the mr package:
|
24
|
+
|
25
|
+
$ sudo apt-get install mr
|
26
|
+
$ brew install mr
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/mr_github
ADDED
data/lib/mr_github.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'ghee'
|
5
|
+
require 'pry'
|
6
|
+
require 'dotenv'
|
7
|
+
require 'thor'
|
8
|
+
|
9
|
+
Dotenv.load "#{ENV['HOME']}/.mr_github"
|
10
|
+
|
11
|
+
module MrGithub
|
12
|
+
|
13
|
+
class MrConfig
|
14
|
+
def initialize(github_user, github_password)
|
15
|
+
@gh = Ghee.basic_auth(github_user, github_password)
|
16
|
+
end
|
17
|
+
|
18
|
+
def config
|
19
|
+
@config ||= begin
|
20
|
+
@config = StringIO.new
|
21
|
+
|
22
|
+
user = @gh.user
|
23
|
+
|
24
|
+
@config.puts "# That #{user.login} has access to directly"
|
25
|
+
@gh.user.repos.all.each do |repo|
|
26
|
+
@config.puts "[src/#{repo.owner.login.to_s}/#{repo.name.to_s}]"
|
27
|
+
@config.puts "checkout = git clone #{repo.ssh_url.to_s}"
|
28
|
+
@config.puts ""
|
29
|
+
end
|
30
|
+
|
31
|
+
@gh.orgs.each do |org|
|
32
|
+
@config.puts "# That #{user.login} has access to via #{org.login}"
|
33
|
+
@gh.orgs(org.login).repos.all.each do |repo|
|
34
|
+
next if repo == ["message", "Not Found"]
|
35
|
+
next if repo.name == 'rails' # don't need people's forks of rails
|
36
|
+
@config.puts "[src/#{repo.owner.login.to_s}/#{repo.name.to_s}]"
|
37
|
+
@config.puts "checkout = git clone #{repo.ssh_url.to_s}"
|
38
|
+
@config.puts ""
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
@config.string
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_s
|
48
|
+
config.to_s
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class App < Thor
|
53
|
+
include Thor::Actions
|
54
|
+
|
55
|
+
desc 'generate', 'Generate a ~/.mrconfig from GitHub repositories you can access'
|
56
|
+
def generate
|
57
|
+
github_user = ENV['GITHUB_USER']
|
58
|
+
if github_user.nil? || github_user.empty?
|
59
|
+
raise Thor::Error, "Missing GITHUB_USER in ~/.mr_github. Add a line like GITHUB_USER=yourusername and try again"
|
60
|
+
end
|
61
|
+
|
62
|
+
github_password = ENV['GITHUB_PASSWORD']
|
63
|
+
if github_password.nil? || github_password.empty?
|
64
|
+
raise Thor::Error, "Missing GITHUB_PASSWORD in ~/.mr_github. Add a line like GITHUB_PASSWORD=yourpassword and try again"
|
65
|
+
end
|
66
|
+
|
67
|
+
mr_config = MrConfig.new(github_user, github_password)
|
68
|
+
say "Generating .mrconfig with repositories #{github_user} can access"
|
69
|
+
|
70
|
+
create_file "#{ENV['HOME']}/.mrconfig", mr_config.to_s
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/mr_github.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mr_github/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "mr_github"
|
8
|
+
gem.version = MrGithub::VERSION
|
9
|
+
gem.authors = ["Josh Nichols"]
|
10
|
+
gem.email = ["josh@technicalpickles.com"]
|
11
|
+
gem.description = %q{A tool to make it easy to clone and pull all your GitHub repositories}
|
12
|
+
gem.summary = %q{A tool to make it easy to clone and pull all your GitHub repositories}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_dependency "ghee"
|
20
|
+
gem.add_dependency "dotenv"
|
21
|
+
gem.add_dependency "thor"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mr_github
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Nichols
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ghee
|
16
|
+
requirement: &70156525383760 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70156525383760
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: dotenv
|
27
|
+
requirement: &70156525383320 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70156525383320
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: thor
|
38
|
+
requirement: &70156525382900 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70156525382900
|
47
|
+
description: A tool to make it easy to clone and pull all your GitHub repositories
|
48
|
+
email:
|
49
|
+
- josh@technicalpickles.com
|
50
|
+
executables:
|
51
|
+
- mr_github
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- Gemfile
|
57
|
+
- Gemfile.lock
|
58
|
+
- LICENSE.txt
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- bin/mr_github
|
62
|
+
- lib/mr_github.rb
|
63
|
+
- lib/mr_github/version.rb
|
64
|
+
- mr_github.gemspec
|
65
|
+
homepage: ''
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.8.10
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: A tool to make it easy to clone and pull all your GitHub repositories
|
89
|
+
test_files: []
|
90
|
+
has_rdoc:
|