update_repo 0.9.10 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3387caba12fdfb2f594ebb155b0fef824878b18233d158951d8cd34518eeead8
4
- data.tar.gz: 534954a429c276739f657bd33625d21f0b1df3aa30bf1406f3abb490ea4cf0b1
3
+ metadata.gz: ab7dd33a2bc0ca3e8081a27838556804ef0c6902f2ecd551af20f3e8408d1af7
4
+ data.tar.gz: 27c6fe165be5697b08fbf270bd212d43e1311828b97a9d044bd4e6e8a2f86aee
5
5
  SHA512:
6
- metadata.gz: 0c3718e9e1ee0c204b2642ead7952700c248ce48fcc2894821b7f6c2944e55858d9fabc292a99054cf29b9c5fb8c45c18cf3e33f6056fb8cf56ad180d150a614
7
- data.tar.gz: 67dcce3bed7b9a547d4349cdf86194fbea3f513b448f434cdf020c20ec070567b2aad375c616ae705ba66c453303c03c67567ba4259fb3a4867119b96361c25c
6
+ metadata.gz: 319b49c40bbc2bbb44f450a69ea1b42b2061024c31b02b0574e596453be0b388db9cb316d65bf62dc5cb583ae238d6245d99ed44e40d833d27ed389cb21abc2c
7
+ data.tar.gz: b30306f7fbfa425c1f8db2258754fa25bb574f16965cc7d810ec925d99c9f9761e29b1b5a0a93bef89c5c253f13c756262a52edf66c7c9a0e7599c29fcf43417
data/.reek.yml ADDED
@@ -0,0 +1,21 @@
1
+ ---
2
+ detectors:
3
+ TooManyStatements:
4
+ max_statements: 8
5
+ exclude:
6
+ - set_options
7
+
8
+ UtilityFunction:
9
+ public_methods_only: true
10
+
11
+ RepeatedConditional:
12
+ max_ifs: 3
13
+
14
+ DuplicateMethodCall:
15
+ max_calls: 3
16
+
17
+ NestedIterators:
18
+ max_allowed_nesting: 2
19
+
20
+ TooManyInstanceVariables:
21
+ max_instance_variables: 5
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ require: rubocop-performance
2
+
1
3
  AllCops:
2
4
  DisplayCopNames: true
3
5
  DisplayStyleGuide: true
@@ -6,6 +8,7 @@ AllCops:
6
8
  - 'web/node_modules/**/*'
7
9
  - 'Vagrantfile'
8
10
  - 'update_repo.gemspec'
11
+ - 'bin/**/*'
9
12
 
10
13
  Style/SymbolArray:
11
14
  Enabled: false
@@ -13,4 +16,4 @@ Style/SymbolArray:
13
16
  Metrics/BlockLength:
14
17
  Enabled: true
15
18
  Exclude:
16
- - spec/**/*
19
+ - spec/**/*
data/.travis.yml CHANGED
@@ -2,8 +2,9 @@ language: ruby
2
2
 
3
3
  rvm:
4
4
  - 2.3.8
5
- - 2.4.5
6
- - 2.5.3
5
+ - 2.4.6
6
+ - 2.5.5
7
+ - 2.6.3
7
8
 
8
9
  before_install:
9
10
  - gem update --system
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in update_repo.gemspec
data/README.md CHANGED
@@ -94,6 +94,11 @@ brief: true
94
94
  quiet: true
95
95
  ```
96
96
 
97
+ `save_errors:` - Save any Git error messages from the last run for future display, defaults to FALSE (optional)
98
+ ```yaml
99
+ save_errors: true
100
+ ```
101
+
97
102
  #### Command line switches
98
103
  Options are not required. If none are specified then the program will read from the standard configuration file (~/.updaterepo) and automatically update the specified Repositories. Command line options will take preference over those specified in the configuration file. Again, see the [Website][website] for complete details and usage.
99
104
 
@@ -116,6 +121,8 @@ Options:
116
121
  -E, --verbose-errors List all the error output from a failing command in the summary, not just the first line
117
122
  -b, --brief Do not print the header, footer or summary
118
123
  -q, --quiet Run completely silent, with no output to the terminal (except fatal errors)
124
+ -s, --save-errors Save any Git error messages from the last run for future display
125
+ -S, --show-errors Show any Git error messages from the last run of the script
119
126
  -v, --version Print version and exit
120
127
  -h, --help Show this message
121
128
  ```
@@ -136,6 +143,8 @@ Add functionality, not in any specific order :
136
143
  - Add option to use alternative git command if required, either globally or on a case-by-case basis (see also comments on 'variants' above). Currently the script just uses a blanket `git pull` command on all repositories.
137
144
  - Add option to specify a completely different directory for the log file other than the 2 current options of home dir and local dir
138
145
  - Document configuration file format and options. `[IN PROGRESS]`
