git_shizzle 0.2.6 → 0.2.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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +0 -1
  4. data/.travis.yml +11 -0
  5. data/Gemfile +25 -1
  6. data/Guardfile +3 -2
  7. data/README.md +66 -0
  8. data/git_shizzle.gemspec +8 -25
  9. data/lib/commands.rb +4 -4
  10. data/lib/git_shizzle/git/git.rb +19 -19
  11. data/lib/git_shizzle/version.rb +1 -1
  12. data/spec/git_shizzle/builtin_commands/checkout_spec.rb +51 -0
  13. data/spec/git_shizzle/builtin_commands/diff_cached_spec.rb +55 -0
  14. data/spec/git_shizzle/builtin_commands/diff_spec.rb +51 -0
  15. data/spec/git_shizzle/builtin_commands/stage_patch_spec.rb +37 -0
  16. data/spec/{git-shizzle → git_shizzle}/builtin_commands/stage_spec.rb +19 -16
  17. data/spec/{git-shizzle → git_shizzle}/builtin_commands/track_spec.rb +12 -9
  18. data/spec/git_shizzle/builtin_commands/unstage_spec.rb +67 -0
  19. data/spec/{git-shizzle → git_shizzle}/command_spec.rb +0 -1
  20. data/spec/git_shizzle/dsl_spec.rb +42 -0
  21. data/spec/git_shizzle/git_spec.rb +34 -0
  22. data/spec/{git-shizzle → git_shizzle}/index_spec.rb +6 -3
  23. data/spec/{git-shizzle → git_shizzle}/status_parser_spec.rb +5 -6
  24. data/spec/helpers/git_repository.rb +3 -3
  25. data/spec/spec_helper.rb +7 -0
  26. metadata +35 -161
  27. data/Gemfile.lock +0 -71
  28. data/doc.txt +0 -8
  29. data/spec/git-shizzle/builtin_commands/checkout_spec.rb +0 -49
  30. data/spec/git-shizzle/builtin_commands/diff_cached_spec.rb +0 -53
  31. data/spec/git-shizzle/builtin_commands/diff_spec.rb +0 -49
  32. data/spec/git-shizzle/builtin_commands/stage_patch_spec.rb +0 -32
  33. data/spec/git-shizzle/builtin_commands/unstage_spec.rb +0 -68
  34. data/spec/git-shizzle/dsl_spec.rb +0 -48
  35. data/spec/git-shizzle/git_spec.rb +0 -15
