git_wrapper 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,67 +1,67 @@
1
- module GitWrapper
2
- module Commands
3
-
4
- module Shell
5
-
6
- def self.execute(command, options={})
7
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
8
- jruby_execute(command, options)
9
- else
10
- ruby_execute(command, options)
11
- end
12
- end
13
-
14
- def self.ruby_execute(command, options={})
15
- location_folder = options[:chdir] || '.'
16
- result = nil
17
-
18
- Open3.popen3(command, :chdir => location_folder) do |stdin, stdout, stderr, wait_thr|
19
- output = stdout.readlines.join
20
- error = stderr.readlines.join
21
- status = wait_thr.value
22
-
23
- if block_given?
24
- result = status
25
- yield(output, error, wait_thr.pid)
26
- else
27
- result = [output, error, status]
28
- end
29
- end
30
-
31
- return result
32
- end
33
-
34
- def self.jruby_execute(command, options={})
35
- location_folder = options[:chdir] || '.'
36
-
37
- prev_stdout = $stdout
38
- prev_stderr = $stderr
39
-
40
- $stdout = StringIO.new
41
- $stderr = StringIO.new
42
-
43
- begin
44
- Dir.chdir location_folder do
45
- system(command)
46
- end
47
- status = $?
48
- $stdout.rewind
49
- $stderr.rewind
50
- if block_given?
51
- yield($stdout.readlines.join.force_encoding('UTF-8'), $stderr.readlines.join.force_encoding('UTF-8'), status.pid)
52
- result = status
53
- else
54
- result = $stdout.readlines.join.force_encoding('UTF-8'), $stderr.readlines.join.force_encoding('UTF-8'), status
55
- end
56
- ensure
57
- $stdout = prev_stdout
58
- $stderr = prev_stderr
59
- end
60
-
61
- return result
62
- end
63
-
64
- end
65
-
66
- end
1
+ module GitWrapper
2
+ module Commands
3
+
4
+ module Shell
5
+
6
+ def self.execute(command, options={})
7
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
8
+ jruby_execute(command, options)
9
+ else
10
+ ruby_execute(command, options)
11
+ end
12
+ end
13
+
14
+ def self.ruby_execute(command, options={})
15
+ location_folder = options[:chdir] || '.'
16
+ result = nil
17
+
18
+ Open3.popen3(command, :chdir => location_folder) do |stdin, stdout, stderr, wait_thr|
19
+ output = stdout.readlines.join
20
+ error = stderr.readlines.join
21
+ status = wait_thr.value
22
+
23
+ if block_given?
24
+ result = status
25
+ yield(output, error, wait_thr.pid)
26
+ else
27
+ result = [output, error, status]
28
+ end
29
+ end
30
+
31
+ return result
32
+ end
33
+
34
+ def self.jruby_execute(command, options={})
35
+ location_folder = options[:chdir] || '.'
36
+
37
+ prev_stdout = $stdout
38
+ prev_stderr = $stderr
39
+
40
+ $stdout = StringIO.new
41
+ $stderr = StringIO.new
42
+
43
+ begin
44
+ Dir.chdir location_folder do
45
+ system(command)
46
+ end
47
+ status = $?
48
+ $stdout.rewind
49
+ $stderr.rewind
50
+ if block_given?
51
+ yield($stdout.readlines.join.force_encoding('UTF-8'), $stderr.readlines.join.force_encoding('UTF-8'), status.pid)
52
+ result = status
53
+ else
54
+ result = $stdout.readlines.join.force_encoding('UTF-8'), $stderr.readlines.join.force_encoding('UTF-8'), status
55
+ end
56
+ ensure
57
+ $stdout = prev_stdout
58
+ $stderr = prev_stderr
59
+ end
60
+
61
+ return result
62
+ end
63
+
64
+ end
65
+
66
+ end
67
67
  end
@@ -1,40 +1,40 @@
1
- module GitWrapper
2
- module Commands
3
- class Show < Git
4
-
5
- def file(file_name)
6
- @file = to_relative_path(file_name)
7
- self
8
- end
9
-
10
- def commit(commit)
11
- @version = "#{commit}:"
12
- self
13
- end
14
-
15
- def base
16
- @version = ':1:'
17
- self
18
- end
19
-
20
- def mine
21
- @version = ':2:'
22
- self
23
- end
24
-
25
- def theirs
26
- @version = ':3:'
27
- self
28
- end
29
-
30
- def command
31
- "show #{@version ? @version : 'HEAD:'}\"#{@file}\""
32
- end
33
-
34
- def result
35
- output
36
- end
37
-
38
- end
39
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Show < Git
4
+
5
+ def file(file_name)
6
+ @file = to_relative_path(file_name)
7
+ self
8
+ end
9
+
10
+ def commit(commit)
11
+ @version = "#{commit}:"
12
+ self
13
+ end
14
+
15
+ def base
16
+ @version = ':1:'
17
+ self
18
+ end
19
+
20
+ def mine
21
+ @version = ':2:'
22
+ self
23
+ end
24
+
25
+ def theirs
26
+ @version = ':3:'
27
+ self
28
+ end
29
+
30
+ def command
31
+ "show #{@version ? @version : 'HEAD:'}\"#{@file}\""
32
+ end
33
+
34
+ def result
35
+ output
36
+ end
37
+
38
+ end
39
+ end
40
40
  end
@@ -1,17 +1,17 @@
1
- module GitWrapper
2
- module Commands
3
- class Status < Git
4
-
5
- def command
6
- 'status --porcelain'
7
- end
8
-
9
- def result
10
- output.split(/\n/).map do |line|
11
- Results::StatusPorcelain.parse(line)
12
- end
13
- end
14
-
15
- end
16
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Status < Git
4
+
5
+ def command
6
+ 'status --porcelain'
7
+ end
8
+
9
+ def result
10
+ output.split(/\n/).map do |line|
11
+ Results::StatusPorcelain.parse(line)
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
17
  end
@@ -1,54 +1,54 @@
1
- module GitWrapper
2
- module Commands
3
- class Tag < 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 list
23
- @mode = :list
24
- self
25
- end
26
-
27
- def command
28
- command = 'tag '
29
-
30
- if @mode == :create
31
- command += "#{@name} #{@commit.nil? ? '' : @commit}"
32
- elsif @mode == :remove
33
- command += "-d #{@name}"
34
- elsif @mode == :list
35
- #Nothing to add
36
- else
37
- raise 'Unespecified tag mode'
38
- end
39
-
40
- command
41
- end
42
-
43
- def result
44
- return result_list if @mode == :list
45
- super
46
- end
47
-
48
- def result_list
49
- output.split("\n")
50
- end
51
-
52
- end
53
- end
1
+ module GitWrapper
2
+ module Commands
3
+ class Tag < 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 list
23
+ @mode = :list
24
+ self
25
+ end
26
+
27
+ def command
28
+ command = 'tag '
29
+
30
+ if @mode == :create
31
+ command += "#{@name} #{@commit.nil? ? '' : @commit}"
32
+ elsif @mode == :remove
33
+ command += "-d #{@name}"
34
+ elsif @mode == :list
35
+ #Nothing to add
36
+ else
37
+ raise 'Unespecified tag mode'
38
+ end
39
+
40
+ command
41
+ end
42
+
43
+ def result
44
+ return result_list if @mode == :list
45
+ super
46
+ end
47
+
48
+ def result_list
49
+ output.split("\n")
50
+ end
51
+
52
+ end
53
+ end
54
54
  end