gotsha 0.2.9 → 0.3.1
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 +10 -0
- data/exe/gotsha +1 -3
- data/lib/gotsha/action_dispatcher.rb +14 -12
- data/lib/gotsha/actions/commit.rb +1 -1
- data/lib/gotsha/actions/configure.rb +6 -1
- data/lib/gotsha/actions/help.rb +27 -4
- data/lib/gotsha/actions/init.rb +1 -1
- data/lib/gotsha/actions/test.rb +2 -3
- data/lib/gotsha/templates/config.toml +12 -8
- data/lib/gotsha/user_config.rb +1 -1
- data/lib/gotsha/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fcd97adf3389ca91dd4a960d384481f31846423bf51eac8ecda8cf4634d8eb8
|
4
|
+
data.tar.gz: f59e613178b3708fe10ea46ec5367459185a3c1786dbad66fb84835ba789e016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5cd691e9c3b94e53d4f2772f06716423d941909a65ff21a2a662ef149d2436a70c6af3d6afceca7329f9ad17f30feadccb49ed07034cf02838c6d292f13e0fa
|
7
|
+
data.tar.gz: c9b1fceb52dc6f154cc65d19b6e8fc0fc97128092c2f10b0de96c41844901c491e33c5ccd861bd0b521ec9bf12f22047b44239bf146d6e662faaf5bf1f9ff33d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## [0.3.1] - 2025-10-18
|
2
|
+
|
3
|
+
- Add some non-Ruby test command examples to autogenerated config file. Gotsha is language-agnostic :-).
|
4
|
+
|
5
|
+
## [0.3] - 2025-10-18
|
6
|
+
|
7
|
+
- Add guide for case when `gotsha config` fails due to missing `ENV['EDITOR']`
|
8
|
+
- 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`)
|
9
|
+
- Change wording and examples in the config file template, to make it less confising for new users
|
10
|
+
|
1
11
|
## [0.2.9] - 2025-10-15
|
2
12
|
|
3
13
|
- Add some commented out GT Action code to quickly show how to disable for PR drafts
|
data/exe/gotsha
CHANGED
@@ -2,23 +2,26 @@
|
|
2
2
|
|
3
3
|
module Gotsha
|
4
4
|
class ActionDispatcher
|
5
|
-
|
5
|
+
SKIP_CONFIG_VERIFICATION_FOR = %w[init configure uninstall].freeze
|
6
6
|
DEFAULT_ACTION = "help"
|
7
|
-
|
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
|
-
|
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"
|
data/lib/gotsha/actions/help.rb
CHANGED
@@ -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" \
|
data/lib/gotsha/actions/init.rb
CHANGED
data/lib/gotsha/actions/test.rb
CHANGED
@@ -26,8 +26,7 @@ module Gotsha
|
|
26
26
|
return if commands.any?
|
27
27
|
|
28
28
|
raise(Errors::HardFail,
|
29
|
-
"
|
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,19 @@ autogenerated = true # Remove this line to start using Gotsha
|
|
9
9
|
#
|
10
10
|
# Test commands
|
11
11
|
#
|
12
|
-
# This is where you define
|
13
|
-
#
|
14
|
-
#
|
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
|
-
#
|
18
|
-
|
19
|
-
#
|
20
|
-
# "
|
17
|
+
# Your first test command goes into the parentheses!
|
18
|
+
"",
|
19
|
+
# See some examples:
|
20
|
+
# "bin/rails t",
|
21
|
+
# "docker-compose exec great_app rspec"
|
22
|
+
# "npm test"
|
23
|
+
# "npx jest --ci"
|
24
|
+
# "pytest -q"
|
21
25
|
]
|
22
26
|
|
23
27
|
# Git hooks config
|
@@ -34,7 +38,7 @@ commands = [
|
|
34
38
|
#
|
35
39
|
# ```
|
36
40
|
#
|
37
|
-
post_commit_tests =
|
41
|
+
post_commit_tests = true # run tests for every commit
|
38
42
|
pre_push_tests = true # run tests on every push
|
39
43
|
interrupt_push_on_tests_failure = false # prohibit pushing when tests fail
|
40
44
|
|
data/lib/gotsha/user_config.rb
CHANGED
@@ -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
|
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
|
data/lib/gotsha/version.rb
CHANGED