gh-diff 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57381a1e6b18fb6aee1e3d881b2324f1be6ee15e
4
- data.tar.gz: 2120094ff604d63f3aa8ac071316b3dda1abb3cb
3
+ metadata.gz: 5b8d67bafa82796ac797c651eec6009dbf118f36
4
+ data.tar.gz: d011146f7d0602cfb86607d2b07f8c2ee8627a72
5
5
  SHA512:
6
- metadata.gz: cf9cc0e90cde40fdcfc5074fdad3e20c58d576a42356dfc18f653837915aa2711cee81388b47b343217a0c0cf0a45e2f75d132b98735c463645fb7036e11d04b
7
- data.tar.gz: 2dc8e5c0340c7d36e145b09a6db08098cc9931d58ebde0b6ed2c5448a05ddc9d135a80132ae4cffb445e6acaf3599dc4b992f11297bb2e6adfe71279e652731e
6
+ metadata.gz: 4522295017af75cbd678a20409edece4758d162f06686e6744e92ad627ef5813653e17e184ddb60d3690be5fbd63d00b733b18786754642628fe2b74c1a6ad6e
7
+ data.tar.gz: 2230b38da8a00b8bdc183a4d4af8ab9b1f526e923d7ec29c0baf0e203451e66d58e1725f69e2f4aebc8fa9779e60f093a117dd42fe359de5513073a9ea5fb577
data/lib/gh-diff/cli.rb CHANGED
@@ -20,11 +20,19 @@ module GhDiff
20
20
  desc:'github API access token'
21
21
 
22
22
  desc "get FILE", "Get FILE content from github repository"
23
+ option :ref,
24
+ aliases:'-f',
25
+ default:false,
26
+ type: :boolean,
27
+ desc:'Print reference data'
23
28
  def get(file)
24
29
  opts = Option.new(options).with_env
25
30
  github_auth(opts[:username], opts[:password], opts[:token])
26
31
 
27
32
  gh = Diff.new(opts[:repo], revision:opts[:revision], dir:opts[:dir])
33
+ ref = gh.ref(opts[:revision], repo:opts[:repo])
34
+
35
+ print "Base revision: #{ref[:object][:sha]}[#{ref[:ref]}]\n"
28
36
  print gh.get(file)
29
37
  rescue ::Octokit::NotFound
30
38
  path = (dir=opts[:dir]) ? "#{dir}/#{file}" : file