146
+ - Add option to display the active config options, including those on command line and config file.
147
+ - Add option to create the config file with options from existing config and command line
139
148
 
140
149
  Internal Changes and refactoring :
141
150
  - Add testing!
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'inch/rake'
@@ -9,6 +11,7 @@ if RUBY_VERSION >= '2.0'
9
11
  require 'rubocop/rake_task'
10
12
  RuboCop::RakeTask.new do |task|
11
13
  # task.options << 'lib' << 'exe'
14
+ task.requires << 'rubocop-performance'
12
15
  task.fail_on_error = false
13
16
  end
14
17
  else
data/bin/update_repo CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # This file was generated by Bundler.
4
6
  #
@@ -6,11 +8,22 @@
6
8
  # this file is here to facilitate running it.
7
9
  #
8
10
 
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
12
25
 
13
- require 'rubygems'
14
- require 'bundler/setup'
26
+ require "rubygems"
27
+ require "bundler/setup"
15
28
 
16
- load Gem.bin_path('update_repo', 'update_repo')
29
+ load Gem.bin_path("update_repo", "update_repo")
data/exe/update_repo CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require 'update_repo'
3
5
 
4
6
  # Catch ctrl-c and abort gracefully without Ruby back trace...
data/lib/update_repo.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'update_repo/version'
2
4
  require 'update_repo/helpers'
3
5
  require 'update_repo/cmd_config'
@@ -42,11 +44,15 @@ module UpdateRepo
42
44
  checkgit
43
45
  # print out our header unless we are dumping / importing ...
44
46
  @cons.show_header unless dumping?
45
- config['location'].each do |loc|
46
- @cmd[:dump_tree] ? dump_tree(File.join(loc)) : recurse_dir(loc)
47
+ if !@cmd[:show_errors]
48
+ config['location'].each do |loc|
49
+ @cmd[:dump_tree] ? dump_tree(File.join(loc)) : recurse_dir(loc)
50
+ end
51
+ # print out an informative footer unless dump / import ...
52
+ @cons.show_footer unless dumping?
53
+ else
54
+ @cons.show_last_errors
47
55
  end
48
- # print out an informative footer unless dump / import ...
49
- @cons.show_footer unless dumping?
50
56
  end
51
57
 
52
58
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'update_repo/version'
2
4
  require 'update_repo/helpers'
3
5
  require 'confoog'
@@ -13,9 +15,9 @@ module UpdateRepo
13
15
  include Helpers
14
16
 
15
17
  # This constant holds the path to the config file, default to home dir.
16
- CONFIG_PATH = '~/'.freeze
18
+ CONFIG_PATH = '~/'
17
19
  # This constant holds the filename of the config file.
18
- CONFIG_FILE = '.updaterepo'.freeze
20
+ CONFIG_FILE = '.updaterepo'
19
21
 
20
22
  def initialize
21
23
  # read the options from Trollop and store in temp variable.
@@ -100,6 +102,7 @@ module UpdateRepo
100
102
  # @return [void]
101
103
  # rubocop:disable Metrics/MethodLength
102
104
  # rubocop:disable Metrics/LineLength
105
+ # rubocop:disable Metrics/AbcSize
103
106
  def set_options
104
107
  Optimist.options do
105
108
  version "update_repo version #{VERSION} (C)2019 G. Ramsay\n"
@@ -130,9 +133,12 @@ module UpdateRepo
130
133
  opt :verbose_errors, 'List all the error output from a failing command in the summary, not just the first line', default: false, short: 'E'
131
134
  opt :brief, 'Do not print the header, footer or summary', default: false, short: 'b'
132
135
  opt :quiet, 'Run completely silent, with no output to the terminal (except fatal errors)', default: false
136
+ opt :save_errors, 'Save any Git error messages from the last run for future display', default: false, short: 's'
137
+ opt :show_errors, 'Show any Git error messages from the last run of the script', default: false, short: 'S'
133
138
  end
134
139
  end
135
140
  # rubocop:enable Metrics/MethodLength
136
- # rubocop:enable Metrics/LineLength
141
+ # rubocop:enable Metrics/LineLength
142
+ # rubocop:enable Metrics/AbcSize
137
143
  end
138
144
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'update_repo/version'
2
4
  require 'update_repo/helpers'
3
5
 
@@ -70,6 +72,7 @@ module UpdateRepo
70
72
  end
71
73
  print_log ' |'
72
74
  list_failures unless @metrics[:failed_list].empty?
75
+ @metrics.save_errors(@cmd.getconfig) if @cmd[:save_errors]
73
76
  end
74
77
 
75
78
  # List any repositories that failed their update, and the error.
@@ -78,13 +81,15 @@ module UpdateRepo
78
81
  def list_failures
79
82
  # ensure we don't have duplicate errors from the same repo
