gotsha 0.2.8 → 0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c141f44322e5b490f725002cfeb08b78c6fdac86bd596311fdb9a80a553d2119
4
- data.tar.gz: 8061d31df2234c3911c827bdf5592e9d25281187d36605ec5ab8a64c98a5a7f1
3
+ metadata.gz: 6d2eaa7864b9db6785117da9995761e2f6012ebc0c17d6ea6bd509c36791237e
4
+ data.tar.gz: d9c634e46197de4fd2c9515bf87ea7fee9f63cceb563dde98068a821e5bab175
5
5
  SHA512:
6
- metadata.gz: 6b52ac1560058e39dbe268e04fac7f0f9cf7b031c11fe448da1fc825d7a6b3b10611d7cacbdddad2d768848998a23c8467a3eef51662d51d05d4b919710b2e70
7
- data.tar.gz: 2d574789ad564b58d86fa3de9dd647e449a5c8925cf715531b31cc22c20f64491f051f51b0e34c687b6ed4a4e5443f73cbc5f85d65db0dc1bfb788265c0f4398
6
+ metadata.gz: e97d568ebcd2f288b16841a7a673ad64fe38fcbb6a63ab46acc82ff6601da22891218b9173a325a3ed00cbfe0c27db9247f7ab4590dd1cac7c6b056eabc8857a
7
+ data.tar.gz: 45bb9f592dc803fbe9d2ce9c4b8e70671d27f92daaeee1c6251b3c83f60f0ce6458b22b2f5bc457c6939504588cfd009b3cb24598a6acc4c0cfca08b57665e79
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- grep -qE 'pre_push_tests\s*=\s*true' .gotsha/config.toml && (gotsha status || gotsha test)
5
- gotsha push
4
+ grep -qE 'pre_push_tests\s*=\s*true' .gotsha/config.toml && (exe/gotsha status || exe/gotsha test)
5
+ exe/gotsha push
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [0.3] - 2025-10-18
2
+
3
+ - Add guide for case when `gotsha config` fails due to missing `ENV['EDITOR']`
4
+ - Enhance help command (hide some internal commands to not confuse users, add `-h` alias for `help`, add the ability to call `gotsha help <command>` AND `gotsha <command> -h`)
5
+ - Change wording and examples in the config file template, to make it less confising for new users
6
+
7
+ ## [0.2.9] - 2025-10-15
8
+
9
+ - Add some commented out GT Action code to quickly show how to disable for PR drafts
10
+
1
11
  ## [0.2.8] - 2025-10-15
2
12
 
3
13
  - Fix pre-push hook (push every time, even when disabled)
data/exe/gotsha CHANGED
@@ -3,10 +3,8 @@
3
3
 
4
4
  require_relative "../lib/gotsha"
5
5
 
6
- action = ARGV.first
7
-
8
6
  begin
9
- message = Gotsha::ActionDispatcher.call(action)
7
+ message = Gotsha::ActionDispatcher.call(*ARGV)
10
8
  puts("\n✓ Gotsha: #{message}\n\n")
11
9
  exit 0
12
10
  rescue Gotsha::Errors::SoftFail => e
@@ -2,23 +2,26 @@
2
2
 
3
3
  module Gotsha
4
4
  class ActionDispatcher
5
- INIT_SETUP_ACTION = "init"
5
+ SKIP_CONFIG_VERIFICATION_FOR = %w[init configure uninstall].freeze
6
6
  DEFAULT_ACTION = "help"
7
- OPEN_CONFIG_ACTION = "configure"
8
- UNINSTALL_ACTION = "uninstall"
7
+ HELP_ACTION_SHORTCUT = "-h"
9
8
 
10
- def self.call(action_name = DEFAULT_ACTION)
9
+ def self.call(action_name = DEFAULT_ACTION, *args)
11
10
  action_name ||= DEFAULT_ACTION
12
11
 
13
- new.call(action_name)
12
+ new.call(action_name, *args)
14
13
  end
15
14
 
16
- def call(action_name)
15
+ def call(action_name, *args)
17
16
  @action_name = action_name
18
17
 
19
18
  verify_configuration!
20
19
 