data/Gemfile.lock DELETED
@@ -1,71 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- git_shizzle (0.2.5)
5
- thor (~> 0.16)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- celluloid (0.15.2)
11
- timers (~> 1.1.0)
12
- coderay (1.1.0)
13
- diff-lcs (1.2.5)
14
- ffi (1.9.3-x86-mingw32)
15
- formatador (0.2.4)
16
- guard (2.4.0)
17
- formatador (>= 0.2.4)
18
- listen (~> 2.1)
19
- lumberjack (~> 1.0)
20
- pry (>= 0.9.12)
21
- thor (>= 0.18.1)
22
- guard-bundler (2.0.0)
23
- bundler (~> 1.0)
24
- guard (~> 2.2)
25
- guard-rspec (4.2.6)
26
- guard (~> 2.1)
27
- rspec (>= 2.14, < 4.0)
28
- listen (2.4.1)
29
- celluloid (>= 0.15.2)
30
- rb-fsevent (>= 0.9.3)
31
- rb-inotify (>= 0.9)
32
- lumberjack (1.0.4)
33
- method_source (0.8.2)
34
- pry (0.9.12.6-x86-mingw32)
35
- coderay (~> 1.0)
36
- method_source (~> 0.8)
37
- slop (~> 3.4)
38
- win32console (~> 1.3)
39
- rake (10.1.1)
40
- rb-fsevent (0.9.4)
41
- rb-inotify (0.9.3)
42
- ffi (>= 0.5.0)
43
- rspec (2.14.1)
44
- rspec-core (~> 2.14.0)
45
- rspec-expectations (~> 2.14.0)
46
- rspec-mocks (~> 2.14.0)
47
- rspec-core (2.14.7)
48
- rspec-expectations (2.14.5)
49
- diff-lcs (>= 1.1.3, < 2.0)
50
- rspec-mocks (2.14.5)
51
- ruby_gntp (0.3.4)
52
- slop (3.4.7)
53
- thor (0.18.1)
54
- timers (1.1.0)
55
- wdm (0.1.0)
56
- win32console (1.3.2-x86-mingw32)
57
-
58
- PLATFORMS
59
- x86-mingw32
60
-
61
- DEPENDENCIES
62
- git_shizzle!
63
- guard
64
- guard-bundler
65
- guard-rspec
66
- rake
67
- rspec
68
- rspec-mocks
69
- ruby_gntp
70
- wdm
71
- win32console
data/doc.txt DELETED
@@ -1,8 +0,0 @@
1
- stage 1 ==> index
2
- stage 1 2 3 4 ==> index
3
- stage 1..3 ==> index
4
- stage . ==> index
5
- diff 1 => show diff on modified tracked file
6
- unstage 1 ==> remove from index
7
- track 1 => add untracked file into index
8
- checkout 1 => discard working directory changes of tracked file
@@ -1,49 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
- require 'git_shizzle'
3
-
4
- describe 'Checkout files by index' do
5
-
6
- let(:git) { GitShizzle::Git::Git.new(repo) }
7
- subject { GitShizzle::QuickGit.new(git) }
8
-
9
- context 'repository with modified files' do
10
- before (:each) do
11
- %w{ deleted modified }.each { |f| create f; stage f }
12
- `git commit --message Blah`
13
-
14
- delete 'deleted'
15
- modify 'modified'
16
-
17
- git.status[0].work_tree_status.should == :deleted
18
- git.status[1].work_tree_status.should == :modified
19
- end
20
-
21
- context 'when a modified file is checked out' do
22
- it 'should run git checkout' do
23
- git.stub(:command).and_call_original
24
- git.stub(:command).with(/checkout/, anything)
25
-
26
- expect(git).to receive(:command).with('checkout --', ['modified'])
27
-
28
- subject.checkout 2
29
- end
30
- end
31
-
32
- context 'when a deleted file is checked out' do
33
- it 'should run git checkout' do
34
- git.stub(:command).and_call_original
35
- git.stub(:command).with(/checkout/, anything)
36
-
37
- expect(git).to receive(:command).with('checkout --', ['deleted'])
38
-
39
- subject.checkout 1
40
- end
41
- end
42
- end
43
-
44
- context 'when the repository contains no modified files' do
45
- it 'should fail' do
46
- expect { subject.checkout 1 }.to raise_error
47
- end
48
- end
49
- end
@@ -1,53 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
- require 'git_shizzle'
3
-
4
- describe 'Diff staged/cached files by index' do
5
-
6
- let(:git) { GitShizzle::Git::Git.new(repo) }
7
- subject { GitShizzle::QuickGit.new(git) }
8
-
9
- context 'repository with modified files' do
10
- before (:each) do
11
- %w{ deleted modified }.each { |f| create f; stage f }
12
- `git commit --message Blah`
13
-
14
- delete 'deleted'
15
- stage 'deleted'
16
- modify 'modified'
17
- stage 'modified'
18
-
19
- git.status[0].work_tree_status.should == nil
20
- git.status[0].index_status.should == :deleted
21
- git.status[1].work_tree_status.should == nil
22
- git.status[1].index_status.should == :modified
23
- end
24
-
25
- context 'when a staged modified file is diffed' do
26
- it 'should run git diff --cached' do
27
- git.stub(:command).and_call_original
28
- git.stub(:command).with(/diff/, anything)
29
-
30
- expect(git).to receive(:command).with('diff --cached --', ['modified'])
31
-
32
- subject.diff_cached 2
33
- end
34
- end
35
-
36
- context 'when a staged deleted file is diffed' do
37
- it 'should run git diff --cached' do
38
- git.stub(:command).and_call_original
39
- git.stub(:command).with(/diff/, anything)
40
-
41
- expect(git).to receive(:command).with('diff --cached --', ['deleted'])
42
-
43
- subject.diff_cached 1
44
- end
45
- end
46
- end
47
-
48
- context 'when the repository contains no staged files' do
49
- it 'should fail' do
50
- expect { subject.diff_cached 1 }.to raise_error
51
- end
52
- end
53
- end
@@ -1,49 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
- require 'git_shizzle'
3
-
4
- describe 'Diff files by index' do
5
-
6
- let(:git) { GitShizzle::Git::Git.new(repo) }
7
- subject { GitShizzle::QuickGit.new(git) }
8
-
9
- context 'repository with modified files' do
10
- before (:each) do
11
- %w{ deleted modified }.each { |f| create f; stage f }
12
- `git commit --message Blah`
13
-
14
- delete 'deleted'
15
- modify 'modified'
16
-
17
- git.status[0].work_tree_status.should == :deleted
18
- git.status[1].work_tree_status.should == :modified
19
- end
20
-
21
- context 'when a modified file is diffed' do
22
- it 'should run git diff' do
23
- git.stub(:command).and_call_original
24
- git.stub(:command).with(/diff/, anything)
25
-
26
- expect(git).to receive(:command).with('diff --', ['modified'])
27
-
28
- subject.diff 2
29
- end
30
- end
31
-
32
- context 'when a deleted file is diffed' do
33
- it 'should run git diff' do
34
- git.stub(:command).and_call_original
35
- git.stub(:command).with(/diff/, anything)
36
-
37
- expect(git).to receive(:command).with('diff --', ['deleted'])
38
-
39
- subject.diff 1
40
- end
41
- end
42
- end
43
-
44
- context 'when the repository contains no modified files' do
45
- it 'should fail' do
46
- expect { subject.diff 1 }.to raise_error
47
- end
48
- end
49
- end
@@ -1,32 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
- require 'git_shizzle'
3
-
4
- describe 'Stage patches by index', :draft => true do
5
-
6
- let(:git) { GitShizzle::Git::Git.new(repo) }
7
- subject { GitShizzle::QuickGit.new(git) }
8
-
9
- context 'repository with modified files' do
10
- before (:each) do
11
- %w{ deleted modified }.each { |f| create f; stage f }
12
- `git commit --message Blah`
13
-
14
- delete 'deleted'
15
- modify 'modified'
16
-
17
- git.status[0].work_tree_status.should == :deleted
18
- git.status[1].work_tree_status.should == :modified
19
- end
20
-
21
- context 'when a modified file is staged' do
22
- it 'should run git add --patch' do
23
- git.stub(:command).and_call_original
24
- git.stub(:command).with(/add/, anything)
25
-
26
- expect(git).to receive(:command).with('add --patch --', ['modified'])
27
-
28
- subject.stage_with_patch 2
29
- end
30
- end
31
- end
32
- end
@@ -1,68 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
- require 'git_shizzle'
3
-
4
- describe 'Unstage staged/cached files by index' do
5
-
6
- let(:git) { GitShizzle::Git::Git.new(repo) }
7
- subject { GitShizzle::QuickGit.new(git) }
8
-
9
- context 'repository with modified files' do
10
- before (:each) do
11
- %w{ deleted modified }.each { |f| create f; stage f }
12
- `git commit --message Blah`
13
-
14
- delete 'deleted'
15
- stage 'deleted'
16
- modify 'modified'
17
- stage 'modified'
18
- create 'untracked'
19
- stage 'untracked'
20
-
21
- git.status[0].work_tree_status.should == nil
22
- git.status[0].index_status.should == :deleted
23
- git.status[1].work_tree_status.should == nil
24
- git.status[1].index_status.should == :modified
25
- git.status[2].work_tree_status.should == nil
26
- git.status[2].index_status.should == :added
27
- end
28
-
29
- context 'when a staged modified file is unstaged' do
30
- it 'should run git reset HEAD' do
31
- git.stub(:command).and_call_original
32
- git.stub(:command).with(/reset/, anything)
33
-
34
- expect(git).to receive(:command).with('reset HEAD --', ['modified'])
35
-
36
- subject.unstage 2
37
- end
38
- end
39
-
40
- context 'when a staged deleted file is unstaged' do
41
- it 'should run git reset HEAD' do
42
- git.stub(:command).and_call_original
43
- git.stub(:command).with(/reset/, anything)
44
-
45
- expect(git).to receive(:command).with('reset HEAD --', ['deleted'])
46
-
47
- subject.unstage 1
48
- end
49
- end
50
-
51
- context 'when a staged new file is unstaged' do
52
- it 'should run git reset HEAD' do
53
- git.stub(:command).and_call_original
54
- git.stub(:command).with(/reset/, anything)
55
-
56
- expect(git).to receive(:command).with('reset HEAD --', ['untracked'])
57
-
58
- subject.unstage 3
59
- end
60
- end
61
- end
62
-
63
- context 'when the repository contains no staged files' do
64
- it 'should fail' do
65
- expect { subject.unstage 1 }.to raise_error
66
- end
67
- end
68
- end
@@ -1,48 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../spec_helper')
2
- require 'git_shizzle'
3
-
4
- describe 'Command DSL' do
5
-
6
- context 'when reading commands' do
7
- it 'should not accept commands without a definition' do
8
- commands = GitShizzle::Dsl::CommandCollection.new
9
- command_spec = <<-EOF
10
- command :foo
11
- EOF
12
-
13
- expect { commands.load command_spec }.to raise_error(GitShizzle::Dsl::CommandDefinitionError, "Command 'foo': #command requires a block.")
14
- end
15
- end
16
-
17
- it 'should not accept duplicate identifiers' do
18
- commands = GitShizzle::Dsl::CommandCollection.new
19
- command_spec = <<-EOF
20
- command :foo do end
21
- command :foo do end
22
- EOF
23
-
24
- expect { commands.load command_spec }.to raise_error(GitShizzle::Dsl::DuplicateCommandDefinitionError, "The 'foo' command was specified twice.")
25
- end
26
-
27
- it 'should not accept empty filters' do
28
- commands = GitShizzle::Dsl::CommandCollection.new
29
- command_spec = <<-EOF
30
- command :foo do
31
- applies_to
32
- end
33
- EOF
34
-
35
- expect { commands.load command_spec }.to raise_error(GitShizzle::Dsl::CommandDefinitionError, "Command 'foo': #applies_to requires a block.")
36
- end
37
-
38
- it 'should not accept empty actions' do
39
- commands = GitShizzle::Dsl::CommandCollection.new
40
- command_spec = <<-EOF
41
- command :foo do
42
- action
43
- end
44
- EOF
45
-
46
- expect { commands.load command_spec }.to raise_error(GitShizzle::Dsl::CommandDefinitionError, "Command 'foo': #action requires a block.")
47
- end
48
- end
@@ -1,15 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../spec_helper')
2
- require 'git_shizzle'
3
-
4
- describe 'Git Repository' do
5
-
6
- let(:git) { GitShizzle::Git::Git.new(repo) }
7
- subject { GitShizzle::QuickGit.new(git) }
8
-
9
- context 'when invoking a command outside a Git repository' do
10
- it 'should fail' do
11
- FileUtils.rm_rf '.git'
12
- expect { subject.run(:track) }.to raise_error(GitShizzle::Git::GitExecuteError, /Not a git repository/)
13
- end
14
- end
15
- end