80
83
  remove_dups
81
- print_log "\n\n!! Note : The following #{@metrics[:failed_list].count}",
84
+ puts "\n" unless @cmd[:show_errors]
85
+ print_log "\n!! Note : The following #{@metrics[:failed_list].count}",
82
86
  ' repositories ', 'FAILED'.red.underline, ' during this run :'
83
87
  # print out any and all errors into a nice list
84
88
  @metrics[:failed_list].each do |failed|
85
89
  print_log "\n [", 'x'.red, "] #{failed[:loc]}"
86
90
  print_log "\n -> ", failed[:line].chomp.red
87
91
  end
92
+ print_log " \n\n"
88
93
  end
89
94
 
90
95
  # removes any duplications in the list of failed repos.
@@ -123,5 +128,17 @@ module UpdateRepo
123
128
 
124
129
  print_log "\nLogging to file:".underline, " #{@log.logfile}\n".cyan
125
130
  end
131
+
132
+ # just print out errors from the last run, if any
133
+ # @return [void]
134
+ def show_last_errors
135
+ @metrics.load_errors(@cmd.getconfig)
136
+ if !@metrics[:failed_list].empty?
137
+ puts 'Showing ' + 'ERRORS'.red.underline + ' from last full run :'
138
+ list_failures
139
+ else
140
+ puts 'There are' + ' No Errors'.green + " from last full run.\n\n"
141
+ end
142
+ end
126
143
  end
127
144
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'update_repo/version'
2
4
  require 'update_repo/helpers'
3
5
  require 'open3'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Module 'Helpers' containing assorted helper functions required elsewhere
2
4
  module Helpers
3
5
  # will remove the FIRST 'how_many' root levels from a directory path 'dir'..
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'update_repo/version'
2
4
  require 'update_repo/helpers'
3
5
 
@@ -99,7 +101,7 @@ module UpdateRepo
99
101
  # @param [none]
100
102
  # @return [void]
101
103
  def close
102
- @logfile.close if @logfile
104
+ @logfile&.close # if @logfile
103
105
  end
104
106
  end
105
107
  end
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'update_repo/version'
2
4
  require 'update_repo/helpers'
5
+ require 'yaml'
3
6
 
4
7
  module UpdateRepo
5
8
  # Class : Metrics.
@@ -30,5 +33,31 @@ module UpdateRepo
30
33
  def []=(key, value)
31
34
  @metrics[key] = value
32
35
  end
36
+
37
+ # This will save any (git) errors encountered to a file,
38
+ # so they can be reprinted again at a later date.
39
+ # If no errors, then delete any previously existing error file.
40
+ # @param config [instance] of Config class
41
+ # @return [void]
42
+ def save_errors(config)
43
+ # get the location of the config file, we'll use the same dir
44
+ # and base name
45
+ path = config.config_path + '.errors'
46
+ if @metrics[:failed_list].empty?
47
+ # delete any existing file if we have no errors
48
+ File.delete(path) if File.exist?(path)
49
+ else
50
+ # otherwise save the errors to file
51
+ File.open(path, 'w') { |file| file.write @metrics[:failed_list].to_yaml }
52
+ end
53
+ end
54
+
55
+ # loads an error file (if exists) into the @metrics[:failed_list].
56
+ # @param config [instance] of Config class
57
+ # @return [void]
58
+ def load_errors(config)
59
+ path = config.config_path + '.errors'
60
+ @metrics[:failed_list] = YAML.load_file(path) if File.exist?(path)
61
+ end
33
62
  end
34
63
  end
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module UpdateRepo
2
4
  # constant, current version of this Gem
3
- VERSION = '0.9.10'.freeze
5
+ VERSION = '0.10.1'
4
6
  end
data/update_repo.gemspec CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 1.13'
26
- spec.add_development_dependency 'rake', '~> 11.3'
25
+ spec.add_development_dependency 'bundler'
26
+ spec.add_development_dependency 'rake', '~> 12.3'
27
27
  spec.add_development_dependency 'rspec', '~> 3.0'
28
28
  spec.add_development_dependency 'pry'
29
29
  spec.add_development_dependency 'fakefs'
@@ -38,8 +38,9 @@ Gem::Specification.new do |spec|
38
38
  # Below this we fix to the last working versions to keep Ruby 1.9.3 compat or
39
39
  # we ignore completely - Reek and Rubocop working in the latest versions is
40
40
  # enough since the code base is common.
41
- spec.add_development_dependency 'reek', '~> 4.5' if RUBY_VERSION >= '2.1'
41
+ spec.add_development_dependency 'reek' if RUBY_VERSION >= '2.1'
42
42
  spec.add_development_dependency 'rubocop' if RUBY_VERSION >= '2.0'
43
+ spec.add_development_dependency 'rubocop-performance' if RUBY_VERSION >= '2.0'
43
44
 