21
- action_class.new.call
20
+ action_class.new.call(*args)
21
+ rescue ArgumentError
22
+ return Actions::Help.new.call(action_name) if args == [HELP_ACTION_SHORTCUT]
23
+
24
+ raise Errors::HardFail, "too many arguments"
22
25
  end
23
26
 
24
27
  private
@@ -26,9 +29,7 @@ module Gotsha
26
29
  attr_reader :action_name
27
30
 
28
31
  def verify_configuration!
29
- return if UserConfig.get(:ci)
30
-
31
- return if [INIT_SETUP_ACTION, UNINSTALL_ACTION].include?(action_name.to_s)
32
+ return if SKIP_CONFIG_VERIFICATION_FOR.include?(action_name.to_s) || UserConfig.get(:ci)
32
33
 
33
34
  raise(Errors::HardFail, "config files not found, please run `gotsha init` first") if UserConfig.blank?
34
35
 
@@ -39,7 +40,6 @@ module Gotsha
39
40
  end
40
41
 
41
42
  return unless UserConfig.get(:autogenerated)
42
- return if action_name.to_s == OPEN_CONFIG_ACTION
43
43
 
44
44
  raise Errors::HardFail,
45
45
  "autogenerated config detected! Please, remove `autogenerated = true` from `#{Config::CONFIG_FILE}` " \
@@ -47,8 +47,10 @@ module Gotsha
47
47
  end
48
48
 
49
49
  def action_class
50
- Kernel.const_get("Gotsha::Actions::#{action_name.capitalize}")
50
+ Kernel.const_get("Gotsha::Actions::#{action_name.to_s.capitalize}")
51
51
  rescue NameError
52
+ return Gotsha::Actions::Help if action_name.to_s == HELP_ACTION_SHORTCUT
53
+
52
54
  raise Errors::HardFail, "unknown command `#{action_name}`. See available commands via `gotsha help`."
53
55
  end
54
56
  end
@@ -3,7 +3,7 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Commit
6
- DESCRIPTION = "creates a dummy commit and runs tests on it"
6
+ DESCRIPTION = "creates a dummy commit and runs tests on it (use for manual sign-off, if you disable hooks)"
7
7
 
8
8
  def call
9
9
  BashCommand.silent_run!('git -c core.hooksPath=/dev/null commit --allow-empty -m "Run Gotsha"')
@@ -8,7 +8,12 @@ module Gotsha
8
8
  def call
9
9
  editor = ENV["EDITOR"]
10
10
 
11
- raise(Errors::HardFail, "please, set ENV variable `EDITOR` first") unless editor
11
+ if editor.to_s.empty?
12
+ raise(Errors::HardFail,
13
+ "could not open config file automatically, ENV " \
14
+ "variable `EDITOR` not set.\n\nPlease, open file" \
15
+ "`#{Config::CONFIG_FILE}` manually.")
16
+ end
12
17
 
13
18
  if Kernel.system("#{editor} #{Config::CONFIG_FILE}")
14
19
  "done"
@@ -3,31 +3,52 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Help
6
- DESCRIPTION = "shows available commands and some tips"
6
+ DESCRIPTION = "shows available commands and some tips (has optional <COMMAND> argument)"
7
+ INTERNAL_ACTIONS = %i[fetch push test].freeze
8
+
9
+ def call(action_name = nil)
10
+ @action_name = action_name
7
11
 
8
- def call
9
12
  [
10
13
  "help",
11
14
  commands,
15
+ action_description,
12
16
  config_file,
13
17
  contact
14
- ].join("\n\n")
18
+ ].compact.join("\n\n")
15
19
  end
16
20
 
17
21
  private
18
22
 
19
23
  def commands
24
+ return if @action_name
25
+
20
26
  commands = Gotsha::Actions.constants.map do |command|
21
27
  name = command.downcase
28
+
29
+ next if INTERNAL_ACTIONS.include?(name)
30
+
22
31
  description = Kernel.const_get("Gotsha::Actions::#{command}::DESCRIPTION")
23
32
 
24
33
  "gotsha #{name} # #{description}"
25
- end.sort.join("\n")
34
+ end.compact.sort.join("\n")
26
35
 
27
36
  "Available commands: \n\n#{commands}\n"
28
37
  end
