gotsha 0.2.3 → 0.2.5

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: f841293e7364e5d5f54063847dfe476567064dfe1db9a43508b40a25d02dfdef
4
- data.tar.gz: dd632b63c1459d15cf9ccc8f23e08f772b81737173c2073dc450790a3f672c68
3
+ metadata.gz: 91171467c8757fdfc1daa7d26824b5282a3273bc25649f67d907a24da5ed4b6b
4
+ data.tar.gz: 2c8892e5129b38130dd7f3bb4f8b8a31330627754883c0e6fcf10d3191306e7a
5
5
  SHA512:
6
- metadata.gz: 59a83f98f3357c79205f9c5e69410f8d6d2d4e56148d2d7b06fc1ac648adaee2109dcf04d2b58a51c0ee904358c0a5b39ebcd032c4fcd2dedbbe21af0a877205
7
- data.tar.gz: 3250fdc837dce2ddb76103cfc0a4754517a21f41f434a5b7e5ce2d2664a75cc0f53785a944938072949397bae10ec9f4c2c90acbaf8a105946066997d870133f
6
+ metadata.gz: 2f05012248c5e815491ff5418a8a7fa09d736c6d9b103a6b083a80ddb1e9546897ce7e8e3d0b2b3d1c3acddd6369b3e5e4eb4755044aa7d3a4e25851c7e00eb3
7
+ data.tar.gz: cb17994999f70a0600a3c9fbea42197a5054c7e7a5031e7960849e8d67e24d289df5faca6396e356ab3f5bcbffc7fa076558b282ccf3657d907a8352e188fea4
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
- [ -f .gotsha/config.toml ] || exit 0
3
+
4
4
  grep -qE 'post_commit_tests\s*=\s*true' .gotsha/config.toml || exit 0
5
+
5
6
  exe/gotsha test
6
7
 
@@ -1,21 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- [ -f .gotsha/config.toml ] || exit 0
4
+ grep -qE 'pre_push_tests\s*=\s*true' .gotsha/config.toml || exit 0
5
5
 
6
- grep -qE 'pre_push_tests\s*=\s*true' .gotsha/config.toml && (exe/gotsha status || exe/gotsha test)
7
-
8
- push_gotsha_notes() {
9
- # if already done before, let's only push the notes and exit
10
- git push --no-verify origin refs/notes/gotsha:refs/notes/gotsha && return 0
11
-
12
- # if pushing above failed, it means we need to do some one-time Git setup
13
- git fetch origin 'refs/notes/gotsha:refs/notes/gotsha-remote'
14
- git notes --ref=gotsha merge -v refs/notes/gotsha-remote
15
- git update-ref -d refs/notes/gotsha-remote
16
-
17
- # ... and push again!
18
- git push --no-verify origin refs/notes/gotsha:refs/notes/gotsha
19
- }
20
-
21
- push_gotsha_notes
6
+ exe/gotsha status || exe/gotsha test
7
+ exe/gotsha push
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.2.5] - 2025-10-14
2
+
3
+ - Introduce `push` and `fetch` commands
4
+
5
+ ## [0.2.4] - 2025-10-14
6
+
7
+ - Change Github Action config to actually use the gem itself (instead of bash scripting the logic)
8
+
1
9
  ## [0.2.3] - 2025-10-14
2
10
 
3
11
  - Add support for running on CI (ENV var GOTSHA_CI)
@@ -5,6 +5,7 @@ module Gotsha
5
5
  INIT_SETUP_ACTION = "init"
6
6
  DEFAULT_ACTION = "help"
7
7
  OPEN_CONFIG_ACTION = "configure"
8
+ UNINSTALL_ACTION = "uninstall"
8
9
 
9
10
  def self.call(action_name = DEFAULT_ACTION)
10
11
  action_name ||= DEFAULT_ACTION
@@ -27,7 +28,7 @@ module Gotsha
27
28
  def verify_configuration!
28
29
  return if UserConfig.get(:ci)
29
30
 
30
- return if action_name.to_s == INIT_SETUP_ACTION
31
+ return if [INIT_SETUP_ACTION, UNINSTALL_ACTION].include?(action_name.to_s)
31
32
 
32
33
  raise(Errors::HardFail, "config files not found, please run `gotsha init` first") if UserConfig.blank?
33
34
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gotsha
4
+ module Actions
5
+ class Fetch
6
+ DESCRIPTION = "fetches Gotsha test results from remote"
7
+
8
+ def call
9
+ command = BashCommand.silent_run!("git fetch origin 'refs/notes/gotsha:refs/notes/gotsha'")
10
+
11
+ raise(Errors::HardFail, "something went wrong") unless command.success?
12
+
13
+ "fetched"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gotsha
4
+ module Actions
5
+ class Push
6
+ DESCRIPTION = "pushes Gotsha test results to remote"
7
+
8
+ def call
9
+ try_push = push_command
10
+
11
+ unless try_push.success?
12
+ Fetch.new.call
13
+ push_command
14
+ end
15
+
16
+ "pushed"
17
+ end
18
+
19
+ private
20
+
21
+ def push_command
22
+ BashCommand.silent_run!("git push --no-verify origin refs/notes/gotsha:refs/notes/gotsha")
23
+ end
24
+ end
25
+ end
26
+ end
@@ -8,8 +8,8 @@ module Gotsha
8
8
  def call
