gh-diff 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df88d776025400eb4dea76dcb6a31f303da8efe6
4
- data.tar.gz: f8063a6acccc3708d6524155b559bca0bb4cda52
3
+ metadata.gz: 58a7afc6f9936f07dc10fc7eba22da6cc50b6232
4
+ data.tar.gz: 98dee8f50d2d2148c302a05cc85fdd03fd8657a1
5
5
  SHA512:
6
- metadata.gz: 4b9014ab2b8b6dad06409f895a9c9c85c5a4351ed64fe9faf7af37e8eee4ac7042d2874c2a637ba59cc0967db7282ab5e724b82e9669805e0a142b136d12cdb5
7
- data.tar.gz: a0fee2f77bf4ce3cf5dc45d4852db974961330e0b6d567a42db50d93a3bf1fd4253cbfc7ffb52180d032212a2b869b206db56657806f77a2e08915992ecdcd99
6
+ metadata.gz: 64760cc1db798ee4718a24afa8864904e44f9e5d95bdeed3846d1db7e6f0e951348691302119380b8b43c504265015194877881fa19d8225d7b8fd9159358dbb
7
+ data.tar.gz: a0c9929f293389dd2a29ecbc3d3b50790c04344bb8e8c402c737227bbd3d2c42448b7030cb5b0e58806fa4d5cda8ea7b5411ffadc2e31dee1f221e331689b035
data/lib/gh-diff.rb CHANGED
@@ -10,6 +10,7 @@ require "togglate"
10
10
 
11
11
  module GhDiff
12
12
  class RepositoryNameError < StandardError; end
13
+ class NoDirectoryError < StandardError; end
13
14
  class Diff
14
15
  attr_accessor :repo, :revision, :dir
15
16
  def initialize(repo, revision:'master', dir:nil)
@@ -37,6 +38,7 @@ module GhDiff
37
38
  end
38
39
 
39
40
  def dir_diff(directory, repo:@repo, revision:@revision, dir:@dir)
41
+ raise NoDirectoryError unless Dir.exist?(directory)
40
42
  local_files = Dir.glob("#{directory}/*").map { |f| File.basename f }
41
43
  remote_path = build_path(dir, directory)
42
44
  remote_files = get_contents(repo, remote_path, revision).map(&:name)
data/lib/gh-diff/cli.rb CHANGED
@@ -162,6 +162,9 @@ module GhDiff
162
162
  end
163
163
  end
164
164
  end
165
+ rescue GhDiff::NoDirectoryError
166
+ puts "Directory not found: `#{dir}`"
167
+ exit(1)
165
168
  end
166
169
 
167
170
  desc "version", "Show gh-diff version"
@@ -1,3 +1,3 @@
1
1
  module GhDiff
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -126,11 +126,17 @@ describe GhDiff::CLI do
126
126
  end
127
127
 
128
128
  it "raises an error when repo is empty" do
129
- ARGV.replace %w(dir_diff docs/quickstart.md --repo=)
129
+ ARGV.replace %w(dir_diff docs --repo=)
130
130
  expect { GhDiff::CLI.start }.to raise_error(SystemExit)
131
131
  expect($stdout.string).to match(/Repository should/)
132
132
  end
133
133
 
134
+ it "raises an error when directory not exsit" do
135
+ ARGV.replace %w(dir_diff docs/hello --repo=jekyll/jekyll --dir=site)
136
+ expect { GhDiff::CLI.start }.to raise_error(SystemExit)
137
+ expect($stdout.string).to match(/Directory not found/)
138
+ end
139
+
134
140
  context "with save option" do
135
141
  it "saves new files" do
136
142
  VCR.use_cassette('save-dir-diff') do
data/spec/gh-diff_spec.rb CHANGED
@@ -125,6 +125,10 @@ describe GhDiff::Diff do
125
125
  expect(removed).to be_empty
126
126
  end
127
127
  end
128
+
129
+ it "raise NoDirectoryError" do
130
+ expect{ gh.dir_diff 'no_such_dir'}.to raise_error(GhDiff::NoDirectoryError)
131
+ end
128
132
  end
129
133
 
130
134
  describe "#ref" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyoendo