herdsman 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/README.md +6 -0
- data/herdsman.gemspec +1 -0
- data/lib/herdsman/cli.rb +9 -1
- data/lib/herdsman/config.rb +36 -6
- data/lib/herdsman/herd.rb +2 -2
- data/lib/herdsman/herd_member_config.rb +23 -13
- data/lib/herdsman/version.rb +1 -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: 8828c60f07d2f88386232fa85465bc2f1dadeaed
|
|
4
|
+
data.tar.gz: 408b35de658e9e9d8077f05f6af66873cdf74e3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6bd0851552c5d30dc23ca1a4f34c3c06f149b0ae28b799ace9a861b28fa4dd1b1d41b44a89717bc67cda51a69510108dac4e87941af9144eda6a7daa7ea42d37
|
|
7
|
+
data.tar.gz: b529b2e72ac88e0f1993b490d03f2d04c4feb11206bdd51d4d8e6734257ed8d3e9027b4cfba9add9c3d29c3d47687c138a9b49dff23be3d9f0bb949ed9554661
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [v0.3.0] - 2017-04-17
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* `--fetch-cache=SECONDS`/`-c` option.
|
|
12
|
+
* `--revision`/`-r` option.
|
|
13
|
+
* `defaults:` config with support for `revision:` and `fetch_cache:`.
|
|
14
|
+
* Glob support for `path:`.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
* Missing `thor` dependency in gemspec.
|
|
19
|
+
|
|
7
20
|
## [v0.2.0] - 2017-03-01
|
|
8
21
|
|
|
9
22
|
### Added
|
|
@@ -21,5 +34,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
21
34
|
* `version` command.
|
|
22
35
|
* `--quiet`/`-q` option.
|
|
23
36
|
|
|
24
|
-
[Unreleased]: https://github.com/tommarshall/herdsman/compare/v0.
|
|
37
|
+
[Unreleased]: https://github.com/tommarshall/herdsman/compare/v0.3.0...HEAD
|
|
38
|
+
[v0.3.0]: https://github.com/tommarshall/herdsman/compare/v0.2.0...v0.3.0
|
|
25
39
|
[v0.2.0]: https://github.com/tommarshall/herdsman/compare/v0.1.0...v0.2.0
|
data/README.md
CHANGED
|
@@ -22,6 +22,8 @@ Commands:
|
|
|
22
22
|
herdsman version # Show the herdsman version
|
|
23
23
|
|
|
24
24
|
Options:
|
|
25
|
+
c, [--fetch-cache=SECONDS]
|
|
26
|
+
r, [--revision=REVISION]
|
|
25
27
|
q, [--quiet], [--no-quiet]
|
|
26
28
|
```
|
|
27
29
|
|
|
@@ -53,6 +55,10 @@ Configure the herd of repositories to manage with a `herdsman.yml` file in the c
|
|
|
53
55
|
Example:
|
|
54
56
|
|
|
55
57
|
```yml
|
|
58
|
+
defaults:
|
|
59
|
+
revision: not-master
|
|
60
|
+
fetch_cache: 300
|
|
61
|
+
|
|
56
62
|
repos:
|
|
57
63
|
- /path/to/foo-repo
|
|
58
64
|
- ../../path/to/bar-repo
|
data/herdsman.gemspec
CHANGED
|
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|
|
3
3
|
require 'herdsman/version'
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
+
spec.add_dependency 'thor', '~> 0.19.0'
|
|
6
7
|
spec.authors = ['Tom Marshall']
|
|
7
8
|
spec.description =
|
|
8
9
|
'Herdsman is a CLI utility for working with multiple Git repositories'
|
data/lib/herdsman/cli.rb
CHANGED
|
@@ -4,6 +4,8 @@ module Herdsman
|
|
|
4
4
|
class CLI < Thor
|
|
5
5
|
require 'herdsman'
|
|
6
6
|
|
|
7
|
+
class_option :fetch_cache, type: :numeric, banner: 'SECONDS', aliases: :c
|
|
8
|
+
class_option :revision, type: :string, aliases: :r
|
|
7
9
|
class_option :quiet, type: :boolean, aliases: :q
|
|
8
10
|
|
|
9
11
|
default_task :status
|
|
@@ -24,12 +26,18 @@ module Herdsman
|
|
|
24
26
|
private
|
|
25
27
|
|
|
26
28
|
def config
|
|
27
|
-
|
|
29
|
+
path = File.expand_path('herdsman.yml', Dir.pwd)
|
|
30
|
+
Herdsman::Config.new(path, config_overrides)
|
|
28
31
|
rescue
|
|
29
32
|
$stderr.puts "ERROR: #{$!.message}"
|
|
30
33
|
exit 1
|
|
31
34
|
end
|
|
32
35
|
|
|
36
|
+
def config_overrides
|
|
37
|
+
overridable_options = %w(fetch_cache revision)
|
|
38
|
+
options.select { |key, _| overridable_options.include? key }
|
|
39
|
+
end
|
|
40
|
+
|
|
33
41
|
def env
|
|
34
42
|
Herdsman::Environment.new
|
|
35
43
|
end
|
data/lib/herdsman/config.rb
CHANGED
|
@@ -3,21 +3,24 @@ require 'herdsman/herd_member_config'
|
|
|
3
3
|
|
|
4
4
|
module Herdsman
|
|
5
5
|
class Config
|
|
6
|
-
def initialize(path)
|
|
7
|
-
@config
|
|
6
|
+
def initialize(path, overrides = {})
|
|
7
|
+
@config = read_config!(path)
|
|
8
|
+
@overrides = overrides
|
|
8
9
|
validate!
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def repos
|
|
12
|
-
config_repos = config['repos'] || config['repositories'] || []
|
|
13
13
|
config_repos.map do |herd_member_config|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
args = herd_member_args(herd_member_config)
|
|
15
|
+
herd_member_paths(herd_member_config).map do |path|
|
|
16
|
+
HerdMemberConfig.new(path, args, overrides, config_defaults)
|
|
17
|
+
end
|
|
18
|
+
end.flatten
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
private
|
|
19
22
|
|
|
20
|
-
attr_reader :config
|
|
23
|
+
attr_reader :config, :overrides
|
|
21
24
|
|
|
22
25
|
def read_config!(path)
|
|
23
26
|
YAML.load_file(path)
|
|
@@ -25,6 +28,33 @@ module Herdsman
|
|
|
25
28
|
raise 'No config found'
|
|
26
29
|
end
|
|
27
30
|
|
|
31
|
+
def config_defaults
|
|
32
|
+
config.fetch('defaults')
|
|
33
|
+
rescue
|
|
34
|
+
{}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def config_repos
|
|
38
|
+
config['repos'] || config['repositories'] || []
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def herd_member_paths(herd_member_config)
|
|
42
|
+
config_path = herd_member_path(herd_member_config)
|
|
43
|
+
Dir.glob(config_path).select { |fn| File.directory?(fn) }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def herd_member_path(herd_member_config)
|
|
47
|
+
herd_member_config.fetch('path')
|
|
48
|
+
rescue
|
|
49
|
+
herd_member_config
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def herd_member_args(herd_member_config)
|
|
53
|
+
herd_member_config.select { |key, _| key != 'path' }
|
|
54
|
+
rescue
|
|
55
|
+
{}
|
|
56
|
+
end
|
|
57
|
+
|
|
28
58
|
def validate!
|
|
29
59
|
raise 'Invalid config' unless config.is_a?(Hash) && repos.is_a?(Array)
|
|
30
60
|
raise 'No repos defined' if repos.empty?
|
data/lib/herdsman/herd.rb
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
module Herdsman
|
|
2
2
|
class HerdMemberConfig
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
attr_reader :path
|
|
4
|
+
def initialize(path, args = {}, overrides = {}, defaults = {})
|
|
5
|
+
@path = path
|
|
6
|
+
@args = args
|
|
7
|
+
@overrides = overrides
|
|
8
|
+
@defaults = defaults
|
|
5
9
|
validate!
|
|
6
10
|
end
|
|
7
11
|
|
|
8
|
-
def path
|
|
9
|
-
args.fetch('path')
|
|
10
|
-
rescue
|
|
11
|
-
args
|
|
12
|
-
end
|
|
13
|
-
|
|
14
12
|
def name
|
|
15
13
|
args.fetch('name')
|
|
16
14
|
rescue
|
|
@@ -18,31 +16,43 @@ module Herdsman
|
|
|
18
16
|
end
|
|
19
17
|
|
|
20
18
|
def revision
|
|
21
|
-
|
|
19
|
+
overridable_arg('revision')
|
|
22
20
|
rescue
|
|
23
21
|
default_revision
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
def fetch_cache
|
|
27
|
-
|
|
25
|
+
overridable_arg('fetch_cache').to_i
|
|
28
26
|
rescue
|
|
29
27
|
default_fetch_cache
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
private
|
|
33
31
|
|
|
34
|
-
attr_reader :args
|
|
32
|
+
attr_reader :args, :overrides, :defaults
|
|
35
33
|
|
|
36
34
|
def default_name
|
|
37
35
|
File.basename(path)
|
|
38
36
|
end
|
|
39
37
|
|
|
40
38
|
def default_revision
|
|
41
|
-
'master'
|
|
39
|
+
overridable_default('revision', 'master')
|
|
42
40
|
end
|
|
43
41
|
|
|
44
42
|
def default_fetch_cache
|
|
45
|
-
0
|
|
43
|
+
overridable_default('fetch_cache', 0)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def overridable_default(arg, default)
|
|
47
|
+
defaults.fetch(arg)
|
|
48
|
+
rescue
|
|
49
|
+
default
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def overridable_arg(arg)
|
|
53
|
+
overrides.fetch(arg)
|
|
54
|
+
rescue
|
|
55
|
+
args.fetch(arg)
|
|
46
56
|
end
|
|
47
57
|
|
|
48
58
|
def validate!
|
data/lib/herdsman/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: herdsman
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tom Marshall
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
12
|
-
dependencies:
|
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.19.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.19.0
|
|
13
27
|
description: Herdsman is a CLI utility for working with multiple Git repositories
|
|
14
28
|
email: tommarshall7@gmail.com
|
|
15
29
|
executables:
|