9
9
  puts "Removing config files..."
10
10
 
11
- FileUtils.rm_rf(Config::CONFIG_DIR)
12
- FileUtils.rm(Config::GH_CONFIG_FILE)
11
+ File.exist?(Config::CONFIG_DIR) && FileUtils.rm_rf(Config::CONFIG_DIR)
12
+ File.exist?(Config::GH_CONFIG_FILE) && FileUtils.rm(Config::GH_CONFIG_FILE)
13
13
 
14
14
  puts "Unsetting Git hooks path..."
15
15
  BashCommand.silent_run!("git config --unset core.hooksPath")
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
- [ -f .gotsha/config.toml ] || exit 0
3
+
4
4
  grep -qE 'post_commit_tests\s*=\s*true' .gotsha/config.toml || exit 0
5
+
5
6
  gotsha test
6
7
 
@@ -1,21 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- [ -f .gotsha/config.toml ] || exit 0
4
+ grep -qE 'pre_push_tests\s*=\s*true' .gotsha/config.toml || exit 0
5
5
 
6
- grep -qE 'pre_push_tests\s*=\s*true' .gotsha/config.toml && (gotsha status || gotsha test)
7
-
8
- push_gotsha_notes() {
9
- # if already done before, let's only push the notes and exit
10
- git push --no-verify origin refs/notes/gotsha:refs/notes/gotsha && return 0
11
-
12
- # if pushing above failed, it means we need to do some one-time Git setup
13
- git fetch origin 'refs/notes/gotsha:refs/notes/gotsha-remote'
14
- git notes --ref=gotsha merge -v refs/notes/gotsha-remote
15
- git update-ref -d refs/notes/gotsha-remote
16
-
17
- # ... and push again!
18
- git push --no-verify origin refs/notes/gotsha:refs/notes/gotsha
19
- }
20
-
21
- push_gotsha_notes
6
+ gotsha status || gotsha test
7
+ gotsha push
@@ -12,33 +12,16 @@ jobs:
12
12
  fetch-depth: 0
13
13
  ref: ${{ github.event.pull_request.head.sha }}
14
14
 
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: '3.3'
18
+ bundler-cache: true
19
+
20
+ - name: Install Gotsha
21
+ run: gem install gotsha
22
+
15
23
  - name: Fetch Gotsha notes
16
24
  run: git fetch origin 'refs/notes/gotsha:refs/notes/gotsha'
17
25
 
18
26
  - name: Show tests output
19
- run: |
20
- SHA="${{ github.event.pull_request.head.sha }}"
21
- if git --no-pager notes --ref=gotsha show "$SHA" >/dev/null 2>&1; then
22
- git --no-pager notes --ref=gotsha show "$SHA"
23
- else
24
- echo "No gotsha note found for $SHA"
25
- fi
26
-
27
- - name: Verify
28
- run: |
29
- SHA="${{ github.event.pull_request.head.sha }}"
30
- NOTE="$(git --no-pager notes --ref=gotsha show "$SHA" 2>/dev/null || true)"
31
-
32
- if [ -z "$NOTE" ]; then
33
- echo "::error ::Gotsha: not verified yet. Run 'gotsha commit' to verify."
34
- exit 1
35
- elif [[ "$NOTE" == Tests\ failed:* ]]; then
36
- git --no-pager notes --ref=gotsha show "$SHA"
37
- echo "::error ::Gotsha: Tests failed"
38
- exit 1
39
- elif [[ "$NOTE" == Tests\ passed:* ]]; then
40
- echo "✓ Gotsha: tests passed"
41
- else
42
- echo "::error ::Unrecognized Gotsha note format for $SHA"
43
- exit 1
44
- fi
27
+ run: GOTSHA_CI=1 gotsha show
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gotsha
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
data/lib/gotsha.rb CHANGED
@@ -6,8 +6,10 @@ require "toml-rb"
6
6
  require_relative "gotsha/action_dispatcher"
7
7
  require_relative "gotsha/actions/commit"
8
8
  require_relative "gotsha/actions/configure"
9
+ require_relative "gotsha/actions/fetch"
9
10
  require_relative "gotsha/actions/help"
10
11
  require_relative "gotsha/actions/init"
12
+ require_relative "gotsha/actions/push"
11
13
  require_relative "gotsha/actions/show"
12
14
  require_relative "gotsha/actions/test"
13
15
  require_relative "gotsha/actions/uninstall"
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.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitek Meloun
@@ -45,8 +45,10 @@ files:
45
45
  - lib/gotsha/action_dispatcher.rb
46
46
  - lib/gotsha/actions/commit.rb
47
47
  - lib/gotsha/actions/configure.rb
48
+ - lib/gotsha/actions/fetch.rb
48
49
  - lib/gotsha/actions/help.rb
49
50
  - lib/gotsha/actions/init.rb
51
+ - lib/gotsha/actions/push.rb
50
52
  - lib/gotsha/actions/show.rb
51
53
  - lib/gotsha/actions/status.rb
52
54
  - lib/gotsha/actions/test.rb