gh-diff 0.0.9 → 0.0.10

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: e8b0437ed2bd7b0d6f40b2a98fd8e8c57c0bf23e
4
- data.tar.gz: edec7e6457db65566fea5f499d742260e3cfa7df
3
+ metadata.gz: 68850949a7f61cc948ef08629469105a7cb3405b
4
+ data.tar.gz: b87485464a7d156154aba9cacfa7589412790f8f
5
5
  SHA512:
6
- metadata.gz: 943ca3f940f8a473216d285bee695abae210302fced1531b58f161d9f3f23963a09b354d7766bc2e01ef0ef169c7b74267ddac93876383ce9ec8b0285508768f
7
- data.tar.gz: 50329ebccee2155a3138eb5adefd2eeb1fbda4fd6e2bc757bd6b09d1d14da2e6bcd7adff80f1f99d5d84640240a96f653a6f3e245306c968903cfc8194a5f576
6
+ metadata.gz: 0f737b7381ec74802e4dd6af8d8df9979f884f3757e03c881b728521d077e136e3579565cb855d0ac8fe773463f5650e8861898b95bcf7babc8f66819c4af399
7
+ data.tar.gz: 7c6d96caad994c600eab09bb742f0ccb7738c5254b9a011d5864a2ccf90fb6792d6395497a68497c0505925adeec957f808bfd08084a3c85e6606a2aab2b89ab
data/lib/gh-diff/cli.rb CHANGED
@@ -77,6 +77,7 @@ module GhDiff
77
77
 
78
78
  ref = gh.ref(opts[:revision], repo:opts[:repo])
79
79
 
80
+ return_flag = 0
80
81
  diffs.each do |(f1, f2), diff|
81
82
  next if file_not_found?(f1, f2, diff)
82
83
  header = "#{ref_format(ref)}--- #{f1}\n+++ #{f2}\n\n"
@@ -88,6 +89,7 @@ module GhDiff
88
89
  content = diff.to_s(format)
89
90
  unless content.empty?
90
91
  save(header + content, opts[:save_dir], f1)
92
+ return_flag |= 1
91
93
  else
92
94
  print "\e[32mno Diff on\e[0m #{diff_form}\n"
93
95
  end
@@ -100,11 +102,15 @@ module GhDiff
100
102
  print header
101
103
  print diff.to_s(opts[:format])
102
104
  end
105
+ return_flag |= 1
103
106
  else
104
107
  print "\e[32mno Diff on\e[0m #{diff_form}\n"
105
108
  end
106
109
  end
107
110
  end
111
+ # return: 0 - no diff on all files
112
+ # 1 - diff found on any of files
113
+ return_flag
108
114
  end
109
115
 
110
116
  desc "dir_diff DIRECTORY", "Print added and removed files in remote repository"
@@ -126,6 +132,7 @@ module GhDiff
126
132
 
127
133
  gh = init_ghdiff(opts[:repo], opts[:revision], opts[:dir])
128
134
  added, removed = gh.dir_diff(dir)
135
+ return_flag = 0
129
136
  if [added, removed].all?(&:empty?)
130
137
  puts "\e[33mNothing changed\e[0m"
131
138
  else
@@ -161,7 +168,11 @@ module GhDiff
161
168
  end
162
169
  end
163
170
  end
171
+ return_flag |= 1
164
172
  end
173
+ # return: 0 - nothing changed
174
+ # 1 - file added or removed
175
+ return_flag
165
176
  rescue GhDiff::NoDirectoryError
166
177
  puts "Directory not found: `#{dir}`"
167
178
  exit(1)
@@ -1,3 +1,3 @@
1
1
  module GhDiff
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -288,4 +288,75 @@ http_interactions:
288
288
  string: '{"ref":"refs/heads/master","url":"https://api.github.com/repos/jekyll/jekyll/git/refs/heads/master","object":{"sha":"3dffa8284f604e4ac87ce6eb4bc8bbaa257da8d8","type":"commit","url":"https://api.github.com/repos/jekyll/jekyll/git/commits/3dffa8284f604e4ac87ce6eb4bc8bbaa257da8d8"}}'
289
289
  http_version:
290
290
  recorded_at: Sun, 29 Jun 2014 00:24:08 GMT
