git-process 1.0.4 → 1.0.5

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/CHANGELOG.md +11 -1
  2. data/README.md +2 -8
  3. data/lib/git-process/abstract_error_builder.rb +2 -2
  4. data/lib/git-process/changed_file_helper.rb +1 -1
  5. data/lib/git-process/git_abstract_merge_error_builder.rb +2 -1
  6. data/lib/git-process/git_branch.rb +3 -2
  7. data/lib/git-process/git_branches.rb +9 -8
  8. data/lib/git-process/git_lib.rb +18 -19
  9. data/lib/git-process/git_merge_error.rb +2 -1
  10. data/lib/git-process/git_process.rb +8 -6
  11. data/lib/git-process/git_process_error.rb +1 -1
  12. data/lib/git-process/git_process_options.rb +6 -8
  13. data/lib/git-process/git_rebase_error.rb +2 -1
  14. data/lib/git-process/git_status.rb +37 -36
  15. data/lib/git-process/github_client.rb +8 -10
  16. data/lib/git-process/github_pull_request.rb +9 -7
  17. data/lib/git-process/github_service.rb +7 -7
  18. data/lib/git-process/new_fb.rb +1 -1
  19. data/lib/git-process/parked_changes_error.rb +2 -1
  20. data/lib/git-process/pull_request.rb +1 -1
  21. data/lib/git-process/rebase_to_master.rb +10 -9
  22. data/lib/git-process/sync.rb +17 -5
  23. data/lib/git-process/uncommitted_changes_error.rb +1 -1
  24. data/lib/git-process/version.rb +2 -2
  25. data/spec/FileHelpers.rb +1 -0
  26. data/spec/GitRepoHelper.rb +3 -3
  27. data/spec/changed_file_helper_spec.rb +2 -2
  28. data/spec/git_abstract_merge_error_builder_spec.rb +32 -28
  29. data/spec/git_lib_spec.rb +16 -13
  30. data/spec/git_process_spec.rb +2 -1
  31. data/spec/git_status_spec.rb +5 -4
  32. data/spec/github_pull_request_spec.rb +9 -8
  33. data/spec/github_service_spec.rb +10 -8
  34. data/spec/rebase_to_master_spec.rb +7 -6
  35. data/spec/sync_spec.rb +56 -22
  36. metadata +30 -17
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
- # CHANGELOG - 1.0.3 #
1
+ # CHANGELOG - 1.0.5 #
2
+
3
+ ### Since 1.0.4 ###
4
+
5
+ * Do not try to fetch/push when doing sync if there is not remote. (GH-70)
6
+ * git-sync now merges in upstream changes. (GH-79)
7
+ * Simplified Windows installation instructions. (GH-76 GH-77)
8
+
9
+ ### Since 1.0.3 ###
10
+
11
+ * Gets rid of infinate loop in Highline library. (GH-72)
2
12
 
3
13
  ### Since 1.0.2 ###
4
14
 
data/README.md CHANGED
@@ -17,14 +17,8 @@ Some older operating systems (such as OSX 10.6) are using an old version of Ruby
17
17
 
18
18
  ## Windows Installation ##
19
19
 
20
- 1. Run http://cygwin.com/setup.exe
21
- 2. Go through the various prompts and then select to install "git", "curl", "ruby" and "openssh" (along with their dependencies)
22
- 3. Open a Cygwin terminal
23
- 4. `curl -L -O http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz`
24
- 5. `tar xfz rubygems-1.8.24.tgz`
25
- 6. `cd rubygems-1.8.24`
26
- 7. `ruby setup.rb`
27
- 8. `gem install git-process`
20
+ 1. Install Ruby (if you have not sone so already) from http://rubyinstaller.org/
21
+ 2. Open a command prompt and type `gem install git-process`
28
22
 
29
23
 
30
24
  # Overview #
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'shellwords'
14
14
 
@@ -47,7 +47,7 @@ module GitProc
47
47
 
48
48
 
49
49
  def shell_escaped_files(files)
50
- shell_escaped_files = files.map{|f| f.shellescape}
50
+ shell_escaped_files = files.map { |f| f.shellescape }
51
51
  shell_escaped_files.join(' ')
52
52
  end
53
53
 
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'git-process/git_lib'
14
14
  require 'highline/import'
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'git-process/abstract_error_builder'
14
14
  require 'shellwords'
@@ -21,6 +21,7 @@ module GitProc
21
21
  module AbstractMergeErrorBuilder
22
22
  include GitProc::AbstractErrorBuilder
23
23
 
24
+
24
25
  def resolved_files
25
26
  @resolved_files ||= find_resolved_files
26
27
  end
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  module GitProc
14
14
 
@@ -17,8 +17,9 @@ module GitProc
17
17
 
18
18
  attr_reader :name
19
19
 
