git_wrapper 1.0.2 → 1.0.3

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 (36) hide show
  1. data/README.md +74 -74
  2. data/git_wrapper.gemspec +21 -21
  3. data/lib/git_wrapper/commands/add.rb +20 -20
  4. data/lib/git_wrapper/commands/branch.rb +72 -72
  5. data/lib/git_wrapper/commands/checkout.rb +20 -20
  6. data/lib/git_wrapper/commands/commit.rb +20 -20
  7. data/lib/git_wrapper/commands/config.rb +25 -25
  8. data/lib/git_wrapper/commands/diff.rb +27 -27
  9. data/lib/git_wrapper/commands/fetch.rb +20 -20
  10. data/lib/git_wrapper/commands/git.rb +43 -43
  11. data/lib/git_wrapper/commands/init.rb +15 -15
  12. data/lib/git_wrapper/commands/log.rb +81 -81
  13. data/lib/git_wrapper/commands/merge.rb +15 -15
  14. data/lib/git_wrapper/commands/pull.rb +20 -20
  15. data/lib/git_wrapper/commands/push.rb +26 -26
  16. data/lib/git_wrapper/commands/remote.rb +48 -48
  17. data/lib/git_wrapper/commands/remove.rb +15 -15
  18. data/lib/git_wrapper/commands/reset.rb +35 -35
  19. data/lib/git_wrapper/commands/revert.rb +22 -22
  20. data/lib/git_wrapper/commands/shell.rb +66 -66
  21. data/lib/git_wrapper/commands/show.rb +39 -39
  22. data/lib/git_wrapper/commands/status.rb +16 -16
  23. data/lib/git_wrapper/commands/tag.rb +53 -53
  24. data/lib/git_wrapper/repository.rb +208 -208
  25. data/lib/git_wrapper/results/diff_name_status.rb +27 -27
  26. data/lib/git_wrapper/results/file_status.rb +21 -21
  27. data/lib/git_wrapper/results/log_info.rb +22 -22
  28. data/lib/git_wrapper/results/status_porcelain.rb +39 -39
  29. data/lib/git_wrapper/version.rb +3 -3
  30. data/lib/git_wrapper.rb +46 -44
  31. data/spec/repository_spec.rb +888 -888
  32. data/spec/spec_helper.rb +9 -9
  33. data/spec/status_porcelain_parser_spec.rb +86 -86
  34. data/spec/support/helpers/file_helper.rb +40 -36
  35. data/spec/support/matchers/git_status_matchers.rb +39 -39
  36. metadata +17 -7
data/README.md CHANGED
@@ -1,74 +1,74 @@
1
- # GitWrapper
2
-
3
- OO git command line wrapper
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'git_wrapper'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install git_wrapper
18
-
19
- ## Requirments
20
-
21
- Git client must be installed and inculded in system path
22
-
23
- ## Usage
24
-
25
- ### Example
26
-
27
- repo = Repository.new(folder_name)
28
-
29
- repo.init
30
- # or
31
- repo.init_bare
32
-
33
- repo.add 'file_name'
34
- # or
35
- repo.add_all
36
-
37
- repo.status
38
-
39
- repo.commit 'message'
40
-
41
- repo.add_remote 'origin', 'git@localhost:repo.git'
42
-
43
- repo.push 'origin', 'master'
44
-
45
- ### Supported commands
46
-
47
- - Add
48
- - Branch
49
- - Checkout
50
- - Commit
51
- - Config
52
- - Diff
53
- - Fecht
54
- - Init
55
- - Log
56
- - Merge
57
- - Pull
58
- - Push
59
- - Remote
60
- - Remove
61
- - Reset
62
- - Revert
63
- - Show
64
- - Status
65
- - Tag
66
-
67
-
68
- ## Contributing
69
-
70
- 1. Fork it
71
- 2. Create your feature branch (`git checkout -b my-new-feature`)
72
- 3. Commit your changes (`git commit -am 'Added some feature'`)
73
- 4. Push to the branch (`git push origin my-new-feature`)
74
- 5. Create new Pull Request
1
+ # GitWrapper
2
+
3
+ OO git command line wrapper
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'git_wrapper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install git_wrapper
18
+
19
+ ## Requirments
20
+
21
+ Git client must be installed and inculded in system path
22
+
23
+ ## Usage
24
+
25
+ ### Example
26
+
27
+ repo = Repository.new(folder_name)
28
+
29
+ repo.init
30
+ # or
31
+ repo.init_bare
32
+
33
+ repo.add 'file_name'
34
+ # or
35
+ repo.add_all
36
+
37
+ repo.status
38
+
39
+ repo.commit 'message'
40
+
41
+ repo.add_remote 'origin', 'git@localhost:repo.git'
42
+
43
+ repo.push 'origin', 'master'
44
+
45
+ ### Supported commands
46
+
47
+ - Add
48
+ - Branch
49
+ - Checkout
50
+ - Commit
51
+ - Config
52
+ - Diff
53
+ - Fecht
54
+ - Init
55
+ - Log
56
+ - Merge
57
+ - Pull
58
+ - Push
59
+ - Remote
60
+ - Remove
61
+ - Reset
62
+ - Revert
63
+ - Show
64
+ - Status
65
+ - Tag
66
+
67
+
68
+ ## Contributing
69
+
70
+ 1. Fork it
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create new Pull Request
data/git_wrapper.gemspec CHANGED
@@ -1,21 +1,21 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "git_wrapper/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'git_wrapper'
7
- s.version = GitWrapper::VERSION
8
- s.authors = ['Gabriel Naiman']
9
- s.email = ['gabynaiman@gmail.com']
10
- s.homepage = 'https://github.com/gabynaiman/git_wrapper'
11
- s.summary = 'OO git command line wrapper'
12
- s.description = 'OO git command line wrapper'
13
-
14
- s.files = `git ls-files`.split("\n")
15
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
- s.require_paths = ["lib"]
18
-
19
- s.add_runtime_dependency 'nokogiri'
20
- s.add_development_dependency 'rspec'
21
- end
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "git_wrapper/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'git_wrapper'
7
+ s.version = GitWrapper::VERSION
8
+ s.authors = ['Gabriel Naiman']
9
+ s.email = ['gabynaiman@gmail.com']
10
+ s.homepage = 'https://github.com/gabynaiman/git_wrapper'
11
+ s.summary = 'OO git command line wrapper'
12
+ s.description = 'OO git command line wrapper'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency 'nokogiri'
20
+ s.add_development_dependency 'rspec'
21
+ end
@@ -1,21 +1,21 @@
1
- module GitWrapper
2
- module Commands
3
- class Add < Git
4
-
5
- def all
6
- @file = '-A'
7
- self
8
- end
9
-
10
- def file(file_name)
11
- @file = to_relative_path(file_name)
12
- self
13
- end
14
-
15
- def command
16
- "add \"#{@file}\""
17
- end
18
-
19
- end
20
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Add < Git
4
+
5
+ def all
6
+ @file = '-A'
7
+ self
8
+ end
9
+
10
+ def file(file_name)
11
+ @file = to_relative_path(file_name)
12
+ self
13
+ end
14
+
15
+ def command
16
+ "add \"#{@file}\""
17
+ end
18
+
19
+ end
20
+ end
21
21
  end