@@ -1,3 +1,3 @@
1
1
  module GhDiff
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,147 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/repos/jekyll/jekyll/git/refs/heads/master
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/vnd.github.v3+json
12
+ User-Agent:
13
+ - Octokit Ruby Gem 3.1.2
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - GitHub.com
23
+ Date:
24
+ - Thu, 03 Jul 2014 12:13:07 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Status:
30
+ - 200 OK
31
+ X-Ratelimit-Limit:
32
+ - '60'
33
+ X-Ratelimit-Remaining:
34
+ - '59'
35
+ X-Ratelimit-Reset:
36
+ - '1404393187'
37
+ Cache-Control:
38
+ - public, max-age=60, s-maxage=60
39
+ Last-Modified:
40
+ - Thu, 03 Jul 2014 11:52:54 GMT
41
+ Etag:
42
+ - '"ad9185dfc029bd1858b4d7fe6c98a0b5"'
43
+ X-Poll-Interval:
44
+ - '300'
45
+ Vary:
46
+ - Accept
47
+ - Accept-Encoding
48
+ X-Github-Media-Type:
49
+ - github.v3; format=json
50
+ X-Xss-Protection:
51
+ - 1; mode=block
52
+ X-Frame-Options:
53
+ - deny
54
+ Content-Security-Policy:
55
+ - default-src 'none'
56
+ Access-Control-Allow-Credentials:
57
+ - 'true'
58
+ Access-Control-Expose-Headers:
59
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
60
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
61
+ Access-Control-Allow-Origin:
62
+ - "*"
63
+ X-Github-Request-Id:
64
+ - DE962F8B:1809:1839526:53B548D3
65
+ Strict-Transport-Security:
66
+ - max-age=31536000; includeSubdomains
67
+ X-Content-Type-Options:
68
+ - nosniff
69
+ X-Served-By:
70
+ - 3061975e1f37121b3751604ad153c687
71
+ body:
72
+ encoding: UTF-8
73
+ string: '{"ref":"refs/heads/master","url":"https://api.github.com/repos/jekyll/jekyll/git/refs/heads/master","object":{"sha":"4d8dab6e33978c9167864e9e4b023ffba14e8b71","type":"commit","url":"https://api.github.com/repos/jekyll/jekyll/git/commits/4d8dab6e33978c9167864e9e4b023ffba14e8b71"}}'
74
+ http_version:
75
+ recorded_at: Thu, 03 Jul 2014 12:13:07 GMT
76
+ - request:
77
+ method: get
78
+ uri: https://api.github.com/repos/jekyll/jekyll/contents/site/docs/quickstart.md?ref=master
79
+ body:
80
+ encoding: US-ASCII
81
+ string: ''
82
+ headers:
83
+ Accept:
84
+ - application/vnd.github.v3+json
85
+ User-Agent:
86
+ - Octokit Ruby Gem 3.1.2
87
+ Accept-Encoding:
88
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
89
+ response:
90
+ status:
91
+ code: 200
92
+ message: OK
93
+ headers:
94
+ Server:
95
+ - GitHub.com
96
+ Date:
97
+ - Thu, 03 Jul 2014 12:13:08 GMT
98
+ Content-Type:
99
+ - application/json; charset=utf-8
100
+ Transfer-Encoding:
101
+ - chunked
102
+ Status:
103
+ - 200 OK
104
+ X-Ratelimit-Limit:
105
+ - '60'
106
+ X-Ratelimit-Remaining:
107
+ - '58'
108
+ X-Ratelimit-Reset:
109
+ - '1404393187'
110
+ Cache-Control:
111
+ - public, max-age=60, s-maxage=60
112
+ Last-Modified:
113
+ - Wed, 02 Jul 2014 00:15:54 GMT
114
+ Etag:
115
+ - '"cc900739c902114785938b70ec00be83"'
116
+ Vary:
117
+ - Accept
118
+ - Accept-Encoding
119
+ X-Github-Media-Type:
120
+ - github.v3; format=json
121
+ X-Xss-Protection:
122
+ - 1; mode=block
123
+ X-Frame-Options:
124
+ - deny
125
+ Content-Security-Policy:
126
+ - default-src 'none'
127
+ Access-Control-Allow-Credentials:
128
+ - 'true'
129
+ Access-Control-Expose-Headers:
130
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
131
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
132
+ Access-Control-Allow-Origin:
133
+ - "*"
134
+ X-Github-Request-Id:
135
+ - DE962F8B:1808:14423E1:53B548D4
136
+ Strict-Transport-Security:
137
+ - max-age=31536000; includeSubdomains
138
+ X-Content-Type-Options:
139
+ - nosniff
140
+ X-Served-By:
141
+ - a1d8c69b807c8e21f06cad9da377d1b0
142
+ body:
143
+ encoding: UTF-8
144
+ string: '{"name":"quickstart.md","path":"site/docs/quickstart.md","sha":"eedb976237a3f8aef6e3f0cc205fcab284370ef7","size":728,"url":"https://api.github.com/repos/jekyll/jekyll/contents/site/docs/quickstart.md?ref=master","html_url":"https://github.com/jekyll/jekyll/blob/master/site/docs/quickstart.md","git_url":"https://api.github.com/repos/jekyll/jekyll/git/blobs/eedb976237a3f8aef6e3f0cc205fcab284370ef7","type":"file","content":"LS0tCmxheW91dDogZG9jcwp0aXRsZTogUXVpY2stc3RhcnQgZ3VpZGUKcHJl\ndl9zZWN0aW9uOiBob21lCm5leHRfc2VjdGlvbjogaW5zdGFsbGF0aW9uCnBl\ncm1hbGluazogL2RvY3MvcXVpY2tzdGFydC8KLS0tCgpGb3IgdGhlIGltcGF0\naWVudCwgaGVyZSdzIGhvdyB0byBnZXQgYSBib2lsZXJwbGF0ZSBKZWt5bGwg\nc2l0ZSB1cCBhbmQgcnVubmluZy4KCnslIGhpZ2hsaWdodCBiYXNoICV9Cn4g\nJCBnZW0gaW5zdGFsbCBqZWt5bGwKfiAkIGpla3lsbCBuZXcgbXlibG9nCn4g\nJCBjZCBteWJsb2cKfi9teWJsb2cgJCBqZWt5bGwgc2VydmUKIyA9PiBOb3cg\nYnJvd3NlIHRvIGh0dHA6Ly9sb2NhbGhvc3Q6NDAwMAp7JSBlbmRoaWdobGln\naHQgJX0KClRoYXQncyBub3RoaW5nLCB0aG91Z2guIFRoZSByZWFsIG1hZ2lj\nIGhhcHBlbnMgd2hlbiB5b3Ugc3RhcnQgY3JlYXRpbmcgYmxvZwpwb3N0cywg\ndXNpbmcgdGhlIGZyb250LW1hdHRlciB0byBjb250cm9sIHRlbXBsYXRlcyBh\nbmQgbGF5b3V0cywgYW5kIHRha2luZwphZHZhbnRhZ2Ugb2YgYWxsIHRoZSBh\nd2Vzb21lIGNvbmZpZ3VyYXRpb24gb3B0aW9ucyBKZWt5bGwgbWFrZXMgYXZh\naWxhYmxlLgoKSWYgeW91J3JlIHJ1bm5pbmcgaW50byBwcm9ibGVtcywgZW5z\ndXJlIHlvdSBoYXZlIGFsbCB0aGUgW3JlcXVpcmVtZW50cwppbnN0YWxsZWRd\nW0luc3RhbGxhdGlvbl0uCgpbSW5zdGFsbGF0aW9uXTogL2RvY3MvaW5zdGFs\nbGF0aW9uLwo=\n","encoding":"base64","_links":{"self":"https://api.github.com/repos/jekyll/jekyll/contents/site/docs/quickstart.md?ref=master","git":"https://api.github.com/repos/jekyll/jekyll/git/blobs/eedb976237a3f8aef6e3f0cc205fcab284370ef7","html":"https://github.com/jekyll/jekyll/blob/master/site/docs/quickstart.md"}}'
145
+ http_version:
146
+ recorded_at: Thu, 03 Jul 2014 12:13:08 GMT
147
+ recorded_with: VCR 2.9.2
data/spec/cli_spec.rb CHANGED
@@ -47,6 +47,19 @@ describe GhDiff::CLI do
47
47
  expect { GhDiff::CLI.start }.to raise_error(SystemExit)