20
+
20
21
  def initialize(name, current, lib)
21
- if (/^remotes\// =~ name)
22
+ if /^remotes\// =~ name
22
23
  @name = name[8..-1]
23
24
  @remote = true
24
25
  else
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'set'
14
14
  require 'git-process/git_branch'
@@ -18,6 +18,7 @@ module GitProc
18
18
  class GitBranches
19
19
  include Enumerable
20
20
 
21
+
21
22
  def initialize(lib)
22
23
  @lib = lib
23
24
  branch_lines = lib.branch(nil, :all => true, :no_color => true).split("\n")
@@ -34,35 +35,35 @@ module GitProc
34
35
 
35
36
 
36
37
  def each(&block)
37
- @items.each {|b| block.call(b)}
38
+ @items.each { |b| block.call(b) }
38
39
  end
39
40
 
40
41
 
41
42
  def names
42
- @items.map {|b| b.name}
43
+ @items.map { |b| b.name }
43
44
  end
44
45
 
45
46
 
46
47
  def current
47
- @items.find {|b| b.current? }
48
+ @items.find { |b| b.current? }
48
49
  end
49
50
 
50
51
 
51
52
  def parking
52
- @items.find {|b| b.name == '_parking_' }
53
+ @items.find { |b| b.name == '_parking_' }
53
54
  end
54
55
 
55
56
 
56
57
  def include?(branch_name)
57
- @items.find {|b| b.name == branch_name} != nil
58
+ @items.find { |b| b.name == branch_name } != nil
58
59
  end
59
60
 
60
61
 
61
62
  def [](branch_name)
62
63
  branch_name = current.name if branch_name == 'HEAD'
63
- br = @items.find {|b| b.name == branch_name}
64
+ br = @items.find { |b| b.name == branch_name }
64
65
  if br.nil? and branch_name !~ /origin\// and branch_name != '_parking_'
65
- @lib.logger.warn {"Could not find '#{branch_name}' in #{@items.map{|i|i.name}.join(',')}"}
66
+ @lib.logger.warn { "Could not find '#{branch_name}' in #{@items.map { |i| i.name }.join(',')}" }
66
67
  end
67
68
  br
68
69
  end
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'logger'
14
14
  require 'git-process/git_branch'
@@ -55,8 +55,7 @@ module GitProc
55
55
  @logger = Logger.new(STDOUT)
56
56
  @logger.level = log_level || Logger::WARN
57
57
  @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
58
- f = Logger::Formatter.new
59
- @logger.formatter = proc do |severity, datetime, progname, msg|
58
+ @logger.formatter = proc do |_, _, _, msg|
60
59
  "#{msg}\n"
61
60
  end
62
61
  end
@@ -135,22 +134,22 @@ module GitProc
135
134
  def branch(branch_name, opts = {})
136
135
  args = []
137
136
  if opts[:delete]
138
- logger.info { "Deleting local branch '#{branch_name}'."} unless branch_name == '_parking_'
137
+ logger.info { "Deleting local branch '#{branch_name}'." } unless branch_name == '_parking_'
139
138
 
140
139
  args << (opts[:force] ? '-D' : '-d')
141
140
  args << branch_name
142
141
  elsif opts[:rename]
143
- logger.info { "Renaming branch '#{branch_name}' to '#{opts[:rename]}'."}
142
+ logger.info { "Renaming branch '#{branch_name}' to '#{opts[:rename]}'." }
144
143
 
145
144
  args << '-m' << branch_name << opts[:rename]
146
145
  elsif branch_name
147
146
  if opts[:force]
148
147
  raise ArgumentError.new("Need :base_branch when using :force for a branch.") unless opts[:base_branch]
149
- logger.info { "Changing branch '#{branch_name}' to point to '#{opts[:base_branch]}'."}
148
+ logger.info { "Changing branch '#{branch_name}' to point to '#{opts[:base_branch]}'." }
150
149
 
151
150
  args << '-f' << branch_name << opts[:base_branch]
152
151
  else
153
- logger.info { "Creating new branch '#{branch_name}' based on '#{opts[:base_branch]}'."}
152
+ logger.info { "Creating new branch '#{branch_name}' based on '#{opts[:base_branch]}'." }
154
153
 
155
154
  args << branch_name
156
155
  args << (opts[:base_branch] ? opts[:base_branch] : 'master')
@@ -197,7 +196,7 @@ module GitProc
197
196
  raise GitProc::GitProcessError.new("Can not delete the integration branch '#{int_branch}'")
198
197
  end
199
198
 
200
- logger.info { "Deleting remote branch '#{rb}' on '#{remote_name}'."}
199
+ logger.info { "Deleting remote branch '#{rb}' on '#{remote_name}'." }
201
200
  args << '--delete' << rb
202
201
  else
203
202
  local_branch ||= branches.current
@@ -224,12 +223,12 @@ module GitProc
224
223
 
225
224
 
226
225
  def stash_save
227
- command(:stash, ['save'])
226
+ command(:stash, %w(save))
228
227
  end
229
228
 
230
229
 
231
230
  def stash_pop
232
- command(:stash, ['pop'])
231
+ command(:stash, %w(pop))
233
232
  end
234
233
 
235
234
 
@@ -238,7 +237,7 @@ module GitProc
238
237
  end
239
238
 
240
239
 
241
- def checkout(branch_name, opts = {}, &block)
240
+ def checkout(branch_name, opts = {})
242
241
  args = []
243
242
  args << '--no-track' if opts[:no_track]
244
243
  args << '-b' if opts[:new_branch]
@@ -282,7 +281,7 @@ module GitProc
282
281
 
283
282
  def config(key = nil, value = nil, global = false)
284
283
  if key and value
285
- args = global ? ['--global'] : []
284
+ args = global ? %w(--global) : []
286
285
  args << key << value
287
286
  command(:config, args)
288
287
  config_hash[key] = value unless config_hash.empty?
@@ -329,7 +328,7 @@ module GitProc
329
328
  raise "!@remote_name.is_a? String" unless @remote_name.is_a? String
330
329
  end
331
330
  end
332
- logger.debug {"Using remote name of '#{@remote_name}'"}
331
+ logger.debug { "Using remote name of '#@remote_name'" }
333
332
  end
334
333
  @remote_name
335
334
  end
@@ -414,30 +413,30 @@ module GitProc
414
413
  ENV['GIT_WORK_TREE'] = workdir
415
414
  path = workdir
416
415
 
417
- opts = [opts].flatten.map {|s| escape(s) }.join(' ')
416
+ opts = [opts].flatten.map { |s| escape(s) }.join(' ')
418
417
  git_cmd = "git #{cmd} #{opts} #{redirect} 2>&1"
419
418
 
420
419
  out = nil
421
420
  if chdir and (Dir.getwd != path)
422
- Dir.chdir(path) { out = run_command(git_cmd, &block) }
421
+ Dir.chdir(path) { out = run_command(git_cmd, &block) }
423
422
  else
424
423
  out = run_command(git_cmd, &block)
425
424
  end
426
-
425
+
427
426
  if logger
428
427
  logger.debug(git_cmd)
429
428
  logger.debug(out)
430
429
  end
431
-
430
+
432
431
  if $?.exitstatus > 0
433
432
  if $?.exitstatus == 1 && out == ''
434
433
  return ''
435
434
  end
436
- raise GitProc::GitExecuteError.new(git_cmd + ':' + out.to_s)
435
+ raise GitProc::GitExecuteError.new(git_cmd + ':' + out.to_s)
437
436
  end
438
437
  out
439
438
  end
440
-
439
+
441
440
 
442
441
  def run_command(git_cmd, &block)
443
442
  if block_given?
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'git-process/git_abstract_merge_error_builder'
14
14
 
@@ -19,6 +19,7 @@ module GitProc
19
19
 
20
20
  attr_reader :error_message, :lib
21
21
 
22
+
22
23
  def initialize(merge_error_message, lib)
23
24
  @lib = lib
24
25
  @error_message = merge_error_message
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'git-process/git_lib'
14
14
  require 'git-process/git_rebase_error'
@@ -21,6 +21,7 @@ module GitProc
21
21
  class Process
22
22
  include GitLib
23
23
 
24
+
24
25
  def initialize(dir, opts = {})
25
26
  @log_level = Process.log_level(opts)
26
27
 
@@ -48,7 +49,7 @@ module GitProc
48
49
 
49
50
 
50
51
  def set_workdir(dir)
51
- if !dir.nil?
52
+ unless dir.nil?
52
53
  @workdir = find_workdir(dir)
53
54
  if @workdir.nil?
54
55
  @workdir = dir
@@ -105,10 +106,10 @@ module GitProc
105
106
  def should_remove_master
106
107
  my_branches = branches()
107
108
  has_a_remote? and
108
- my_branches.include?(master_branch) and
109
- my_branches.current.name != master_branch and
110
- !keep_local_integration_branch? and
111
- my_branches[integration_branch].contains_all_of(master_branch)
109
+ my_branches.include?(master_branch) and
110
+ my_branches.current.name != master_branch and
111
+ !keep_local_integration_branch? and
112
+ my_branches[integration_branch].contains_all_of(master_branch)
112
113
  end
113
114
 
114
115
 
@@ -139,6 +140,7 @@ module GitProc
139
140
  private
140
141
 
141
142
 
143
+ #noinspection RubyInstanceMethodNamingConvention
142
144
  def keep_local_integration_branch_config_value
143
145
  config('gitProcess.keepLocalIntegrationBranch')
144
146
  end
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  module GitProc
14
14
 
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'optparse'
14
14
  require 'trollop'
@@ -20,6 +20,7 @@ module GitProc
20
20
 
21
21
  DEBUG = false
22
22
 
23
+
23
24
  def parse_cli(filename, argv)
24
25
  parser = Trollop::Parser.new
25
26
  parser.version "#{filename} #{GitProc::Version::STRING}"
@@ -42,8 +43,8 @@ module GitProc
42
43
 
43
44
  post_parse(opts, argv)
44
45
 
45
- if (DEBUG)
46
- puts "\n\n#{opts.map{|k,v| "#{k}:#{v}"}.join(', ')}"
46
+ if DEBUG
47
+ puts "\n\n#{opts.map { |k, v| "#{k}:#{v}" }.join(', ')}"
47
48
  puts "\nargs: #{argv.join(', ')}"
48
49
  end
49
50
 
@@ -82,16 +83,13 @@ module GitProc
82
83
  end
83
84
 
84
85
 
86
+ #noinspection RubyUnusedLocalVariable
85
87
  def extend_opts(parser)
86
88
  # extension point - does nothing by default
87
89
  end
88
90
 
89
91
 
90
- # def extend_args(argv)
91
- # # extension point - does nothing by default
92
- # end
93
-
94
-
92
+ #noinspection RubyUnusedLocalVariable
95
93
  def post_parse(opts, argv)
96
94
  # extension point - does nothing by default
97
95
  end
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  require 'git-process/git_abstract_merge_error_builder'
14
14
 
@@ -19,6 +19,7 @@ module GitProc
19
19
 
20
20
  attr_reader :error_message, :lib
21
21
 
22
+
22
23
  def initialize(rebase_error_message, lib)
23
24
  @lib = lib
24
25
  @error_message = rebase_error_message
@@ -8,7 +8,7 @@
8
8
  # distributed under the License is distributed on an "AS IS" BASIS,
9
9
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  # See the License for the specific language governing permissions and
11
- # limitations under the License.require 'shellwords'
11
+ # limitations under the License.
12
12
 
13
13
  module GitProc
14
14
 
@@ -28,6 +28,7 @@ module GitProc
28
28
  class GitStatus
29
29
  attr_reader :unmerged, :modified, :deleted, :added, :unknown
30
30
 
31
+
31
32
  def initialize(lib)
32
33
  unmerged = []
33
34
  modified = []
@@ -43,41 +44,41 @@ module GitProc
43
44
  #puts "stat #{stat} - #{file}"
44
45
  f = unquote(file)
45
46
  case stat
46
- when 'U ', ' U'
47
- unmerged << f
48
- when 'UU'
49
- unmerged << f
50
- modified << f
51
- when 'M ', ' M', 'MM'
52
- modified << f
53
- when 'MD'
54
- modified << f
55
- deleted << f
56
- when 'D ', ' D'
57
- deleted << f
58
- when 'DU', 'UD'
59
- deleted << f
60
- unmerged << f
61
- when 'A ', ' A'
62
- added << f
63
- when 'AD'
64
- added << f
65
- deleted << f
66
- when 'AA'
67
- added << f
68
- unmerged << f
69
- when '??'
70
- unknown << f
71
- when 'R '
72
- old_file, new_file = file.split(' -> ')
73
- deleted << unquote(old_file)
74
- added << unquote(new_file)
75
- when 'C '
76
- old_file, new_file = file.split(' -> ')
77
- added << unquote(old_file)
78
- added << unquote(new_file)
79
- else
80
- raise "Do not know what to do with status #{stat} - #{file}"
47
+ when 'U ', ' U'
48
+ unmerged << f
49
+ when 'UU'
50
+ unmerged << f
51
+ modified << f
52
+ when 'M ', ' M', 'MM'
53
+ modified << f
54
+ when 'MD'
55
+ modified << f
56
+ deleted << f
57
+ when 'D ', ' D'
58
+ deleted << f
59
+ when 'DU', 'UD'
60
+ deleted << f
61
+ unmerged << f
62
+ when 'A ', ' A'
63
+ added << f
64
+ when 'AD'
65
+ added << f
66
+ deleted << f
67
+ when 'AA'
68
+ added << f
69
+ unmerged << f
70
+ when '??'
71
+ unknown << f
72
+ when 'R '
73
+ old_file, new_file = file.split(' -> ')
74
+ deleted << unquote(old_file)
75
+ added << unquote(new_file)
76
+ when 'C '
77
+ old_file, new_file = file.split(' -> ')
78
+ added << unquote(old_file)
79
+ added << unquote(new_file)
80
+ else
81
+ raise "Do not know what to do with status #{stat} - #{file}"
81
82
  end
82
83
  end
83
84