gotsha 1.2.2 → 1.2.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: 3e0f73be2106c8fd2111cf3e47162d1937dc90f518de9937ae9c520f9326024a
4
- data.tar.gz: b3f3bf5f2b1f80e2ade8fe795b6ce1df454d1b0262ed00f991d16810378469a8
3
+ metadata.gz: fb220efa50d1fcf743ab88b04069a95cac84bbb0e0a0f0b14e00fb1c64d2142a
4
+ data.tar.gz: 523153c4bf0c11c20ab8f7e1e62d80c11b4993f40b76421cfc8f098dca42534a
5
5
  SHA512:
6
- metadata.gz: b1b39081004be11a4b7569e54c42bb346e367b24d64f1603982c9a985b4502a014d0f546d3f158b1d1e9c6012da7a63c3f15e807452a7e9d68f4c969a51f8eaf
7
- data.tar.gz: 0ab6697d6d78ec97fcbd69c1241ab8c3ae9f01184f8fcb27cf169a4a0f1f43faa4fb5403f543c8825f02efc4051c6479857b5e4dc62d2fcd6e0ec44a540b6dd9
6
+ metadata.gz: 7042e35f72ee02ea6b480e8bff850717b7faeb22aa70f949557d2847932c2f6de9938cc94d554645198e17d01dca44f3bc125ec77a059231ab211938a7405816
7
+ data.tar.gz: fc89cd81d93194b62022a4a3271f5906a828f67bb935372ed2cd40b3065c1c7568cdac17133d3059795c1a4e138ae360d3701376ec48b40fc88965eab8c08bc1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.2.3] - 2026-04-18
2
+
3
+ - Fix small bugs (security and Git integration).
4
+
1
5
  ## [1.2.2] - 2026-01-03
2
6
 
3
7
  - 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
@@ -6,12 +6,19 @@ module Gotsha
6
6
  DESCRIPTION = "fetches Gotsha test results from remote"
7
7
 
8
8
  def call
9
- command = BashCommand.silent_run!("git fetch --force origin 'refs/notes/gotsha:refs/notes/gotsha'")
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
@@ -6,7 +6,8 @@ module Gotsha
6
6
  DESCRIPTION = "pushes Gotsha test results to remote"
7
7
 
8
8
  def call
9
- command = BashCommand.silent_run!("git push --no-verify --force origin refs/notes/gotsha:refs/notes/gotsha")
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")
@@ -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
@@ -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
- ENV["GOTSHA_#{key.to_s.upcase}"] || # this allows changing config via ENV vars
9
- config[key]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gotsha
4
- VERSION = "1.2.2"
4
+ VERSION = "1.2.3"
5
5
  end
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
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ ruby = "latest"
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.2
4
+ version: 1.2.3
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: 3.6.9
97
+ rubygems_version: 4.0.6
96
98
  specification_version: 4
97
99
  summary: 'Gotsha: your local testing CI'
98
100
  test_files: []