gotsha 1.2.2 → 1.2.4
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 +7 -0
- data/lib/gotsha/action_dispatcher.rb +4 -4
- data/lib/gotsha/actions/commit.rb +3 -1
- data/lib/gotsha/actions/fetch.rb +9 -2
- data/lib/gotsha/actions/push.rb +2 -1
- data/lib/gotsha/actions/uninstall.rb +1 -0
- data/lib/gotsha/bash_command.rb +1 -1
- data/lib/gotsha/remote_resolver.rb +27 -0
- data/lib/gotsha/user_config.rb +13 -2
- data/lib/gotsha/version.rb +1 -1
- data/lib/gotsha.rb +1 -0
- data/mise.toml +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e2cc7b0a6d638757b14677caaa43f31683cdabd4726ad8488a2168ef08ca501a
|
|
4
|
+
data.tar.gz: 9020d7cd3e6145ca125fd761b6d9e25ccf99e6844dad32c2825482b552f81e39
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 508c0197ce27724c515f79239ace2664efe793ec0f39475f89b0efb0bc35ee84548199d86a54761efa28817728a7b1305be5afb283f3649fb17a4f6b0f1eadf6
|
|
7
|
+
data.tar.gz: e9e2487529629a31be43cb7e4889cc0bda5ee99f97febe8e69a1c1c17168ee4dab2e40f95603496a8a4cbbed19b6134a7faeb427878f6a3034cf574ec3ec4885
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.2.4] - 2026-04-18
|
|
2
|
+
|
|
3
|
+
- Squash a bug in Ruby loading, happening in Mac with Mise
|
|
4
|
+
## [1.2.3] - 2026-04-18
|
|
5
|
+
|
|
6
|
+
- Fix small bugs (security and Git integration).
|
|
7
|
+
|
|
1
8
|
## [1.2.2] - 2026-01-03
|
|
2
9
|
|
|
3
10
|
- Fix a bug: hooks did not ignore commented-out settings from config file. They do now.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Gotsha
|
|
4
4
|
class ActionDispatcher
|
|
5
|
-
SKIP_CONFIG_VERIFICATION_FOR = %w[init configure uninstall].freeze
|
|
5
|
+
SKIP_CONFIG_VERIFICATION_FOR = %w[init configure uninstall help -h --help].freeze
|
|
6
6
|
DEFAULT_ACTION = "help"
|
|
7
7
|
HELP_ACTION_SHORTCUT = "-h"
|
|
8
8
|
VERSION_ACTION_SHORTCUT = "-v"
|
|
@@ -16,13 +16,13 @@ module Gotsha
|
|
|
16
16
|
def call(action_name, *args)
|
|
17
17
|
@action_name = action_name
|
|
18
18
|
|
|
19
|
+
return Actions::Help.new.call(action_name) if args == [HELP_ACTION_SHORTCUT]
|
|
20
|
+
return Actions::Help.new.call(action_name) if args == ["--help"]
|
|
21
|
+
|
|
19
22
|
verify_configuration!
|
|
20
23
|
|
|
21
24
|
action_class.new.call(*args)
|
|
22
25
|
rescue ArgumentError
|
|
23
|
-
return Actions::Help.new.call(action_name) if args == [HELP_ACTION_SHORTCUT]
|
|
24
|
-
return Actions::Help.new.call(action_name) if args == ["--help"]
|
|
25
|
-
|
|
26
26
|
raise Errors::HardFail, "too many arguments"
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -6,7 +6,9 @@ module Gotsha
|
|
|
6
6
|
DESCRIPTION = "runs tests on a dummy commit for manual sign-off"
|
|
7
7
|
|
|
8
8
|
def call
|
|
9
|
-
BashCommand.silent_run!('git -c core.hooksPath=/dev/null commit --allow-empty -m "Run Gotsha"')
|
|
9
|
+
command = BashCommand.silent_run!('git -c core.hooksPath=/dev/null commit --allow-empty -m "Run Gotsha"')
|
|
10
|
+
|
|
11
|
+
raise Errors::HardFail, "something went wrong" unless command.success?
|
|
10
12
|
|
|
11
13
|
Test.new.call
|
|
12
14
|
end
|
data/lib/gotsha/actions/fetch.rb
CHANGED
|
@@ -6,12 +6,19 @@ module Gotsha
|
|
|
6
6
|
DESCRIPTION = "fetches Gotsha test results from remote"
|
|
7
7
|
|
|
8
8
|
def call
|
|
9
|
-
|
|
9
|
+
remote = RemoteResolver.resolve
|
|
10
|
+
command = BashCommand.silent_run!("git fetch --force #{remote} 'refs/notes/gotsha:refs/notes/gotsha'")
|
|
10
11
|
|
|
11
|
-
raise(Errors::HardFail, "something went wrong") unless command.success?
|
|
12
|
+
raise(Errors::HardFail, "something went wrong") unless command.success? || missing_notes_ref?(command)
|
|
12
13
|
|
|
13
14
|
"fetched"
|
|
14
15
|
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def missing_notes_ref?(command)
|
|
20
|
+
command.text_output.include?("couldn't find remote ref refs/notes/gotsha")
|
|
21
|
+
end
|
|
15
22
|
end
|
|
16
23
|
end
|
|
17
24
|
end
|
data/lib/gotsha/actions/push.rb
CHANGED
|
@@ -6,7 +6,8 @@ module Gotsha
|
|
|
6
6
|
DESCRIPTION = "pushes Gotsha test results to remote"
|
|
7
7
|
|
|
8
8
|
def call
|
|
9
|
-
|
|
9
|
+
remote = RemoteResolver.resolve
|
|
10
|
+
command = BashCommand.silent_run!("git push --no-verify --force #{remote} refs/notes/gotsha:refs/notes/gotsha")
|
|
10
11
|
|
|
11
12
|
raise(Errors::HardFail, "something went wrong") unless command.success?
|
|
12
13
|
|
|
@@ -10,6 +10,7 @@ module Gotsha
|
|
|
10
10
|
|
|
11
11
|
File.exist?(Config::CONFIG_DIR) && FileUtils.rm_rf(Config::CONFIG_DIR)
|
|
12
12
|
File.exist?(Config::GH_CONFIG_FILE) && FileUtils.rm(Config::GH_CONFIG_FILE)
|
|
13
|
+
File.exist?(Config::GL_CONFIG_FILE) && FileUtils.rm(Config::GL_CONFIG_FILE)
|
|
13
14
|
|
|
14
15
|
puts "Unsetting Git hooks path..."
|
|
15
16
|
BashCommand.silent_run!("git config --unset core.hooksPath")
|
data/lib/gotsha/bash_command.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Gotsha
|
|
|
18
18
|
exit_code = nil
|
|
19
19
|
|
|
20
20
|
# This block is an ugly workaround to ensure the color output is stored both on Linux and Mac
|
|
21
|
-
PTY.spawn("bash", "-
|
|
21
|
+
PTY.spawn("bash", "-c", "#{command}; printf \"\\n#{MARKER}%d\\n\" $?") do |r, _w, pid|
|
|
22
22
|
r.each do |line|
|
|
23
23
|
if line.start_with?(MARKER)
|
|
24
24
|
exit_code = line.sub(MARKER, "").to_i
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "open3"
|
|
4
|
+
|
|
5
|
+
module Gotsha
|
|
6
|
+
module RemoteResolver
|
|
7
|
+
def self.resolve
|
|
8
|
+
branch_name = BashCommand.run!("git branch --show-current").text_output
|
|
9
|
+
return "origin" if branch_name.empty?
|
|
10
|
+
|
|
11
|
+
push_remote = git_config("branch.#{branch_name}.pushRemote")
|
|
12
|
+
return push_remote unless push_remote.empty?
|
|
13
|
+
|
|
14
|
+
branch_remote = git_config("branch.#{branch_name}.remote")
|
|
15
|
+
return branch_remote unless branch_remote.empty?
|
|
16
|
+
|
|
17
|
+
"origin"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.git_config(key)
|
|
21
|
+
stdout, _status = Open3.capture2("git", "config", "--get", key)
|
|
22
|
+
stdout.strip
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private_class_method :git_config
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/gotsha/user_config.rb
CHANGED
|
@@ -4,15 +4,26 @@ module Gotsha
|
|
|
4
4
|
class UserConfig
|
|
5
5
|
def self.get(key)
|
|
6
6
|
config = new.to_h
|
|
7
|
+
env_key = "GOTSHA_#{key.to_s.upcase}"
|
|
8
|
+
env_value = ENV[env_key]
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
return config[key] if key.to_sym == :commands
|
|
11
|
+
return coerce_env_value(env_value) unless env_value.nil?
|
|
12
|
+
|
|
13
|
+
config[key]
|
|
10
14
|
end
|
|
11
15
|
|
|
12
16
|
def self.blank?
|
|
13
17
|
new.to_h.empty?
|
|
14
18
|
end
|
|
15
19
|
|
|
20
|
+
def self.coerce_env_value(value)
|
|
21
|
+
return true if value == "true"
|
|
22
|
+
return false if value == "false"
|
|
23
|
+
|
|
24
|
+
value
|
|
25
|
+
end
|
|
26
|
+
|
|
16
27
|
def to_h
|
|
17
28
|
TomlRB.load_file(Config::CONFIG_FILE).transform_keys(&:to_sym)
|
|
18
29
|
rescue Errno::ENOENT
|
data/lib/gotsha/version.rb
CHANGED
data/lib/gotsha.rb
CHANGED
|
@@ -18,6 +18,7 @@ require_relative "gotsha/actions/version"
|
|
|
18
18
|
require_relative "gotsha/bash_command"
|
|
19
19
|
require_relative "gotsha/config"
|
|
20
20
|
require_relative "gotsha/errors"
|
|
21
|
+
require_relative "gotsha/remote_resolver"
|
|
21
22
|
require_relative "gotsha/user_config"
|
|
22
23
|
require_relative "gotsha/version"
|
|
23
24
|
|
data/mise.toml
ADDED
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: 1.2.
|
|
4
|
+
version: 1.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vitek Meloun
|
|
@@ -56,6 +56,7 @@ files:
|
|
|
56
56
|
- lib/gotsha/bash_command.rb
|
|
57
57
|
- lib/gotsha/config.rb
|
|
58
58
|
- lib/gotsha/errors.rb
|
|
59
|
+
- lib/gotsha/remote_resolver.rb
|
|
59
60
|
- lib/gotsha/templates/config.toml
|
|
60
61
|
- lib/gotsha/templates/git_hooks/post-commit
|
|
61
62
|
- lib/gotsha/templates/git_hooks/pre-push
|
|
@@ -63,6 +64,7 @@ files:
|
|
|
63
64
|
- lib/gotsha/templates/gitlab_action_example.yml
|
|
64
65
|
- lib/gotsha/user_config.rb
|
|
65
66
|
- lib/gotsha/version.rb
|
|
67
|
+
- mise.toml
|
|
66
68
|
- sig/gotsha.rbs
|
|
67
69
|
- web/favicon.ico
|
|
68
70
|
- web/img/commit.png
|
|
@@ -92,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
92
94
|
- !ruby/object:Gem::Version
|
|
93
95
|
version: '0'
|
|
94
96
|
requirements: []
|
|
95
|
-
rubygems_version:
|
|
97
|
+
rubygems_version: 4.0.3
|
|
96
98
|
specification_version: 4
|
|
97
99
|
summary: 'Gotsha: your local testing CI'
|
|
98
100
|
test_files: []
|