48
48
  end
49
49
  end
50
+
51
+ context "with ref option" do
52
+ it "also prints reference data of the file" do
53
+ VCR.use_cassette 'quickstart-ref' do
54
+ ARGV.replace %w(get docs/quickstart.md
55
+ --repo=jekyll/jekyll --dir=site
56
+ --ref)
57
+ GhDiff::CLI.start
58
+ expect($stdout.string).to match(/title: Quick-start guide/)
59
+ expect($stdout.string).to match(/Base revision: 4d8dab.*master/)
60
+ end
61
+ end
62
+ end
50
63
  end
51
64
 
52
65
  describe "diff" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyoendo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: togglate
@@ -191,6 +191,7 @@ files:
191
191
  - spec/cassettes/dir.yml
192
192
  - spec/cassettes/docs.yml
193
193
  - spec/cassettes/nonexist.yml
194
+ - spec/cassettes/quickstart-ref.yml
194
195
  - spec/cassettes/quickstart.yml
195
196
  - spec/cassettes/ref-tag.yml
196
197
  - spec/cassettes/ref.yml
@@ -232,6 +233,7 @@ test_files:
232
233
  - spec/cassettes/dir.yml
233
234
  - spec/cassettes/docs.yml
234
235
  - spec/cassettes/nonexist.yml
236
+ - spec/cassettes/quickstart-ref.yml
235
237
  - spec/cassettes/quickstart.yml
236
238
  - spec/cassettes/ref-tag.yml
237
239
  - spec/cassettes/ref.yml