291
+ - request:
292
+ method: get
293
+ uri: https://api.github.com/repos/jekyll/jekyll/contents/site/docs/migrations.md?ref=master
294
+ body:
295
+ encoding: US-ASCII
296
+ string: ''
297
+ headers:
298
+ Accept:
299
+ - application/vnd.github.v3+json
300
+ User-Agent:
301
+ - Octokit Ruby Gem 3.2.0
302
+ Accept-Encoding:
303
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
304
+ response:
305
+ status:
306
+ code: 200
307
+ message: OK
308
+ headers:
309
+ Server:
310
+ - GitHub.com
311
+ Date:
312
+ - Wed, 30 Jul 2014 12:24:34 GMT
313
+ Content-Type:
314
+ - application/json; charset=utf-8
315
+ Transfer-Encoding:
316
+ - chunked
317
+ Status:
318
+ - 200 OK
319
+ X-Ratelimit-Limit:
320
+ - '60'
321
+ X-Ratelimit-Remaining:
322
+ - '59'
323
+ X-Ratelimit-Reset:
324
+ - '1406726674'
325
+ Cache-Control:
326
+ - public, max-age=60, s-maxage=60
327
+ Last-Modified:
328
+ - Tue, 29 Jul 2014 23:23:00 GMT
329
+ Etag:
330
+ - '"cc1f1604a33f46a76ee717a0bef0d0db"'
331
+ Vary:
332
+ - Accept
333
+ - Accept-Encoding
334
+ X-Github-Media-Type:
335
+ - github.v3; format=json
336
+ X-Xss-Protection:
337
+ - 1; mode=block
338
+ X-Frame-Options:
339
+ - deny
340
+ Content-Security-Policy:
341
+ - default-src 'none'
342
+ Access-Control-Allow-Credentials:
343
+ - 'true'
344
+ Access-Control-Expose-Headers:
345
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
346
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
347
+ Access-Control-Allow-Origin:
348
+ - "*"
349
+ X-Github-Request-Id:
350
+ - DE962F8B:29B2:22EB0A:53D8E402
351
+ Strict-Transport-Security:
352
+ - max-age=31536000; includeSubdomains
353
+ X-Content-Type-Options:
354
+ - nosniff
355
+ X-Served-By:
356
+ - c436b2b44345c72ff906059f604991e7
357
+ body:
358
+ encoding: UTF-8
359
+ string: '{"name":"migrations.md","path":"site/docs/migrations.md","sha":"a080c6c6ee28720ea347b0e4fe0660e3e333d501","size":359,"url":"https://api.github.com/repos/jekyll/jekyll/contents/site/docs/migrations.md?ref=master","html_url":"https://github.com/jekyll/jekyll/blob/master/site/docs/migrations.md","git_url":"https://api.github.com/repos/jekyll/jekyll/git/blobs/a080c6c6ee28720ea347b0e4fe0660e3e333d501","type":"file","content":"LS0tCmxheW91dDogZG9jcwp0aXRsZTogQmxvZyBtaWdyYXRpb25zCnByZXZf\nc2VjdGlvbjogYXNzZXRzCm5leHRfc2VjdGlvbjogdGVtcGxhdGVzCnBlcm1h\nbGluazogL2RvY3MvbWlncmF0aW9ucy8KLS0tCgpJZiB5b3XigJlyZSBzd2l0\nY2hpbmcgdG8gSmVreWxsIGZyb20gYW5vdGhlciBibG9nZ2luZyBzeXN0ZW0s\nIEpla3lsbOKAmXMgaW1wb3J0ZXJzCmNhbiBoZWxwIHlvdSB3aXRoIHRoZSBt\nb3ZlLiBUbyBsZWFybiBtb3JlIGFib3V0IGltcG9ydGluZyB5b3VyIHNpdGUg\ndG8gSmVreWxsLAp2aXNpdCBvdXIgW2BqZWt5bGwtaW1wb3J0YCBkb2NzIHNp\ndGVdKGh0dHA6Ly9pbXBvcnQuamVreWxscmIuY29tL2RvY3MvaG9tZS8pLgo=\n","encoding":"base64","_links":{"self":"https://api.github.com/repos/jekyll/jekyll/contents/site/docs/migrations.md?ref=master","git":"https://api.github.com/repos/jekyll/jekyll/git/blobs/a080c6c6ee28720ea347b0e4fe0660e3e333d501","html":"https://github.com/jekyll/jekyll/blob/master/site/docs/migrations.md"}}'
360
+ http_version:
361
+ recorded_at: Wed, 30 Jul 2014 12:24:34 GMT
291
362
  recorded_with: VCR 2.9.2
data/spec/cli_spec.rb CHANGED
@@ -75,8 +75,9 @@ describe GhDiff::CLI do
75
75
  ARGV.replace %w(diff docs/quickstart.md
76
76
  --repo=jekyll/jekyll --dir=site
77
77
  --name_only=false)
78
- GhDiff::CLI.start
78
+ flag = GhDiff::CLI.start
79
79
  expect($stdout.string).to eq @diff_result
80
+ expect(flag).to eq 1
80
81
  end
81
82
  end
82
83
 
@@ -120,8 +121,9 @@ describe GhDiff::CLI do
120
121
  VCR.use_cassette('dir') do
121
122
  ARGV.replace %w(dir_diff docs
122
123
  --repo=jekyll/jekyll --dir=site)
123
- GhDiff::CLI.start
124
+ flag = GhDiff::CLI.start
124
125
  expect($stdout.string).to match(/New files:.*collections.md/m)
126
+ expect(flag).to eq 1
125
127
  end
126
128
  end
127
129
 
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.9
4
+ version: 0.0.10
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-29 00:00:00.000000000 Z
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: togglate