manifestly 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/manifestly/manifest_item.rb +65 -6
- data/lib/manifestly/repository.rb +5 -11
- data/lib/manifestly/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a122c2c2aad6e6043dfb5e16f1d51362eceaf94
|
4
|
+
data.tar.gz: 06b7b5cbb590eedf3c5229edf2c16a0b66b3d775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eadfeb8b0b646242ac93ef0ec955db3326f4546edef87f56669f6e9303bfbbd109a8e8db73a0cb087056e290ea0e9e31f6d29e3492100537db64ab4fc17bc3b1
|
7
|
+
data.tar.gz: 02cc0ec9bf7d0c29fbcd21155330cb4e2dabf543ba7559f66300d158337e47558814f7d41dc7735db867edd72302d12246391e632cd7c63df54d42d1f25ba495
|
data/README.md
CHANGED
@@ -20,13 +20,15 @@ To update to the latest version:
|
|
20
20
|
A manifest is simple: just a file listing off repositories at specified commits, e.g.:
|
21
21
|
|
22
22
|
```
|
23
|
-
my_github_org/application_1
|
24
|
-
my_github_org/application_2
|
23
|
+
[directory_1] my_github_org/application_1@fb18640024
|
24
|
+
[directory_2] my_github_org/application_2@c4eb68d6b1 # v1.2.3
|
25
25
|
```
|
26
26
|
|
27
27
|
When you have deploys that span multiple applications, a manifest lets you identify exactly what is deployed for each app.
|
28
28
|
This tool, Manifestly, helps you create, find, and use these manifests in your deploy infrastructure.
|
29
29
|
|
30
|
+
_Note: By including repository source directories, manifestly helps support cases where one repository holds the source for multiple deployments. Manifestly will also include tag names for the indicated commit at the end of each line in a comment._
|
31
|
+
|
30
32
|
## Usage
|
31
33
|
|
32
34
|
Manifestly has built in help:
|
@@ -30,20 +30,42 @@ module Manifestly
|
|
30
30
|
@repository.checkout_commit(@commit.sha, fetch_if_unfound)
|
31
31
|
end
|
32
32
|
|
33
|
+
def commit_tags
|
34
|
+
@repository.git.tags.select do |tag|
|
35
|
+
# Gotta do some digging to get tagged sha out of annotated tags
|
36
|
+
tagged_sha = tag.annotated? ?
|
37
|
+
tag.contents_array[0].split(" ").last == commit :
|
38
|
+
tag.sha
|
39
|
+
|
40
|
+
tagged_sha == commit.sha
|
41
|
+
end.map(&:name)
|
42
|
+
end
|
43
|
+
|
33
44
|
def to_file_string
|
34
|
-
|
45
|
+
dir = @repository.deepest_working_dir
|
46
|
+
repo = @repository.github_name_or_path
|
47
|
+
tags = commit_tags
|
48
|
+
|
49
|
+
"[#{dir}]#{repo.nil? ? '' : ' ' + repo}@#{commit.sha[0..9]}#{' # ' + tags.join(",") if tags.any?}"
|
35
50
|
end
|
36
51
|
|
37
52
|
def self.from_file_string(string, repositories)
|
38
|
-
repo_name, sha = string
|
39
|
-
raise(InvalidManifestItem, string) if repo_name.blank? || sha.blank?
|
53
|
+
repo_name, dir, sha = parse_file_string(string)
|
40
54
|
|
41
55
|
matching_repositories = repositories.select do |repo|
|
42
|
-
|
56
|
+
# directory name will be the most unique way to match and should always be available
|
57
|
+
# wheres repo_name won't always be
|
58
|
+
repo.deepest_working_dir == dir
|
59
|
+
end
|
60
|
+
|
61
|
+
# TODO test these two exceptions!
|
62
|
+
if matching_repositories.size > 1
|
63
|
+
raise(MultipleSameNameRepositories, "Dir: [#{dir}], Repo: [#{repo_name}]")
|
43
64
|
end
|
44
65
|
|
45
|
-
|
46
|
-
|
66
|
+
if matching_repositories.empty?
|
67
|
+
raise(RepositoryNotFound, "Dir: [#{dir}], Repo: [#{repo_name}]")
|
68
|
+
end
|
47
69
|
|
48
70
|
repository = matching_repositories.first
|
49
71
|
|
@@ -52,6 +74,43 @@ module Manifestly
|
|
52
74
|
item
|
53
75
|
end
|
54
76
|
|
77
|
+
def self.parse_file_string(string)
|
78
|
+
sha_re = "([a-fA-F0-9]+)"
|
79
|
+
repo_re = '([\w-]+\/[\w-]+)'
|
80
|
+
old_dir_re_1 = '\((.*)\)'
|
81
|
+
old_dir_re_2 = '(.*)'
|
82
|
+
new_dir_re = '\[(.*)\]'
|
83
|
+
|
84
|
+
# New style: `[dir] org/repo@sha`
|
85
|
+
if string =~ /#{new_dir_re}\W*#{repo_re}\W*@\W*#{sha_re}/
|
86
|
+
dir = $1.strip
|
87
|
+
repo_name = $2.strip
|
88
|
+
sha = $3.strip
|
89
|
+
# New style where there is no GH repo: `[dir]@sha`
|
90
|
+
elsif string =~ /#{new_dir_re}\W*@\W*#{sha_re}/
|
91
|
+
dir = $1.strip
|
92
|
+
sha = $2.strip
|
93
|
+
# Old style with dir shown: `org/repo (dir) @ sha`
|
94
|
+
elsif string =~ /#{repo_re}\W*#{old_dir_re_1}\W*@\W*#{sha_re}/
|
95
|
+
repo_name = $1.strip
|
96
|
+
dir = $2.strip
|
97
|
+
sha = $3.strip
|
98
|
+
# Old style with implicit dir: `org/repo @ sha`
|
99
|
+
elsif string =~ /#{repo_re}\W*@\W*#{sha_re}/
|
100
|
+
repo_name = $1.strip
|
101
|
+
sha = $2.strip
|
102
|
+
dir = repo_name.split('/').last
|
103
|
+
# Old style with no repo: `dir @ sha`
|
104
|
+
elsif string =~ /#{old_dir_re_2}\W*@\W*#{sha_re}/
|
105
|
+
dir = $1.strip
|
106
|
+
sha = $2.strip
|
107
|
+
else
|
108
|
+
raise(InvalidManifestItem, string)
|
109
|
+
end
|
110
|
+
|
111
|
+
[repo_name, dir, sha]
|
112
|
+
end
|
113
|
+
|
55
114
|
attr_accessor :commit
|
56
115
|
attr_reader :repository
|
57
116
|
|
@@ -239,18 +239,12 @@ module Manifestly
|
|
239
239
|
git.dir
|
240
240
|
end
|
241
241
|
|
242
|
+
def deepest_working_dir
|
243
|
+
working_dir.to_s.split(File::SEPARATOR).last
|
244
|
+
end
|
245
|
+
|
242
246
|
def display_name
|
243
|
-
if github_name_or_path
|
244
|
-
repo_name = github_name_or_path.split('/').last
|
245
|
-
dir_name = working_dir.to_s.split(File::SEPARATOR).last
|
246
|
-
if repo_name == dir_name
|
247
|
-
github_name_or_path
|
248
|
-
else
|
249
|
-
github_name_or_path + " (#{dir_name})"
|
250
|
-
end
|
251
|
-
else
|
252
|
-
working_dir.to_s.split('/').last
|
253
|
-
end
|
247
|
+
"[#{deepest_working_dir}]#{' ' + github_name_or_path if !github_name_or_path.nil?}"
|
254
248
|
end
|
255
249
|
|
256
250
|
protected
|
data/lib/manifestly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manifestly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|