verto 0.6.1 → 0.7.0

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: 3f133ca9770197a96c51bf790c7ad1370b16927a6a651ef8392b04bfb58d894d
4
- data.tar.gz: 7b30716c515ebf40d095bf7e0a684de630c10fdba522a4f9273722d2bc748803
3
+ metadata.gz: cfd9726849a396c41f007f2fab517a0df8785a803abe7e1a0f9d612ad24b91bb
4
+ data.tar.gz: 7eb69cf6a56f0b754c83007ba047e916ce42cb093358b8b38284f5305ef04a64
5
5
  SHA512:
6
- metadata.gz: a9c790091841b1f6825ac130f9f3b0affc84acd8856fa385a76a06603d9fdaa8768b4a8a72833146a2b44033cfafdaf724d9c73031ba4299b252e42cd415a7f0
7
- data.tar.gz: 7ad45eacb814408b1a99064ca3e6419d818969b607c591f50d5f89ff3ab2274f39b4513458b513536f41e533daca77ba73266b9462a14ac958b351b644a5e948
6
+ metadata.gz: 79883291888bd50b34a5965fb70a6a1fb8b2dcfbb5f9b2d837253f7ee2484a09ba9f8087d783bfac4e0d9abbe3db86f9f2f5519699ad532a6d5e8b669944f103
7
+ data.tar.gz: 4db6f9d35a10d97de50b8f9e61c4dea72e1d3f8ff038bd915d34357d8b7bef4fd91cc17bb14220fa366f14b216fffd873bf7a3b810d5c8fa051a4873b1b5ba7a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.7.0 - 29/04/2020
2
+ * [FEATURE Built In Git Hooks]
3
+
1
4
  ## 0.6.1 - 15/04/2020
2
5
  * [FIX] Fix Vertofile to add Gemfile.lock before release
3
6
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- verto (0.6.1)
4
+ verto (0.7.0)
5
5
  dry-auto_inject (~> 0.7)
6
6
  dry-configurable (~> 0.8)
7
7
  dry-container (~> 0.7)
data/README.md CHANGED
@@ -32,28 +32,20 @@ You don't need to install verto in your machine, you can run verto via the docke
32
32
  To use verto in the same way that you use any other cli, you can set an alias in your `.bashrc`, `.zshrc`, etc:
33
33
 
34
34
  ```shell
35
- alias verto='docker run -v $(pwd):/usr/src/project -it catks/verto:0.6.1'
35
+ alias verto='docker run -v $(pwd):/usr/src/project -it catks/verto:0.7.0'
36
36
  ```
37
37
 
38
38
  If you want you can share your git configuration and known_hosts with:
39
39
 
40
40
  ```shell
41
- alias verto='docker run -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -it catks/verto:0.6.1'
41
+ alias verto='docker run -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -it catks/verto:0.7.0'
42
42
 
43
43
  ```
44
44
 
45
- You can also use your ssh keys with verto container (for git push):
45
+ You can also use your ssh keys, know_hosts and git config with verto container (for git push):
46
46
 
47
47
  ```shell
48
- alias verto='docker run -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -e SSH_PRIVATE_KEY=/root/.ssh/id_rsa -it catks/verto:0.6.1'
49
-
50
- ```
51
-
52
- Or share the git config, known_hosts and ssh_keys:
53
-
54
-
55
- ```shell
56
- alias verto='docker run -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -e SSH_PRIVATE_KEY=/root/.ssh/id_rsa -it catks/verto:0.6.1'
48
+ alias verto='docker run -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -e SSH_PRIVATE_KEY=/root/.ssh/id_rsa -it catks/verto:0.7.0'
57
49
 
58
50
  ```
59
51
 