@@ -1,73 +1,73 @@
1
- module GitWrapper
2
- module Commands
3
- class Branch < Git
4
-
5
- def create(name)
6
- @mode = :create
7
- @name = name
8
- self
9
- end
10
-
11
- def from(commit)
12
- @commit = commit
13
- self
14
- end
15
-
16
- def remove(name)
17
- @mode = :remove
18
- @name = name
19
- self
20
- end
21
-
22
- def remote(remote)
23
- @remote = remote
24
- self
25
- end
26
-
27
- def list
28
- @mode = :list
29
- self
30
- end
31
-
32
- def current
33
- @mode = :current
34
- self
35
- end
36
-
37
- def command
38
- command = 'branch '
39
-
40
- if @mode == :create
41
- command += "#{@name} #{@commit.nil? ? '' : @commit}"
42
- elsif @mode == :remove
43
- if @remote.nil?
44
- command += "-D #{@name}"
45
- else
46
- command = "push #{@remote} --delete #{@name}"
47
- end
48
- elsif @mode == :list || @mode == :current
49
- command += '-a'
50
- else
51
- raise 'Unespecified branch mode'
52
- end
53
-
54
- command
55
- end
56
-
57
- def result
58
- return result_list if @mode == :list
59
- return result_current if @mode == :current
60
- super
61
- end
62
-
63
- def result_list
64
- output.split("\n").map{|b| b[2..b.length]}
65
- end
66
-
67
- def result_current
68
- output.split("\n").select{|b| b.start_with?('*')}.map{|b| b[2..b.length]}.first
69
- end
70
-
71
- end
72
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Branch < Git
4
+
5
+ def create(name)
6
+ @mode = :create
7
+ @name = name
8
+ self
9
+ end
10
+
11
+ def from(commit)
12
+ @commit = commit
13
+ self
14
+ end
15
+
16
+ def remove(name)
17
+ @mode = :remove
18
+ @name = name
19
+ self
20
+ end
21
+
22
+ def remote(remote)
23
+ @remote = remote
24
+ self
25
+ end
26
+
27
+ def list
28
+ @mode = :list
29
+ self
30
+ end
31
+
32
+ def current
33
+ @mode = :current
34
+ self
35
+ end
36
+
37
+ def command
38
+ command = 'branch '
39
+
40
+ if @mode == :create
41
+ command += "#{@name} #{@commit.nil? ? '' : @commit}"
42
+ elsif @mode == :remove
43
+ if @remote.nil?
44
+ command += "-D #{@name}"
45
+ else
46
+ command = "push #{@remote} --delete #{@name}"
47
+ end
48
+ elsif @mode == :list || @mode == :current
49
+ command += '-a'
50
+ else
51
+ raise 'Unespecified branch mode'
52
+ end
53
+
54
+ command
55
+ end
56
+
57
+ def result
58
+ return result_list if @mode == :list
59
+ return result_current if @mode == :current
60
+ super
61
+ end
62
+
63
+ def result_list
64
+ output.split("\n").map{|b| b[2..b.length]}
65
+ end
66
+
67
+ def result_current
68
+ output.split("\n").select{|b| b.start_with?('*')}.map{|b| b[2..b.length]}.first
69
+ end
70
+
71
+ end
72
+ end
73
73
  end
@@ -1,21 +1,21 @@
1
- module GitWrapper
2
- module Commands
3
- class Checkout < Git
4
-
5
- def commit(commit)
6
- @commit = commit
7
- self
8
- end
9
-
10
- def into(new_branch)
11
- @new_branch = new_branch
12
- self
13
- end
14
-
15
- def command
16
- "checkout #{@commit} #{@new_branch.nil? ? '' : "-b #{@new_branch}" }"
17
- end
18
-
19
- end
20
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Checkout < Git
4
+
5
+ def commit(commit)
6
+ @commit = commit
7
+ self
8
+ end
9
+
10
+ def into(new_branch)
11
+ @new_branch = new_branch
12
+ self
13
+ end
14
+
15
+ def command
16
+ "checkout #{@commit} #{@new_branch.nil? ? '' : "-b #{@new_branch}" }"
17
+ end
18
+
19
+ end
20
+ end
21
21
  end
@@ -1,21 +1,21 @@
1
- module GitWrapper
2
- module Commands
3
- class Commit < Git
4
-
5
- def message(message)
6
- @message = message
7
- self
8
- end
9
-
10
- def author(name, email)
11
- @author = "#{name} <#{email}>"
12
- self
13
- end
14
-
15
- def command
16
- "commit -m \"#{@message}\" #{@author ? "--author \"#{@author}\"" : ''}"
17
- end
18
-
19
- end
20
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Commit < Git
4
+
5
+ def message(message)
6
+ @message = message
7
+ self
8
+ end
9
+
10
+ def author(name, email)
11
+ @author = "#{name} <#{email}>"
12
+ self
13
+ end
14
+
15
+ def command
16
+ "commit -m \"#{@message}\" #{@author ? "--author \"#{@author}\"" : ''}"
17
+ end
18
+
19
+ end
20
+ end
21
21
  end
@@ -1,26 +1,26 @@
1
- module GitWrapper
2
- module Commands
3
- class Config < Git
4
-
5
- def key(key)
6
- @key = key
7
- self
8
- end
9
-
10
- def value(value)
11
- @value = value
12
- self
13
- end
14
-
15
- def command
16
- "config #{@key} #{@value}"
17
- end
18
-
19
- def result
20
- return @success if @value || !@success
21
- @output[0..(@output.length - 2)].strip
22
- end
23
-
24
- end
25
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Config < Git
4
+
5
+ def key(key)
6
+ @key = key
7
+ self
8
+ end
9
+
10
+ def value(value)
11
+ @value = value
12
+ self
13
+ end
14
+
15
+ def command
16
+ "config #{@key} #{@value}"
17
+ end
18
+
19
+ def result
20
+ return @success if @value || !@success
21
+ @output[0..(@output.length - 2)].strip
22
+ end
23
+
24
+ end
25
+ end
26
26
  end
@@ -1,27 +1,27 @@
1
- module GitWrapper
2
- module Commands
3
- class Diff < Git
4
-
5
- def with(commit)
6
- @commit = commit
7
- self
8
- end
9
-
10
- def reverse
11
- @reverse = true
12
- self
13
- end
14
-
15
- def command
16
- "diff #{@commit}#{@reverse ? ' -R ' : ''} --name-status"
17
- end
18
-
19
- def result
20
- output.split(/\n/).map do |line|
21
- Results::DiffNameStatus.parse(line)
22
- end
23
- end
24
-
25
- end
26
- end
27
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Diff < Git
4
+
5
+ def with(commit)
6
+ @commit = commit
7
+ self
8
+ end
9
+
10
+ def reverse
11
+ @reverse = true
12
+ self
13
+ end
14
+
15
+ def command
16
+ "diff #{@commit}#{@reverse ? ' -R ' : ''} --name-status"
17
+ end
18
+
19
+ def result
20
+ output.split(/\n/).map do |line|
21
+ Results::DiffNameStatus.parse(line)
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -1,21 +1,21 @@
1
- module GitWrapper
2
- module Commands
3
- class Fetch < Git
4
-
5
- def remote(remote)
6
- @remote = remote
7
- self
8
- end
9
-
10
- def all
11
- @remote = '--all'
12
- self
13
- end
14
-
15
- def command
16
- "fetch #{@remote}"
17
- end
18
-
19
- end
20
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Fetch < Git
4
+
5
+ def remote(remote)
6
+ @remote = remote
7
+ self
8
+ end
9
+
10
+ def all
11
+ @remote = '--all'
12
+ self
13
+ end
14
+
15
+ def command
16
+ "fetch #{@remote}"
17
+ end
18
+
19
+ end
20
+ end
21
21
  end