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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +0 -1
- data/.travis.yml +11 -0
- data/Gemfile +25 -1
- data/Guardfile +3 -2
- data/README.md +66 -0
- data/git_shizzle.gemspec +8 -25
- data/lib/commands.rb +4 -4
- data/lib/git_shizzle/git/git.rb +19 -19
- data/lib/git_shizzle/version.rb +1 -1
- data/spec/git_shizzle/builtin_commands/checkout_spec.rb +51 -0
- data/spec/git_shizzle/builtin_commands/diff_cached_spec.rb +55 -0
- data/spec/git_shizzle/builtin_commands/diff_spec.rb +51 -0
- data/spec/git_shizzle/builtin_commands/stage_patch_spec.rb +37 -0
- data/spec/{git-shizzle → git_shizzle}/builtin_commands/stage_spec.rb +19 -16
- data/spec/{git-shizzle → git_shizzle}/builtin_commands/track_spec.rb +12 -9
- data/spec/git_shizzle/builtin_commands/unstage_spec.rb +67 -0
- data/spec/{git-shizzle → git_shizzle}/command_spec.rb +0 -1
- data/spec/git_shizzle/dsl_spec.rb +42 -0
- data/spec/git_shizzle/git_spec.rb +34 -0
- data/spec/{git-shizzle → git_shizzle}/index_spec.rb +6 -3
- data/spec/{git-shizzle → git_shizzle}/status_parser_spec.rb +5 -6
- data/spec/helpers/git_repository.rb +3 -3
- data/spec/spec_helper.rb +7 -0
- metadata +35 -161
- data/Gemfile.lock +0 -71
- data/doc.txt +0 -8
- data/spec/git-shizzle/builtin_commands/checkout_spec.rb +0 -49
- data/spec/git-shizzle/builtin_commands/diff_cached_spec.rb +0 -53
- data/spec/git-shizzle/builtin_commands/diff_spec.rb +0 -49
- data/spec/git-shizzle/builtin_commands/stage_patch_spec.rb +0 -32
- data/spec/git-shizzle/builtin_commands/unstage_spec.rb +0 -68
- data/spec/git-shizzle/dsl_spec.rb +0 -48
- data/spec/git-shizzle/git_spec.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f81e7bd6d517a1aee359ee001614c960293db9e
|
4
|
+
data.tar.gz: 8244dd26914f17b277e238a021d1e2b4085e3a92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a194af6c83e344ebb3d4f525bcd032eb77a1cf9d21e92c18fcb6c52067a40551ce6c9c2be161bc17dd14ce66e36b9db448d0051b858ad709a4c0fa66335c6b7e
|
7
|
+
data.tar.gz: aa1334b811aa300578507bb9f27d2bdd45665d9907da10c112b29335929e42e5e079d641b24be3b06af2607cc45d22be762fdf43de5bb7abdc97cfd9de182d5b
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
-
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'guard-bundler', require: false
|
9
|
+
gem 'guard-rspec', require: false
|
10
|
+
|
11
|
+
case RbConfig::CONFIG['target_os']
|
12
|
+
when /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
|
13
|
+
gem 'ruby_gntp', require: false
|
14
|
+
gem 'wdm', require: false
|
15
|
+
when /linux/i
|
16
|
+
gem 'rb-inotify', require: false
|
17
|
+
when /mac|darwin/i
|
18
|
+
gem 'rb-fsevent', require: false
|
19
|
+
gem 'growl', require: false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
group :development, :ci do
|
24
|
+
gem 'rspec', '~> 3.0', require: false
|
25
|
+
gem 'rspec-its', require: false
|
26
|
+
gem 'coveralls', require: false
|
27
|
+
end
|
data/Guardfile
CHANGED
@@ -14,9 +14,10 @@ end
|
|
14
14
|
|
15
15
|
guard 'rspec',
|
16
16
|
:all_on_start => true,
|
17
|
-
:all_after_pass =>
|
17
|
+
:all_after_pass => true,
|
18
18
|
:notification => true,
|
19
|
-
:cmd => 'bundle exec rspec
|
19
|
+
:cmd => 'bundle exec rspec' do
|
20
|
+
watch('.rspec')
|
20
21
|
watch(%r{^spec/.+_spec\.rb$})
|
21
22
|
watch(%r{^lib/(.+)\.rb$})
|
22
23
|
watch('spec/spec_helper.rb') { 'spec' }
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# git_shizzle
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/git_shizzle) [](https://travis-ci.org/agross/git_shizzle) [](https://gemnasium.com/agross/git_shizzle) [](https://codeclimate.com/github/agross/git_shizzle) [](https://coveralls.io/r/agross/git_shizzle)
|
4
|
+
|
5
|
+
git_shizzle lets you quickly operate on the file lists printed by `git status`. Imagine a number before each line of the status output and use that index to specify the file you want to operate on. For example, to stage the first file in the list of "Changes not staged for commit", run `quick-git stage 1`.
|
6
|
+
|
7
|
+
* Tested against Ruby 1.9.3, 2.0.0 and 2.1.0
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```bash
|
12
|
+
$ gem install git_shizzle
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ quick-git help
|
19
|
+
```
|
20
|
+
|
21
|
+
### Examples
|
22
|
+
|
23
|
+
```bash
|
24
|
+
# Stage modified file 1 (first in output of git status).
|
25
|
+
$ quick-git stage 1
|
26
|
+
|
27
|
+
# Stage modified file 1, 2, 3 and 4, as in output of git status.
|
28
|
+
$ quick-git stage 1 2 3 4
|
29
|
+
|
30
|
+
# Stage files 1 to 3. Used like a Ruby range.
|
31
|
+
$ quick-git stage 1..3
|
32
|
+
|
33
|
+
# Stage all modified files.
|
34
|
+
$ quick-git stage .
|
35
|
+
|
36
|
+
# Show diff of modified file 1.
|
37
|
+
$ quick-git diff 1
|
38
|
+
|
39
|
+
# Remove staged file 1 from the index.
|
40
|
+
$ quick-git unstage 1
|
41
|
+
|
42
|
+
# Add untracked file 1 to the index.
|
43
|
+
$ quick-git track 1
|
44
|
+
|
45
|
+
# Discard working copy changes of modified file 1.
|
46
|
+
$ quick-git checkout 1
|
47
|
+
```
|
48
|
+
|
49
|
+
### git aliases
|
50
|
+
|
51
|
+
I recommend you set up git aliases like `git config --global alias.qa quick-git stage`. See some examples in [my dotfiles repository](https://github.com/agross/dotfiles/blob/master/profiles/cygwin/git/gitconfig#L18).
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
* Source hosted at [GitHub](https://github.com/agross/git_shizzle)
|
56
|
+
* Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/agross/git_shizzle/issues)
|
57
|
+
|
58
|
+
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. Fork it (http://github.com/agross/git_shizzle/fork)
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. Create new Pull Request
|
data/git_shizzle.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rbconfig'
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'git_shizzle/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
@@ -10,33 +9,17 @@ Gem::Specification.new do |s|
|
|
10
9
|
s.authors = ['Bjoern Rochel', 'Alexander Groß']
|
11
10
|
s.email = ['bjoern@bjro.de', 'agross@therightstuff.de']
|
12
11
|
s.homepage = 'http://grossweber.com'
|
13
|
-
s.
|
12
|
+
s.license = 'BSD'
|
14
13
|
s.description = %q{git_shizzle lets you quickly operate on the file lists printed by `git status`. Imagine a number before each line of the status output and use that index to specify the file you want to operate on. For example, to stage the first file in the list of "Changes not staged for commit", run `quick-git stage 1`.}
|
15
14
|
s.summary = %q{Quickly operate on the git working copy and the index}
|
16
15
|
|
17
|
-
s.
|
18
|
-
|
19
|
-
s.add_development_dependency 'rake'
|
20
|
-
s.add_development_dependency 'rspec'
|
21
|
-
s.add_development_dependency 'rspec-mocks'
|
22
|
-
s.add_development_dependency 'guard'
|
23
|
-
s.add_development_dependency 'guard-rspec'
|
24
|
-
s.add_development_dependency 'guard-bundler'
|
16
|
+
s.required_ruby_version = '>= 1.9.3'
|
25
17
|
|
26
|
-
|
27
|
-
when /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
|
28
|
-
s.add_development_dependency 'win32console'
|
29
|
-
s.add_development_dependency 'ruby_gntp'
|
30
|
-
s.add_development_dependency 'wdm'
|
31
|
-
when /linux/i
|
32
|
-
s.add_development_dependency 'rb-inotify', '~> 0.8.8'
|
33
|
-
when /mac|darwin/i
|
34
|
-
s.add_development_dependency 'rb-fsevent'
|
35
|
-
s.add_development_dependency 'growl'
|
36
|
-
end
|
18
|
+
s.add_dependency 'thor', '~> 0.16'
|
37
19
|
|
38
|
-
|
20
|
+
git = ENV['TEAMCITY_GIT_PATH'] || 'git'
|
21
|
+
s.files = `"#{git}" ls-files -z`.split("\x0")
|
22
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
39
23
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
40
|
-
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
41
24
|
s.require_paths = ['lib']
|
42
25
|
end
|
data/lib/commands.rb
CHANGED
@@ -11,7 +11,7 @@ command :stage do
|
|
11
11
|
when :modified
|
12
12
|
['add --', path]
|
13
13
|
when :deleted
|
14
|
-
['rm --', path]
|
14
|
+
['rm --quiet --', path]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -37,9 +37,9 @@ command :track do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
action do |index, work_tree, path|
|
40
|
-
|
41
|
-
end
|
40
|
+
['add --', path] if work_tree == :untracked
|
42
41
|
end
|
42
|
+
end
|
43
43
|
|
44
44
|
desc 'diff files'
|
45
45
|
command :diff do
|
@@ -72,7 +72,7 @@ command :checkout do
|
|
72
72
|
action do |index, work_tree, path|
|
73
73
|
['checkout --', path]
|
74
74
|
end
|
75
|
-
|
75
|
+
end
|
76
76
|
|
77
77
|
desc 'unstage files'
|
78
78
|
command :unstage do
|
data/lib/git_shizzle/git/git.rb
CHANGED
@@ -10,17 +10,15 @@ module GitShizzle::Git
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def status
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
:status_line => line)
|
23
|
-
end
|
13
|
+
status = command 'status --porcelain -z', [], :verbose => false, :redirect_io => true
|
14
|
+
status
|
15
|
+
.each_line("\x00")
|
16
|
+
.select { |line| line =~ /^[\p{Lu}\x20\?!]{2}\s/ }
|
17
|
+
.each_with_index.map do |line, index|
|
18
|
+
File.new(:index => index,
|
19
|
+
:status => line[0..1],
|
20
|
+
:path => line[3..-1].delete("\000"),
|
21
|
+
:status_line => line)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
@@ -48,20 +46,22 @@ module GitShizzle::Git
|
|
48
46
|
end
|
49
47
|
|
50
48
|
def run_command(git_cmd, params = { }, &block)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
if params.fetch(:redirect_io, false)
|
55
|
-
git_cmd += ' 2>&1'
|
56
|
-
`#{git_cmd}`.chomp
|
49
|
+
Dir.chdir(@repo_location) do
|
50
|
+
if block_given?
|
51
|
+
IO.popen(git_cmd, &block)
|
57
52
|
else
|
58
|
-
|
53
|
+
if params.fetch(:redirect_io, false)
|
54
|
+
git_cmd += ' 2>&1'
|
55
|
+
`#{git_cmd}`.chomp
|
56
|
+
else
|
57
|
+
system git_cmd
|
58
|
+
end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
def echo(msg, verbose)
|
64
|
-
puts(msg) if verbose && defined?(Thor)
|
64
|
+
$stdout.puts(msg) if verbose && defined?(Thor)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/lib/git_shizzle/version.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'git_shizzle'
|
2
|
+
|
3
|
+
describe 'Checkout files by index' do
|
4
|
+
|
5
|
+
let(:git) { GitShizzle::Git::Git.new(repo) }
|
6
|
+
subject { GitShizzle::QuickGit.new(git) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow($stdout).to receive(:puts)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'repository with modified files' do
|
13
|
+
before do
|
14
|
+
%w{ deleted modified }.each { |f| create f; stage f }
|
15
|
+
`git commit --message Blah`
|
16
|
+
|
17
|
+
delete 'deleted'
|
18
|
+
modify 'modified'
|
19
|
+
|
20
|
+
expect(git.status[0].work_tree_status).to eq(:deleted)
|
21
|
+
expect(git.status[1].work_tree_status).to eq(:modified)
|
22
|
+
end
|
23
|
+
|
24
|
+
before do
|
25
|
+
allow(git).to receive(:command).and_call_original
|
26
|
+
allow(git).to receive(:command).with(/checkout/, anything)
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when a modified file is checked out' do
|
30
|
+
it 'should run git checkout' do
|
31
|
+
subject.checkout 2
|
32
|
+
|
33
|
+
expect(git).to have_received(:command).with('checkout --', ['modified'])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when a deleted file is checked out' do
|
38
|
+
it 'should run git checkout' do
|
39
|
+
subject.checkout 1
|
40
|
+
|
41
|
+
expect(git).to have_received(:command).with('checkout --', ['deleted'])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'repository without modified files' do
|
47
|
+
it 'should fail' do
|
48
|
+
expect { subject.checkout 1 }.to raise_error
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'git_shizzle'
|
2
|
+
|
3
|
+
describe 'Diff staged/cached files by index' do
|
4
|
+
|
5
|
+
let(:git) { GitShizzle::Git::Git.new(repo) }
|
6
|
+
subject { GitShizzle::QuickGit.new(git) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow($stdout).to receive(:puts)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'repository with staged files' do
|
13
|
+
before do
|
14
|
+
%w{ deleted modified }.each { |f| create f; stage f }
|
15
|
+
`git commit --message Blah`
|
16
|
+
|
17
|
+
delete 'deleted'
|
18
|
+
stage 'deleted'
|
19
|
+
modify 'modified'
|
20
|
+
stage 'modified'
|
21
|
+
|
22
|
+
expect(git.status[0].work_tree_status).to eq(nil)
|
23
|
+
expect(git.status[0].index_status).to eq(:deleted)
|
24
|
+
expect(git.status[1].work_tree_status).to eq(nil)
|
25
|
+
expect(git.status[1].index_status).to eq(:modified)
|
26
|
+
end
|
27
|
+
|
28
|
+
before do
|
29
|
+
allow(git).to receive(:command).and_call_original
|
30
|
+
allow(git).to receive(:command).with(/diff/, anything)
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when a staged modified file is diffed' do
|
34
|
+
it 'should run git diff --cached' do
|
35
|
+
subject.diff_cached 2
|
36
|
+
|
37
|
+
expect(git).to have_received(:command).with('diff --cached --', ['modified'])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when a staged deleted file is diffed' do
|
42
|
+
it 'should run git diff --cached' do
|
43
|
+
subject.diff_cached 1
|
44
|
+
|
45
|
+
expect(git).to have_received(:command).with('diff --cached --', ['deleted'])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'repository without staged files' do
|
51
|
+
it 'should fail' do
|
52
|
+
expect { subject.diff_cached 1 }.to raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'git_shizzle'
|
2
|
+
|
3
|
+
describe 'Diff files by index' do
|
4
|
+
|
5
|
+
let(:git) { GitShizzle::Git::Git.new(repo) }
|
6
|
+
subject { GitShizzle::QuickGit.new(git) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow($stdout).to receive(:puts)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'repository with modified files' do
|
13
|
+
before do
|
14
|
+
%w{ deleted modified }.each { |f| create f; stage f }
|
15
|
+
`git commit --message Blah`
|
16
|
+
|
17
|
+
delete 'deleted'
|
18
|
+
modify 'modified'
|
19
|
+
|
20
|
+
expect(git.status[0].work_tree_status).to eq(:deleted)
|
21
|
+
expect(git.status[1].work_tree_status).to eq(:modified)
|
22
|
+
end
|
23
|
+
|
24
|
+
before do
|
25
|
+
allow(git).to receive(:command).and_call_original
|
26
|
+
allow(git).to receive(:command).with(/diff/, anything)
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when a modified file is diffed' do
|
30
|
+
it 'should run git diff' do
|
31
|
+
subject.diff 2
|
32
|
+
|
33
|
+
expect(git).to have_received(:command).with('diff --', ['modified'])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when a deleted file is diffed' do
|
38
|
+
it 'should run git diff' do
|
39
|
+
subject.diff 1
|
40
|
+
|
41
|
+
expect(git).to have_received(:command).with('diff --', ['deleted'])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'repository without modified files' do
|
47
|
+
it 'should fail' do
|
48
|
+
expect { subject.diff 1 }.to raise_error
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|