@@ -93,20 +85,21 @@ You can create a new Vertofile with `verto init` or following the next example:
93
85
  ```ruby
94
86
  # Vertofile
95
87
 
96
- verto_version '0.6.1'
88
+ verto_version '0.7.0'
97
89
 
98
90
  config {
99
91
  # version.prefix = 'v' # Adds a version_prefix
92
+ git.pull_before_tag_creation = true # Pull Changes before tag creation
93
+ git.push_after_tag_creation = true # Push changes after tag creation
100
94
  }
101
95
 
102
96
  context(branch('master')) {
103
- before_command('tag_up') {
97
+ before_command_tag_up {
104
98
  git!('origin master')
105
99
  command_options.add(filter: 'release_only')
106
100
  }
107
101
 
108
- on('before_tag_creation') {
109
-
102
+ before_tag_creation {
110
103
  version_changes = sh(
111
104
  %q#git log --oneline --decorate | grep -B 100 -m 1 "tag:" | grep "pull request" | awk '{print $1}' | xargs git show --format='%b' | grep -v Approved | grep -v "^$" | grep -E "^[[:space:]]*\[.*\]" | sed 's/^[[:space:]]*\(.*\)/ * \1/'#, output: false
112
105
  ).output
@@ -130,30 +123,26 @@ context(branch('master')) {
130
123
  git('commit -m "Updates CHANGELOG"')
131
124
  }
132
125
 
133
- after_command('tag_up') {
134
- git('push --tags')
135
- git('push origin master')
136
- }
126
+ # After Hooks
127
+ # after_command_tag_up {
128
+ # git('push --tags')
129
+ # git('push origin master')
130
+ # }
137
131
  }
138
132
 
139
133
  context(branch('staging')) {
140
- before_command('tag_up') {
134
+ before_command_tag_up {
141
135
  git!('pull origin staging')
142
136
  command_options.add(pre_release: 'rc')
143
137
  }
144
138
 
145
- on('before_tag_creation') {
139
+ before_tag_creation {
146
140
  # file('package.json').replace(/"(\d+)\.(\d+)\.(\d+)(-?.*)"/, %Q{"#{new_version}"})
147
141
  # git('add package.json')
148
142
 
149
143
  git('commit -m "Release QA"')
150
144
  git('commit --allow-empty -m "Staging Release"')
151
145
  }
152
-
153
- after_command('tag_up') {
154
- git('push --tags')
155
- git('push origin staging')
156
- }
157
146
  }
158
147
 
159
148
  # Block tag creation in other branchs
@@ -171,7 +160,7 @@ context(!branch('master', 'staging')) {
171
160
 
172
161
  1. Complete README.md description
173
162
  2. Add a configuration to enable, disable or specify the number of tags that a single commit can have(eg: only one release and one pre-release)
174
- 5. Adds more specs and test coverage in CI
163
+ 3. Adds more specs and test coverage in CI
175
164
 
176
165
  ## Contributing
177
166
 
data/Vertofile CHANGED
@@ -1,16 +1,17 @@
1
- verto_version '0.5.0'
1
+ verto_version '0.6.1'
2
2
 
3
3
  config {
4
- version.prefix = 'v' # Adds a version_prefix
4
+ version.prefix = 'v' # Adds a version_prefix
5
+ git.pull_before_tag_creation = true
6
+ git.push_after_tag_creation = true
5
7
  }
6
8
 
7
9
  context(branch('master')) {
8
- before_command('tag_up') {
9
- git!('pull origin master')
10
+ before_command_tag_up {
10
11
  command_options.add(filter: 'release_only')
11
12
  }
12
13
 
13
- on('before_tag_creation') {
14
+ before_tag_creation {
14
15
  version_changes = ""
15
16
  bitbucket_changes = sh(
16
17
  %q#git log --oneline --decorate | grep -B 100 -m 1 "tag:" | grep "pull request" | awk '{print $1}' | xargs git show --format='%b' | grep -v Approved | grep -v "^$" | grep -E "^[[:space:]]*\[.*\]" | sed 's/^[[:space:]]*\(.*\)/ * \1/'#, output: false
@@ -44,12 +45,5 @@ context(branch('master')) {
44
45
 
45
46
  git!('commit -m "Bumps Version"')
46
47
  }
47
-
48
- after_command('tag_up') {
49
- exit
50
- git!('push --tags')
51
- git!('push origin master')
52
- sh!('rake release')
53
- }
54
48
  }
55
49
 
@@ -11,6 +11,8 @@ module Verto
11
11
  option :version_prefix, type: :string, default: nil
12
12
 
13
13
  def up
14
+ load_config_hooks!
15
+
14
16
  call_hooks(%i[before before_tag_up], with_attributes: { command_options: options} )
15
17
 
16
18
  validate_version_option_presence!
@@ -79,7 +81,7 @@ module Verto
79
81
  add filters (eg: verto tag up --pre-release --filter=pre_release_only)
80
82
  or disable tag validation in Vertofile with config.version.validations.new_version_must_be_bigger = false
81
83
  TEXT
82
- ) if new_version < latest_version
84
+ ) if new_version < latest_version && Verto.config.version.validations.new_version_must_be_bigger
83
85
  end
84
86
 
85
87
  def validate_version_option_presence!
@@ -104,5 +106,10 @@ module Verto
104
106
  def version_prefix
105
107
  options[:version_prefix] || Verto.config.version.prefix
106
108
  end
109
+
110
+ def load_config_hooks!
111
+ Verto.config.hooks.prepend Verto::DSL::BuiltInHooks::GitPullCurrentBranch if Verto.config.git.pull_before_tag_creation
112
+ Verto.config.hooks << Verto::DSL::BuiltInHooks::GitPushCurrentBranch if Verto.config.git.push_after_tag_creation
113
+ end
107
114
  end
108
115
  end
@@ -0,0 +1,22 @@
1
+ module Verto
2
+ module DSL
3
+ module BuiltInHooks
4
+ GitPullCurrentBranch = DSL::Hook.new(moment: :before) do
5
+ git!("pull origin #{current_branch}")
6
+ end
7
+
8
+ GitPushTags = DSL::Hook.new(moment: :after) do
9
+ git!("push --tags")
10
+ end
11
+
12
+ GitPushCurrentBranchCommits = DSL::Hook.new(moment: :after) do
13
+ git!("push origin #{current_branch}")
14
+ end
15
+
16
+ GitPushCurrentBranch = DSL::Hook.new(moment: :after) do
17
+ GitPushTags.call
18
+ GitPushCurrentBranchCommits.call
19
+ end
20
+ end
21
+ end
22
+ end
@@ -55,17 +55,13 @@ module Verto
55
55
  end
56
56
 
57
57
  def sh!(command, output: :from_config)
58
- raise Verto::ExitError unless sh(command, output: output).success?
58
+ raise Verto::ExitError, command unless sh(command, output: output).success?
59
59
  end
60
60
 
61
61
  def command_options
62
62
  Verto.config.command_options
63
63
  end
64
64
 
65
- def on(moment, &block)
66
- Verto.config.hooks << Hook.new(moment: moment, &block)
67
- end
68
-
69
65
  def before(&block)
70
66
  Verto.config.hooks << Hook.new(moment: :before, &block)
71
67
  end
@@ -74,14 +70,36 @@ module Verto
74
70
  Verto.config.hooks << Hook.new(moment: :after, &block)
75
71
  end
76
72
 
73
+ def on(moment, &block)
74
+ deprecate('on', use: 'before_tag_creation')
75
+
76
+ Verto.config.hooks << Hook.new(moment: moment, &block)
77
+ end
78
+
77
79
  def before_command(command_name, &block)
80
+ deprecate('before_command', use: 'before_command_tag_up')
81
+
78
82
  Verto.config.hooks << Hook.new(moment: "before_#{command_name}", &block)
79
83
  end
80
84
 
81
85
  def after_command(command_name, &block)
86
+ deprecate('after_command', use: 'after_command_tag_up')
87
+
82
88
  Verto.config.hooks << Hook.new(moment: "after_#{command_name}", &block)
83
89
  end
84
90
 
91
+ def before_command_tag_up(&block)
92
+ Verto.config.hooks << Hook.new(moment: 'before_tag_up', &block)
93
+ end
94
+
95
+ def after_command_tag_up(&block)
96
+ Verto.config.hooks << Hook.new(moment: 'after_tag_up', &block)
97
+ end
98
+
99
+ def before_tag_creation(&block)
100
+ Verto.config.hooks << Hook.new(moment: 'before_tag_creation', &block)
101
+ end
102
+
85
103
  def file(filepath)
86
104
  DSL::File.new(filepath)
87
105
  end
@@ -135,6 +153,10 @@ module Verto
135
153
 
136
154
  SemanticVersion.new(tag_version)
137
155
  end
156
+
157
+ def deprecate(current, use:)
158
+ warn "[DEPRECATED] `#{current}` is deprecated and wil be removed in a future release, use `#{use}` instead"
159
+ end
138
160
  end