44
45
  if RUBY_VERSION < '2.0'
45
46
  spec.add_development_dependency 'json', '= 1.8.3'
@@ -51,4 +52,6 @@ Gem::Specification.new do |spec|
51
52
  spec.add_dependency 'confoog'
52
53
  spec.add_dependency 'optimist'
53
54
  spec.add_dependency 'versionomy'
55
+ # fix issue in Ruby < 2.5.5
56
+ spec.add_dependency "bigdecimal", "1.3.5" if RUBY_VERSION < '2.5.5'
54
57
  end
data/web/index.html CHANGED
@@ -187,6 +187,15 @@
187
187
  </pre>
188
188
  </div><!-- col -->
189
189
 
190
+ <div class="col-lg-12 col-md-12">
191
+ <p><span class="yaml-tag">save_errors:</span> - Enable or disable the option to save any Git errors from a previous run of the script, defaults to FALSE (optional). If this is specified then there will be nothing printed to the terminal except for fatal errors. Equivalent to <span class="cmdline">--save-errors</span> on the command line. Once saved, errors can be displayed using the <span class="cmdline">--show-errors</span> command line option.</p>
192
+ <pre>
193
+ <code class="language-yaml">
194
+ save-errors: true
195
+ </code>
196
+ </pre>
197
+ </div><!-- col -->
198
+
190
199
  <div class="col-lg-12 col-md-12">
191
200
  <p>Putting these together, below is an example <span class="filename">.updaterepo</span> file :</p>
192
201
  <pre>
@@ -227,6 +236,8 @@
227
236
  -E, --verbose-errors List all the error output from a failing command in the summary, not just the first line
228
237
  -b, --brief Do not print the header, footer or summary
229
238
  -q, --quiet Run completely silent, with no output to the terminal (except fatal errors)
239
+ -s, --save-errors Save any Git error messages from the last run for future display
240
+ -S, --show-errors Show any Git error messages from the last run of the script
230
241
  -v, --version Print version and exit
231
242
  -h, --help Show this message
232
243
  </code>
data/web/webdata.json CHANGED
@@ -99,6 +99,24 @@
99
99
  "negative" : "",
100
100
  "default" : "false"
101
101
  },
102
+ {
103
+ "title" : "Save Errors",
104
+ "text" : "Save any Git error messages from the last run for future display. These can be displayed using the Show Errors command below, which will display previous errors then exit without running another pass.",
105
+ "equivalent" : "save_errors",
106
+ "long-form" : "--save-errors",
107
+ "short-form" : "-s",
108
+ "negative" : "",
109
+ "default" : "false"
110
+ },
111
+ {
112
+ "title" : "Show Errors",
113
+ "text" : "Prints any errors detected in the previous run then exits. This needs the 'Save Errors' option above to be enabled.",
114
+ "equivalent" : "",
115
+ "long-form" : "--show-errors",
116
+ "short-form" : "-S",
117
+ "negative" : "",
118
+ "default" : "false"
119
+ },
102
120
  {
103
121
  "title" : "Version",
104
122
  "text" : "Displays the current version number then terminates. All other options will be ignored.",
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: update_repo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Ramsay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-02 00:00:00.000000000 Z
11
+ date: 2019-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '11.3'
33
+ version: '12.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '11.3'
40
+ version: '12.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -168,16 +168,16 @@ dependencies:
168
168
  name: reek
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - "~>"
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '4.5'
173
+ version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - "~>"
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '4.5'
180
+ version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rubocop
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop-performance
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: colorize
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -262,7 +276,7 @@ files:
262
276
  - ".eslintrc.yml"
263
277
  - ".gitignore"
264
278
  - ".pullreview.yml"
265
- - ".reek"
279
+ - ".reek.yml"
266
280
  - ".rspec"
267
281
  - ".rubocop.yml"
268
282
  - ".travis.yml"
@@ -341,8 +355,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
355
  - !ruby/object:Gem::Version
342
356
  version: '0'
343
357
  requirements: []
344
- rubyforge_project:
345
- rubygems_version: 2.7.8
358
+ rubygems_version: 3.0.6
346
359
  signing_key:
347
360
  specification_version: 4
348
361
  summary: A Simple Gem to keep multiple locally-cloned Git Repositories up to date
data/.reek DELETED
@@ -1,20 +0,0 @@
1
- ---
2
- TooManyStatements:
3
- max_statements: 8
4
- exclude:
5
- - set_options
6
-
7
- UtilityFunction:
8
- public_methods_only: true
9
-
10
- RepeatedConditional:
11
- max_ifs: 3
12
-
13
- DuplicateMethodCall:
14
- max_calls: 3
15
-
16
- NestedIterators:
17
- max_allowed_nesting: 2
18
-
19
- TooManyInstanceVariables:
20
- max_instance_variables: 5