update_repo 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -7
- data/lib/update_repo.rb +57 -34
- data/lib/update_repo/version.rb +1 -1
- data/update_repo.gemspec +2 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c32900e76a1fff5d6255a88a76e112d9bccc429
|
4
|
+
data.tar.gz: 2ad9941848464e5d357d51c5a40f22fd216802c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb996cd83661f0b90fa12cd4b3db7ead977303df79317a9827ce6cad19ff3d129bc284920836bd10f52043fa202f59fc1a87f8839e6350fb07134fd202fab89d
|
7
|
+
data.tar.gz: 7c0b28d67cc2134d5979f835ea048c7f90e61ae2c372e7fe2f8724ef55bc306e8728e88e6c0d6fe8c88a0ba44737fa98c82ebb8e3507f9cfea55b54f1588dbf4
|
data/README.md
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
[![Inline docs](http://inch-ci.org/github/seapagan/update_repo.svg?branch=master)](http://inch-ci.org/github/seapagan/update_repo)
|
7
7
|
[![PullReview stats](https://www.pullreview.com/github/seapagan/update_repo/badges/master.svg?)](https://www.pullreview.com/github/seapagan/update_repo/reviews/master)
|
8
8
|
|
9
|
-
A Simple Gem to keep multiple cloned Git Repositories up to date.
|
9
|
+
A Simple Gem to keep multiple locally-cloned Git Repositories up to date.
|
10
10
|
|
11
|
-
This is the conversion to a Gem of one of my standalone Ruby scripts. Still very much work in progress
|
11
|
+
This is the conversion to a Gem of one of my standalone Ruby scripts. Still very much a work in progress but the required basic functionality is there.
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
@@ -51,8 +51,6 @@ Not in any specific order :
|
|
51
51
|
- Either add an option 'variants' or similar to allow non-standard git pull commands (eg Ubuntu kernel), or update the 'exceptions' option to do same.
|
52
52
|
- Error checking and reporting for the git processes - retry for connection issues etc (config setting).
|
53
53
|
- Add extra (optional) stats / info at end-of-job :
|
54
|
-
* number of repos updated
|
55
|
-
* number of repos skipped
|
56
54
|
* list of changed repos
|
57
55
|
* errors or connection problems
|
58
56
|
* _more..._
|
@@ -62,6 +60,7 @@ Not in any specific order :
|
|
62
60
|
- Add new repo from the command line that will be cloned to the default repo directory and then updated as usual. Extra flag added for "add only, clone later" for offline use.
|
63
61
|
- Add flag for 'default' repo directory (or another specific directory - if it does not already exist it will be created and added to the standard list) which will be used for new additions.
|
64
62
|
- Option to save log file for each run.
|
63
|
+
- Option to disable the coloured output
|
65
64
|
- Add option to only display a (text) tree of the discovered git repositories, not updating them; Similar option to just dump a list of the remote git locations.
|
66
65
|
- Add ability to export a text dump of each repo location and then re-import this on a different machine or after reinstall
|
67
66
|
- Document configuration file format and options.
|
@@ -85,9 +84,8 @@ Run `rake` to run the RSpec tests, which also runs `RuboCop`, `Reek` and `inch -
|
|
85
84
|
4. Push to the branch (`git push origin my-new-feature`)
|
86
85
|
5. Create new Pull Request
|
87
86
|
|
88
|
-
|
89
|
-
Running `rake` will automatically test all 3 of those along with the RSpec tests. Note that Failures of Rubocop will cause the CI (Travis) to fail, however 'Reek' failures will not
|
90
|
-
This is still currently a messy conversion to Gem from a standalone script, so the RSpec tests are non-existent and it will fail all [RuboCop][rubocop], [Reek][reek] and [Inch-CI][inch]. This will be quickly fixed though. Once that is done this message will be removed and the above comment reinstated.
|
87
|
+
Please note - This Gem currently aims to pass 100% on [RuboCop][rubocop], [Reek][reek] and [Inch-CI][inch] (on pedantic mode), so all pull requests should do likewise. Ask for guidance if needed.
|
88
|
+
Running `rake` will automatically test all 3 of those along with the RSpec tests. Note that Failures of Rubocop will cause the CI (Travis) to fail, however 'Reek' failures will not.
|
91
89
|
|
92
90
|
[rubocop]: https://github.com/bbatsov/rubocop
|
93
91
|
[reek]: https://github.com/troessner/reek
|
data/lib/update_repo.rb
CHANGED
@@ -2,6 +2,7 @@ require 'update_repo/version'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'colorize'
|
4
4
|
require 'confoog'
|
5
|
+
require 'trollop'
|
5
6
|
|
6
7
|
# Overall module with classes performing the functionality
|
7
8
|
# Contains Class UpdateRepo::WalkRepo
|
@@ -12,25 +13,24 @@ module UpdateRepo
|
|
12
13
|
# An encapsulated class to walk the repo directories and update all Git
|
13
14
|
# repositories found therein.
|
14
15
|
class WalkRepo
|
15
|
-
# Read-only attribute holding the total number of traversed repositories
|
16
|
-
# @attr_reader :counter [fixnum] total number of traversed repositories
|
17
|
-
attr_reader :counter
|
18
|
-
|
19
16
|
# Class constructor. No parameters required.
|
20
17
|
# @return [void]
|
21
18
|
def initialize
|
22
19
|
# @counter - this will be incremented with each repo updated.
|
23
20
|
@counter = 0
|
24
21
|
# @skip_counter - will count all repos deliberately skipped
|
25
|
-
@
|
22
|
+
@skip_count = 0
|
26
23
|
# @ start_time - will be used to get elapsed time
|
27
24
|
@start_time = 0
|
28
25
|
# @config - Class. Reads the configuration from a file in YAML format and
|
29
26
|
# allows easy access to the configuration data
|
30
27
|
@config = Confoog::Settings.new(filename: '.updatereporc',
|
31
28
|
prefix: 'update_repo',
|
32
|
-
autoload: true
|
29
|
+
autoload: true,
|
30
|
+
autosave: false)
|
33
31
|
exit 1 unless @config.status[:errors] == Status::INFO_FILE_LOADED
|
32
|
+
# store the command line variables in a configuration variable
|
33
|
+
@config['cmd'] = set_options
|
34
34
|
end
|
35
35
|
|
36
36
|
# This function will perform the required actions to traverse the Repo.
|
@@ -38,10 +38,9 @@ module UpdateRepo
|
|
38
38
|
# walk_repo = UpdateRepo::WalkRepo.new
|
39
39
|
# walk_repo.start
|
40
40
|
def start
|
41
|
-
|
42
|
-
show_header(exceptions)
|
41
|
+
show_header(@config['exceptions'])
|
43
42
|
@config['location'].each do |loc|
|
44
|
-
recurse_dir(loc
|
43
|
+
recurse_dir(loc)
|
45
44
|
end
|
46
45
|
# print out an informative footer...
|
47
46
|
footer
|
@@ -49,22 +48,48 @@ module UpdateRepo
|
|
49
48
|
|
50
49
|
private
|
51
50
|
|
52
|
-
#
|
53
|
-
|
51
|
+
# rubocop:disable Metrics//MethodLength
|
52
|
+
def set_options
|
53
|
+
Trollop.options do
|
54
|
+
version "\nupdate_repo version #{VERSION} (C)2016 G. Ramsay\n"
|
55
|
+
banner <<-EOS
|
56
|
+
Keep multiple local Git-Cloned Repositories up to date with one command.
|
57
|
+
|
58
|
+
Usage:
|
59
|
+
update_repo [options]
|
60
|
+
|
61
|
+
Options are not required. If none are specified then the program will read from
|
62
|
+
the standard configuration file (~/.updatereporc) and automatically update the
|
63
|
+
specified Repositories.
|
64
|
+
|
65
|
+
Options:
|
66
|
+
EOS
|
67
|
+
# opt :color, 'Use colored output', default: true
|
68
|
+
# opt :quiet, 'Only minimal output to the terminal', default: false
|
69
|
+
# opt :silent, 'Completely silent, no output to terminal at all.',
|
70
|
+
# default: false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
# rubocop:enable Metrics//MethodLength
|
74
|
+
|
75
|
+
# take each directory contained in the Repo directory, if it is detected as
|
76
|
+
# a Git repository then update it (or as directed by command line)
|
54
77
|
# @param dirname [string] Contains the directory to search for Git repos.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
next unless File.directory?(dirpath) && notdot?(dir)
|
60
|
-
if gitdir?(dirpath)
|
61
|
-
!exceptions.include?(dir) ? update_repo(dirpath) : skip_dir(dirpath)
|
62
|
-
else
|
63
|
-
recurse_dir(dirpath, exceptions)
|
78
|
+
def recurse_dir(dirname)
|
79
|
+
Dir.chdir(dirname) do
|
80
|
+
Dir['**/'].each do |dir|
|
81
|
+
notexception?(dir) ? update_repo(dir) : skip_repo(dir) if gitdir?(dir)
|
64
82
|
end
|
65
83
|
end
|
66
84
|
end
|
67
85
|
|
86
|
+
# tests to see if the given directory is an exception and should be skipped
|
87
|
+
# @param dir [string] Directory to be checked
|
88
|
+
# @return [boolean] True if this is NOT an exception, False otherwise
|
89
|
+
def notexception?(dir)
|
90
|
+
!@config['exceptions'].include?(File.basename(dir))
|
91
|
+
end
|
92
|
+
|
68
93
|
# Display a simple header to the console
|
69
94
|
# @example
|
70
95
|
# show_header(exceptions)
|
@@ -88,9 +113,10 @@ module UpdateRepo
|
|
88
113
|
# @return [void]
|
89
114
|
def footer
|
90
115
|
duration = Time.now - @start_time
|
91
|
-
print "\nUpdates completed : ", @counter.to_s.
|
92
|
-
|
93
|
-
print '
|
116
|
+
print "\nUpdates completed : ", @counter.to_s.green,
|
117
|
+
' repositories processed'
|
118
|
+
print ' / ', @skip_count.to_s.yellow, ' skipped' unless @skip_count == 0
|
119
|
+
print ' in ', show_time(duration), "\n\n"
|
94
120
|
end
|
95
121
|
|
96
122
|
def list_locations
|
@@ -100,18 +126,18 @@ module UpdateRepo
|
|
100
126
|
end
|
101
127
|
end
|
102
128
|
|
103
|
-
def
|
104
|
-
Dir.chdir(dirpath) do
|
129
|
+
def skip_repo(dirpath)
|
130
|
+
Dir.chdir(dirpath.chomp!('/')) do
|
105
131
|
repo_url = `git config remote.origin.url`.chomp
|
106
|
-
print
|
107
|
-
@
|
132
|
+
print '* Skipping ', Dir.pwd.yellow, " (#{repo_url})\n"
|
133
|
+
@skip_count += 1
|
108
134
|
end
|
109
135
|
end
|
110
136
|
|
111
137
|
def update_repo(dirname)
|
112
|
-
Dir.chdir(dirname) do
|
138
|
+
Dir.chdir(dirname.chomp!('/')) do
|
113
139
|
repo_url = `git config remote.origin.url`.chomp
|
114
|
-
print '*
|
140
|
+
print '* Checking ', Dir.pwd.green, " (#{repo_url})\n", ' -> '
|
115
141
|
system 'git pull'
|
116
142
|
@counter += 1
|
117
143
|
end
|
@@ -122,12 +148,9 @@ module UpdateRepo
|
|
122
148
|
File.exist?(gitpath) && File.directory?(gitpath)
|
123
149
|
end
|
124
150
|
|
125
|
-
def notdot?(dir)
|
126
|
-
(dir != '.' && dir != '..')
|
127
|
-
end
|
128
|
-
|
129
151
|
def show_time(duration)
|
130
|
-
|
152
|
+
time_taken = Time.at(duration).utc
|
153
|
+
time_taken.strftime('%-H hours, %-M Minutes and %-S seconds.').cyan
|
131
154
|
end
|
132
155
|
end
|
133
156
|
end
|
data/lib/update_repo/version.rb
CHANGED
data/update_repo.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.authors = ['Grant Ramsay']
|
12
12
|
spec.email = ['seapagan@gmail.com']
|
13
13
|
|
14
|
-
spec.summary = 'A Simple Gem to keep multiple cloned Git Repositories up to date'
|
14
|
+
spec.summary = 'A Simple Gem to keep multiple locally-cloned Git Repositories up to date'
|
15
15
|
spec.homepage = 'http://opensource.seapagan.net'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_dependency 'colorize'
|
37
37
|
spec.add_dependency 'confoog'
|
38
|
+
spec.add_dependency 'trollop'
|
38
39
|
|
39
40
|
# Depends on Ruby version if we can use 'Reek'
|
40
41
|
spec.add_development_dependency 'reek', '~> 3.3' if RUBY_VERSION > '2.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: update_repo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Ramsay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: trollop
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :runtime
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: reek
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,6 +281,6 @@ rubyforge_project:
|
|
267
281
|
rubygems_version: 2.6.1
|
268
282
|
signing_key:
|
269
283
|
specification_version: 4
|
270
|
-
summary: A Simple Gem to keep multiple cloned Git Repositories up to date
|
284
|
+
summary: A Simple Gem to keep multiple locally-cloned Git Repositories up to date
|
271
285
|
test_files: []
|
272
286
|
has_rdoc:
|