139
161
  end
140
162
  end
@@ -1,19 +1,20 @@
1
- verto_version '0.6.1'
1
+ verto_version '0.7.0'
2
2
 
3
3
  config {
4
4
  # version.prefix = 'v' # Adds a version_prefix
5
5
  # pre_release.initial_number = 0 # Configures pre_release initial number, defaults to 1
6
6
  # project.path = "#{project_path}" # Configures a custom project path
7
+ # git.pull_before_tag_creation = true # Pull Changes before tag creation
8
+ # git.push_after_tag_creation = true # Push changes after tag creation
7
9
  }
8
10
 
9
11
  context(branch('master')) {
10
- before_command('tag_up') {
12
+ before_command_tag_up {
11
13
  git!('pull origin master')
12
14
  command_options.add(filter: 'release_only')
13
15
  }
14
16
 
15
- on('before_tag_creation') {
16
-
17
+ before_tag_creation{
17
18
  version_changes = ""
18
19
  # Uncomment to get Merged PRs Titles as changes to add in CHANGELOG.
19
20
  # version_changes = sh(
@@ -39,7 +40,7 @@ context(branch('master')) {
39
40
  git('commit -m "Updates CHANGELOG"')
40
41
  }
41
42
 
42
- after_command('tag_up') {
43
+ after_command_tag_up {
43
44
  git('push --tags')
44
45
  git('push origin master')
45
46
  }
@@ -47,18 +48,18 @@ context(branch('master')) {
47
48
 
48
49
  # Uncomment to get a specific pre_release proccess, like a staging or qa branch
49
50
  # context(branch('staging')) {
50
- # before_command('tag_up') {
51
+ # before_command_tag_up {
51
52
  # git!('pull origin staging')
52
53
  # command_options.add(pre_release: 'rc')
53
54
  # }
54
55
  #
55
- # on('before_tag_creation') {
56
+ # before_tag_creation {
56
57
  # file('package.json').replace(/"(\d+)\.(\d+)\.(\d+)(-?.*)"/, %Q{"#{new_version}"}) # Atualiza versão do package.json
57
58
  # git('add package.json')
58
59
  # git('commit --allow-empty -m "Staging Release"')
59
60
  # }
60
61
 
61
- # after_command('tag_up') {
62
+ # after_command_tag_up {
62
63
  # git('push --tags')
63
64
  # git('push origin staging')
64
65
  # }
data/lib/verto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Verto
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/verto.rb CHANGED
@@ -26,6 +26,14 @@ module Verto
26
26
 
27
27
  setting :version do
28
28
  setting :prefix, ''
29
+ setting :validations do
30
+ setting :new_version_must_be_bigger, true
31
+ end
32
+ end
33
+
34
+ setting :git do
35
+ setting :pull_before_tag_creation, false
36
+ setting :push_after_tag_creation, false
29
37
  end
30
38
 
31
39
  setting :hooks, []
@@ -88,6 +96,7 @@ require "verto/dsl/syntax"
88
96
  require "verto/dsl/interpreter"
89
97
  require "verto/dsl/hook"
90
98
  require "verto/dsl/file"
99
+ require "verto/dsl/built_in_hooks"
91
100
  require "verto/commands/base_command"
92
101
  require "verto/commands/tag_command"
93
102
  require "verto/commands/main_command"
data/verto.gemspec CHANGED
@@ -13,9 +13,9 @@ Gem::Specification.new do |spec|
13
13
  spec.license = "MIT"
14
14
 
15
15
 
16
- # spec.metadata["homepage_uri"] = spec.homepage
17
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
18
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/catks/verto"
18
+ spec.metadata["changelog_uri"] = "https://github.com/catks/verto/blob/master/CHANGELOG.md"
19
19
 
20
20
  # Specify which files should be added to the gem when it is released.
21
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Atkinson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-15 00:00:00.000000000 Z
11
+ date: 2020-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -179,6 +179,7 @@ files:
179
179
  - lib/verto/commands/main_command.rb
180
180
  - lib/verto/commands/tag_command.rb
181
181
  - lib/verto/dsl.rb
182
+ - lib/verto/dsl/built_in_hooks.rb
182
183
  - lib/verto/dsl/file.rb
183
184
  - lib/verto/dsl/hook.rb
184
185
  - lib/verto/dsl/interpreter.rb
@@ -195,7 +196,10 @@ files:
195
196
  homepage: https://github.com/catks/verto
196
197
  licenses:
197
198
  - MIT
198
- metadata: {}
199
+ metadata:
200
+ homepage_uri: https://github.com/catks/verto
201
+ source_code_uri: https://github.com/catks/verto
202
+ changelog_uri: https://github.com/catks/verto/blob/master/CHANGELOG.md
199
203
  post_install_message:
200
204
  rdoc_options: []
201
205
  require_paths: