gem-src 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/gem-src.gemspec +3 -2
- data/lib/rubygems_plugin.rb +58 -27
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3c83dc3c5a18f5ae5811a98878cf4f8425f9ec
|
4
|
+
data.tar.gz: 9dc52976d13b55dbcc66b243698b195c89307372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 784ee29ac83834644d22b0e2ac06cb8d482ecab3e74caab90b312dc7f503dd1aebf67001506e973e3121657d3df96a212745d320039df5d52aa0ed4cf270a3d0
|
7
|
+
data.tar.gz: 210a3f0b03f80eef330601954bc57eb73d87ab9033cb78b19ae83ece781405d60c3ba4e7ebb8ee8769fedb0009ce580e77773188a0f5a138819fb4f27df50f2d
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# gem-src
|
2
2
|
|
3
3
|
gem-src is a gem plugin && rbenv plugin that automatically `git clone`s the gem's source right after every `gem install` so you can `git log`, `git grep` and of course write your patch there!
|
4
|
+
Plus, gem-src runs `git init` on each installed gem, and links it to the cloned source repository and the origin repository so that you can easily transfer commits to and from the gem and the repositories.
|
4
5
|
|
5
6
|
***TL;DR***
|
6
7
|
|
data/gem-src.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "gem-src"
|
7
|
-
gem.version = '0.
|
7
|
+
gem.version = '0.9.0'
|
8
8
|
gem.authors = ["Akira Matsuda"]
|
9
9
|
gem.email = ["ronnie@dio.jp"]
|
10
10
|
gem.description = 'Gem.post_install { `git clone gem_source src` }'
|
@@ -19,8 +19,9 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency 'rspec', ['>= 0']
|
20
20
|
|
21
21
|
gem.post_install_message = <<-END
|
22
|
-
[gem-src]
|
22
|
+
[gem-src] Installing gem-src as a gem is not recommended. Please consider installing as an rbenv plugin instead.
|
23
23
|
|
24
|
+
If you have not yet configured "gemsrc_clone_root", we strongly recommend you to add the configuration to your .gemrc.
|
24
25
|
e.g.)
|
25
26
|
% echo "gemsrc_clone_root: ~/src" >> ~/.gemrc
|
26
27
|
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -5,7 +5,7 @@ require 'net/https'
|
|
5
5
|
|
6
6
|
module Gem
|
7
7
|
class Src
|
8
|
-
IRREGULAR_REPOSITORIES = {'activesupport' => nil, 'actionview' => nil, 'actionpack' => nil, 'activemodel' => nil, 'activerecord' => nil, 'activejob' => nil, 'actionmailer' => nil, 'actioncable' => nil, 'railties' => nil, 'activeresource' => 'https://github.com/rails/activeresource.git', 'autoparse' => 'https://github.com/google/autoparse.git', 'aws-sdk-rails' => 'https://github.com/aws/aws-sdk-rails.git', 'bson' => 'https://github.com/mongodb/bson-ruby.git', 'compass-core' => 'https://github.com/Compass/compass.git', 'compass-import-once' => 'https://github.com/Compass/compass.git', 'cool.io' => 'https://github.com/tarcieri/cool.io.git', 'cucumber-core' => 'https://github.com/cucumber/cucumber-ruby-core.git', 'cucumber-wire' => 'https://github.com/cucumber/cucumber-ruby-wire.git', 'diff-lcs' => 'https://github.com/halostatue/diff-lcs.git', 'elasticsearch-api' => 'https://github.com/elastic/elasticsearch-ruby.git', 'elasticsearch-transport' => 'https://github.com/elastic/elasticsearch-ruby.git', 'erubis' => 'https://github.com/kwatch/erubis.git', 'geocoder' => 'https://github.com/alexreisner/geocoder', 'hirb' => 'https://github.com/cldwalker/hirb', 'html2haml' => 'https://github.com/haml/html2haml', 'io-console' => nil, 'meta_request' => 'https://github.com/dejan/rails_panel', 'method_source' => 'https://github.com/banister/method_source', 'origin' => 'https://github.com/mongoid/origin', 'padrino' => 'https://github.com/padrino/padrino-framework', 'padrino-admin' => nil, 'padrino-cache' => nil, 'padrino-core' => nil, 'padrino-gen' => nil, 'padrino-helpers' => nil, 'padrino-mailer' => nil, 'padrino-performance' => nil, 'padrino-support' => nil, 'paranoia' => 'https://github.com/rubysherpas/paranoia', 'pdf-core' => 'https://github.com/prawnpdf/pdf-core', 'pg' => nil, 'rack-mini-profiler' => 'https://github.com/MiniProfiler/rack-mini-profiler', 'raindrops' => 'https://github.com/tmm1/raindrops', 'redis-actionpack' => 'https://github.com/redis-store/redis-actionpack', 'redis-activesupport' => 'https://github.com/redis-store/redis-activesupport', 'redis-rack' => 'https://github.com/redis-store/redis-rack', 'redis-rails' => 'https://github.com/redis-store/redis-rails', 'spreadsheet' => 'https://github.com/zdavatz/spreadsheet', 'thin' => 'https://github.com/macournoyer/thin', 'uniform_notifier' => 'https://github.com/flyerhzm/uniform_notifier'}.freeze
|
8
|
+
IRREGULAR_REPOSITORIES = {'activesupport' => nil, 'actionview' => nil, 'actionpack' => nil, 'activemodel' => nil, 'activerecord' => nil, 'activejob' => nil, 'actionmailer' => nil, 'actioncable' => nil, 'railties' => nil, 'activeresource' => 'https://github.com/rails/activeresource.git', 'autoparse' => 'https://github.com/google/autoparse.git', 'aws-sdk-rails' => 'https://github.com/aws/aws-sdk-rails.git', 'bson' => 'https://github.com/mongodb/bson-ruby.git', 'compass-core' => 'https://github.com/Compass/compass.git', 'compass-import-once' => 'https://github.com/Compass/compass.git', 'cool.io' => 'https://github.com/tarcieri/cool.io.git', 'cucumber-core' => 'https://github.com/cucumber/cucumber-ruby-core.git', 'cucumber-wire' => 'https://github.com/cucumber/cucumber-ruby-wire.git', 'diff-lcs' => 'https://github.com/halostatue/diff-lcs.git', 'elasticsearch-api' => 'https://github.com/elastic/elasticsearch-ruby.git', 'elasticsearch-transport' => 'https://github.com/elastic/elasticsearch-ruby.git', 'erubis' => 'https://github.com/kwatch/erubis.git', 'geocoder' => 'https://github.com/alexreisner/geocoder', 'hirb' => 'https://github.com/cldwalker/hirb', 'html2haml' => 'https://github.com/haml/html2haml', 'io-console' => nil, 'kaminari-actionview' => nil, 'kaminari-activerecord' => nil, 'kaminari-core' => nil, 'meta_request' => 'https://github.com/dejan/rails_panel', 'method_source' => 'https://github.com/banister/method_source', 'origin' => 'https://github.com/mongoid/origin', 'padrino' => 'https://github.com/padrino/padrino-framework', 'padrino-admin' => nil, 'padrino-cache' => nil, 'padrino-core' => nil, 'padrino-gen' => nil, 'padrino-helpers' => nil, 'padrino-mailer' => nil, 'padrino-performance' => nil, 'padrino-support' => nil, 'paranoia' => 'https://github.com/rubysherpas/paranoia', 'pdf-core' => 'https://github.com/prawnpdf/pdf-core', 'pg' => nil, 'rack-mini-profiler' => 'https://github.com/MiniProfiler/rack-mini-profiler', 'raindrops' => 'https://github.com/tmm1/raindrops', 'redis-actionpack' => 'https://github.com/redis-store/redis-actionpack', 'redis-activesupport' => 'https://github.com/redis-store/redis-activesupport', 'redis-rack' => 'https://github.com/redis-store/redis-rack', 'redis-rails' => 'https://github.com/redis-store/redis-rails', 'rouge' => 'https://github.com/jneen/rouge', 'spreadsheet' => 'https://github.com/zdavatz/spreadsheet', 'thin' => 'https://github.com/macournoyer/thin', 'uniform_notifier' => 'https://github.com/flyerhzm/uniform_notifier'}.freeze
|
9
9
|
|
10
10
|
attr_reader :installer
|
11
11
|
|
@@ -13,6 +13,51 @@ module Gem
|
|
13
13
|
@installer, @tested_repositories = installer, []
|
14
14
|
end
|
15
15
|
|
16
|
+
# Guess the git repo from the gemspec and perform git clone
|
17
|
+
def git_clone_homepage_or_source_code_uri_or_homepage_uri_or_github_organization_uri
|
18
|
+
return false if skip_clone?
|
19
|
+
return false if File.exist? clone_dir
|
20
|
+
|
21
|
+
now = Time.now
|
22
|
+
|
23
|
+
if IRREGULAR_REPOSITORIES.key? installer.spec.name
|
24
|
+
return git_clone IRREGULAR_REPOSITORIES[installer.spec.name]
|
25
|
+
end
|
26
|
+
|
27
|
+
result = git_clone(installer.spec.homepage) ||
|
28
|
+
git_clone(github_url(installer.spec.homepage)) ||
|
29
|
+
git_clone(source_code_uri) ||
|
30
|
+
git_clone(homepage_uri) ||
|
31
|
+
git_clone(github_url(homepage_uri)) ||
|
32
|
+
git_clone(github_organization_uri(installer.spec.name))
|
33
|
+
|
34
|
+
if verbose?
|
35
|
+
puts "gem-src: #{installer.spec.name} - !!! Failed to find a repo." if result.nil?
|
36
|
+
puts "gem-src: #{installer.spec.name} - #{Time.now - now}s"
|
37
|
+
end
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
# git init the installed gem so that we can directly edit the files there
|
42
|
+
def repositorize_installed_gem
|
43
|
+
if File.directory? gem_dir
|
44
|
+
puts "gem-src: #{installer.spec.name} - repositorizing..." if verbose?
|
45
|
+
`cd #{gem_dir} && ! git rev-parse --is-inside-work-tree 2> /dev/null && git init && git checkout -qb gem-src_init && git add -A && git commit -m 'Initial commit by gem-src'`
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# git remote add from the installed gem to the cloned repo so that we can easily transfer patches
|
50
|
+
def remote_add_src_and_origin
|
51
|
+
if File.directory?(clone_dir) && File.directory?(gem_dir)
|
52
|
+
puts "gem-src: #{installer.spec.name} - adding remotes..." if verbose?
|
53
|
+
`cd #{gem_dir} && git remote add src #{clone_dir}`
|
54
|
+
origin = `cd #{clone_dir} && git remote get-url origin`.chomp
|
55
|
+
`cd #{gem_dir} && git remote set-url origin #{origin}` if origin
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
16
61
|
def clone_dir
|
17
62
|
@clone_dir ||= if ENV['GEMSRC_CLONE_ROOT']
|
18
63
|
File.expand_path installer.spec.name, ENV['GEMSRC_CLONE_ROOT']
|
@@ -24,6 +69,10 @@ module Gem
|
|
24
69
|
end
|
25
70
|
end
|
26
71
|
|
72
|
+
def gem_dir
|
73
|
+
installer.respond_to?(:gem_dir) ? installer.gem_dir : File.expand_path(File.join(installer.gem_home, 'gems', installer.spec.full_name))
|
74
|
+
end
|
75
|
+
|
27
76
|
def github_url(url)
|
28
77
|
if url =~ /\Ahttps?:\/\/([^.]+)\.github\.(?:com|io)\/(.+)/
|
29
78
|
if $1 == 'www'
|
@@ -88,30 +137,6 @@ module Gem
|
|
88
137
|
ENV['GEMSRC_USE_GHQ'] || Gem.configuration[:gemsrc_use_ghq]
|
89
138
|
end
|
90
139
|
|
91
|
-
def git_clone_homepage_or_source_code_uri_or_homepage_uri_or_github_organization_uri
|
92
|
-
return false if skip_clone?
|
93
|
-
return false if File.exist? clone_dir
|
94
|
-
|
95
|
-
now = Time.now
|
96
|
-
|
97
|
-
if IRREGULAR_REPOSITORIES.key? installer.spec.name
|
98
|
-
return git_clone IRREGULAR_REPOSITORIES[installer.spec.name]
|
99
|
-
end
|
100
|
-
|
101
|
-
result = git_clone(installer.spec.homepage) ||
|
102
|
-
git_clone(github_url(installer.spec.homepage)) ||
|
103
|
-
git_clone(source_code_uri) ||
|
104
|
-
git_clone(homepage_uri) ||
|
105
|
-
git_clone(github_url(homepage_uri)) ||
|
106
|
-
git_clone(github_organization_uri(installer.spec.name))
|
107
|
-
|
108
|
-
if verbose?
|
109
|
-
puts "gem-src: #{installer.spec.name} - !!! Failed to find a repo." if result.nil?
|
110
|
-
puts "gem-src: #{installer.spec.name} - #{Time.now - now}s"
|
111
|
-
end
|
112
|
-
result
|
113
|
-
end
|
114
|
-
|
115
140
|
def api_uri_for(key)
|
116
141
|
uri = api[Regexp.new("^#{key}_uri: (.*)$"), 1]
|
117
142
|
uri =~ /\A(?:https?|git):\/\// ? uri : nil
|
@@ -122,7 +147,7 @@ module Gem
|
|
122
147
|
end
|
123
148
|
|
124
149
|
def verbose?
|
125
|
-
!!ENV['GEMSRC_VERBOSE'] || Gem.configuration[:
|
150
|
+
!!ENV['GEMSRC_VERBOSE'] || Gem.configuration[:gemsrc_verbose]
|
126
151
|
end
|
127
152
|
end
|
128
153
|
end
|
@@ -130,6 +155,12 @@ end
|
|
130
155
|
|
131
156
|
Gem.post_install do |installer|
|
132
157
|
next true if installer.class.name == 'Bundler::Source::Path::Installer'
|
133
|
-
|
158
|
+
|
159
|
+
gem_src = Gem::Src.new installer
|
160
|
+
gem_src.git_clone_homepage_or_source_code_uri_or_homepage_uri_or_github_organization_uri
|
161
|
+
|
162
|
+
gem_src.repositorize_installed_gem
|
163
|
+
|
164
|
+
gem_src.remote_add_src_and_origin
|
134
165
|
true
|
135
166
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-src
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -43,8 +43,9 @@ homepage: https://github.com/amatsuda/gem-src
|
|
43
43
|
licenses: []
|
44
44
|
metadata: {}
|
45
45
|
post_install_message: |
|
46
|
-
[gem-src]
|
46
|
+
[gem-src] Installing gem-src as a gem is not recommended. Please consider installing as an rbenv plugin instead.
|
47
47
|
|
48
|
+
If you have not yet configured "gemsrc_clone_root", we strongly recommend you to add the configuration to your .gemrc.
|
48
49
|
e.g.)
|
49
50
|
% echo "gemsrc_clone_root: ~/src" >> ~/.gemrc
|
50
51
|
|
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
65
|
version: '0'
|
65
66
|
requirements: []
|
66
67
|
rubyforge_project:
|
67
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.6.8
|
68
69
|
signing_key:
|
69
70
|
specification_version: 4
|
70
71
|
summary: Gem.post_install { `git clone gem_source src` }
|