29
38
 
39
+ def action_description
40
+ return unless @action_name
41
+
42
+ description = Kernel.const_get("Gotsha::Actions::#{@action_name.capitalize}::DESCRIPTION")
43
+
44
+ "`gotsha #{@action_name}` #{description}"
45
+ rescue NameError
46
+ raise Errors::HardFail, "unknown command `#{@action_name}`"
47
+ end
48
+
30
49
  def config_file
50
+ return if @action_name
51
+
31
52
  [
32
53
  "Config file:",
33
54
  "How and when Gotsha runs tests is configured in `#{Config::CONFIG_FILE}` file, " \
@@ -39,6 +60,8 @@ module Gotsha
39
60
  end
40
61
 
41
62
  def contact
63
+ return if @action_name
64
+
42
65
  [
43
66
  "Contact:",
44
67
  "Is something not clear? Did you find a bug? Would you use new feature? Let's talk! \n" \
@@ -3,7 +3,7 @@
3
3
  module Gotsha
4
4
  module Actions
5
5
  class Init
6
- DESCRIPTION = "first setup"
6
+ DESCRIPTION = "performs the Gotsha setup (creates few files and changes Git Hooks path)"
7
7
 
8
8
  def call
9
9
  puts "Creating files..."
@@ -26,8 +26,7 @@ module Gotsha
26
26
  return if commands.any?
27
27
 
28
28
  raise(Errors::HardFail,
29
- "please, define some test commands in `#{Config::CONFIG_FILE}` " \
30
- "(you can run `gotsha configure` to open it)")
29
+ "no test commands configured, please run `gotsha configure`")
31
30
  end
32
31
 
33
32
  def run_commands!
@@ -70,7 +69,7 @@ module Gotsha
70
69
  end
71
70
 
72
71
  def commands
73
- @commands ||= UserConfig.get(:commands) || []
72
+ @commands ||= (UserConfig.get(:commands) || []).reject(&:empty?)
74
73
  end
75
74
  end
76
75
  end
@@ -9,15 +9,18 @@ autogenerated = true # Remove this line to start using Gotsha
9
9
  #
10
10
  # Test commands
11
11
  #
12
- # This is where you define what tests to run and how.
13
- # Multiple (comma-separated) commands supported, see the
14
- # commented examples:
12
+ # This is where you define your test commands.
13
+ # A "test command" is any bash command.
14
+ # Multiple (comma-separated) commands supported
15
15
  #
16
16
  commands = [
17
- # "bundle exec rspec --order rand",
18
- # "bin/rails t",
19
- # "rubocop",
20
- # "docker exec -it great-app rspec"
17
+ # Your first test command goes into the parentheses!
18
+ "",
19
+ # See some examples:
20
+ # "bundle exec rspec --order rand",
21
+ # "bin/rails t",
22
+ # "rubocop",
23
+ # "docker exec -it great-app rspec"
21
24
  ]
22
25
 
23
26
  # Git hooks config
@@ -34,7 +37,7 @@ commands = [
34
37
  #
35
38
  # ```
36
39
  #
37
- post_commit_tests = false # run tests for every commit
40
+ post_commit_tests = true # run tests for every commit
38
41
  pre_push_tests = true # run tests on every push
39
42
  interrupt_push_on_tests_failure = false # prohibit pushing when tests fail
40
43
 
@@ -2,6 +2,8 @@ name: Gotsha
2
2
 
3
3
  on:
4
4
  pull_request:
5
+ # Uncomment line below to run Gotsha only when asking for review (ie. do not run when PR is draft)
6
+ # types: [ready_for_review]
5
7
 
6
8
  jobs:
7
9
  verify:
@@ -18,7 +18,7 @@ module Gotsha
18
18
  rescue Errno::ENOENT
19
19
  {}
20
20
  rescue TomlRB::ParseError => e
21
- raise Errors::HardFail, "Syntax error in config file\n\n#{e.message}"
21
+ raise Errors::HardFail, "Syntax error in config file. Open it by running `gotsha configure`\n\n#{e.message}"
22
22
  end
23
23
  end
24
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gotsha
4
- VERSION = "0.2.8"
4
+ VERSION = "0.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gotsha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitek Meloun