gotsha 0.1.3.0 → 0.2.2
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 +9 -0
- data/README.md +6 -1
- data/lib/gotsha/action_dispatcher.rb +4 -1
- data/lib/gotsha/actions/configure.rb +22 -0
- data/lib/gotsha/actions/help.rb +33 -3
- data/lib/gotsha/actions/test.rb +2 -1
- data/lib/gotsha/bash_command.rb +25 -8
- data/lib/gotsha/version.rb +1 -1
- data/lib/gotsha.rb +1 -0
- data/web/img/commit.png +0 -0
- data/web/img/commit_checked.png +0 -0
- data/web/img/gh_action.png +0 -0
- data/web/img/push.png +0 -0
- data/web/index.html +24 -6
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae454dd9d8275719a0a1e4122be0075a6cdb198e5ce294829993d0b1ac3422da
|
|
4
|
+
data.tar.gz: b68234f7ebec3d02720f30da620988c7d7b7bf16b53bcba2369711d59ec6ddc7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46efa5956c790a2ab91363ec7ad23fd8713d3945add64766c226e0494f891b637558ba6ddf9219472f9a83957d63e58a346449e755b7bd7b5baf93f7efe955cc
|
|
7
|
+
data.tar.gz: 4c8d1e824084191a1d592059e01e22b1c80ff50cf397951c600db91713cdf853e9c4847b101a7aec12b1ba1dddb84990f9bab958caff2a5f801aecad9116bb44
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [0.2.2] - 2025-10-13
|
|
2
|
+
|
|
3
|
+
- Fix to ensure everything works on Mac as well
|
|
4
|
+
|
|
5
|
+
## [0.2.1.0] - 2025-10-13
|
|
6
|
+
|
|
7
|
+
- Better `help` output
|
|
8
|
+
- New command `gotsha configure` (opens config file in ENV EDITOR)
|
|
9
|
+
|
|
1
10
|
## [0.1.1] - 2025-10-12
|
|
2
11
|
|
|
3
12
|
- Some cleanup after verifying the gem is published
|
data/README.md
CHANGED
|
@@ -3,12 +3,14 @@ Pushing untested commits? Gotsha!
|
|
|
3
3
|
|
|
4
4
|
## Installation
|
|
5
5
|
```bash
|
|
6
|
-
gem install gotsha # or add `gem "gotsha"` to you Gemfile
|
|
6
|
+
gem install gotsha # or add `gem "gotsha"` to you Gemfile
|
|
7
7
|
|
|
8
8
|
gotsha
|
|
9
9
|
```
|
|
10
10
|
Then just follow the prompts — Gotsha will guide you through the setup. It won't take more than 3 minutes!
|
|
11
11
|
|
|
12
|
+
If you got stuck somewhere, you can always use `gotsha help`.
|
|
13
|
+
|
|
12
14
|
## What is it?
|
|
13
15
|
Gotsha is a tiny tool that lets you “sign off” your commit locally: it runs your tests and then stores the test results with the commit SHA (hence the gem name: got-SHA). Your pull request can then be verified against that record, so reviewers know you actually ran the checks before asking for review.
|
|
14
16
|
|
|
@@ -25,3 +27,6 @@ Then, you can see the tests results in a Github action:
|
|
|
25
27
|
(Screenshots from a real [demo pull request](https://github.com/melounvitek/gotsha/pull/35); check it out!)
|
|
26
28
|
|
|
27
29
|
Based on your workflow and tests speed, you can configure them to auto-run on every commit, before every push, or just manually. Whenever pushing to remote repository, the Git note (which is what's used to store the test results) gets sent there as well.
|
|
30
|
+
|
|
31
|
+
## Do you like Gotsha?
|
|
32
|
+
<a href="https://buymeacoffee.com/gotsha">I like coffee!</a>
|
|
@@ -4,6 +4,7 @@ module Gotsha
|
|
|
4
4
|
class ActionDispatcher
|
|
5
5
|
INIT_SETUP_ACTION = "init"
|
|
6
6
|
DEFAULT_ACTION = "help"
|
|
7
|
+
OPEN_CONFIG_ACTION = "configure"
|
|
7
8
|
|
|
8
9
|
def self.call(action_name = DEFAULT_ACTION)
|
|
9
10
|
action_name ||= DEFAULT_ACTION
|
|
@@ -35,9 +36,11 @@ module Gotsha
|
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
return unless UserConfig.get(:autogenerated)
|
|
39
|
+
return if action_name.to_s == OPEN_CONFIG_ACTION
|
|
38
40
|
|
|
39
41
|
raise Errors::HardFail,
|
|
40
|
-
"autogenerated config detected! Please, remove `autogenerated = true` from
|
|
42
|
+
"autogenerated config detected! Please, remove `autogenerated = true` from `#{Config::CONFIG_FILE}` " \
|
|
43
|
+
"(you can run `gotsha configure` to open it)"
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
def action_class
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gotsha
|
|
4
|
+
module Actions
|
|
5
|
+
class Configure
|
|
6
|
+
DESCRIPTION = "opens Gotsha config file"
|
|
7
|
+
|
|
8
|
+
def call
|
|
9
|
+
editor = ENV["EDITOR"]
|
|
10
|
+
|
|
11
|
+
raise(Errors::HardFail, "please, set ENV variable `EDITOR` first") unless editor
|
|
12
|
+
|
|
13
|
+
if Kernel.system("#{editor} #{Config::CONFIG_FILE}")
|
|
14
|
+
"done"
|
|
15
|
+
else
|
|
16
|
+
raise Errors::HardFail,
|
|
17
|
+
"something went wrong, please check whether `#{editor}` editor (set in ENV variable `EDITOR`) works"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/gotsha/actions/help.rb
CHANGED
|
@@ -3,17 +3,47 @@
|
|
|
3
3
|
module Gotsha
|
|
4
4
|
module Actions
|
|
5
5
|
class Help
|
|
6
|
-
DESCRIPTION = "shows available commands"
|
|
6
|
+
DESCRIPTION = "shows available commands and some tips"
|
|
7
7
|
|
|
8
8
|
def call
|
|
9
|
+
[
|
|
10
|
+
"help",
|
|
11
|
+
commands,
|
|
12
|
+
config_file,
|
|
13
|
+
contact
|
|
14
|
+
].join("\n\n")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def commands
|
|
9
20
|
commands = Gotsha::Actions.constants.map do |command|
|
|
10
21
|
name = command.downcase
|
|
11
22
|
description = Kernel.const_get("Gotsha::Actions::#{command}::DESCRIPTION")
|
|
12
23
|
|
|
13
|
-
"#{name} # #{description}"
|
|
24
|
+
"gotsha #{name} # #{description}"
|
|
14
25
|
end.sort.join("\n")
|
|
15
26
|
|
|
16
|
-
"Available commands: \n\n#{commands}"
|
|
27
|
+
"Available commands: \n\n#{commands}\n"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def config_file
|
|
31
|
+
[
|
|
32
|
+
"Config file:",
|
|
33
|
+
"How and when Gotsha runs tests is configured in `#{Config::CONFIG_FILE}` file, " \
|
|
34
|
+
"so it's the most important file to check and understand! Luckily, it's brief " \
|
|
35
|
+
"and contains explaining comments. If you deleted the comments it was originally " \
|
|
36
|
+
"generated with, or you're not sure how to set it, see " \
|
|
37
|
+
"https://github.com/melounvitek/gotsha/blob/master/lib/gotsha/templates/config.toml\n"
|
|
38
|
+
].join("\n\n")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def contact
|
|
42
|
+
[
|
|
43
|
+
"Contact:",
|
|
44
|
+
"Is something not clear? Did you find a bug? Would you use new feature? Let's talk! \n" \
|
|
45
|
+
"Freel free to email me (vitek@meloun.info), or create an issue (https://github.com/melounvitek/gotsha/issues/)"
|
|
46
|
+
]
|
|
17
47
|
end
|
|
18
48
|
end
|
|
19
49
|
end
|
data/lib/gotsha/actions/test.rb
CHANGED
|
@@ -26,7 +26,8 @@ module Gotsha
|
|
|
26
26
|
return if commands.any?
|
|
27
27
|
|
|
28
28
|
raise(Errors::HardFail,
|
|
29
|
-
"please, define some test commands in
|
|
29
|
+
"please, define some test commands in `#{Config::CONFIG_FILE}` " \
|
|
30
|
+
"(you can run `gotsha configure` to open it)")
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def run_commands!
|
data/lib/gotsha/bash_command.rb
CHANGED
|
@@ -1,32 +1,49 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "pty"
|
|
4
|
-
require "shellwords"
|
|
5
4
|
|
|
6
5
|
module Gotsha
|
|
7
6
|
class BashCommand
|
|
8
7
|
FORCE_OUTPUT_AFTER = 5
|
|
8
|
+
MARKER = "__GOTSHA_EXIT__:"
|
|
9
9
|
|
|
10
|
+
# rubocop:disable Metrics/AbcSize
|
|
11
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
|
12
|
+
# rubocop:disable Metrics/MethodLength
|
|
10
13
|
def self.run!(command)
|
|
11
14
|
start_time = Time.now
|
|
12
15
|
UserConfig.get(:verbose) && puts(command)
|
|
13
16
|
|
|
14
17
|
stdout = +""
|
|
18
|
+
exit_code = nil
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
# This block is an ugly workaround to ensure the color output is stored both on Linux and Mac
|
|
21
|
+
PTY.spawn("bash", "-lc", "#{command}; printf \"\\n#{MARKER}%d\\n\" $?") do |r, _w, pid|
|
|
22
|
+
r.each do |line|
|
|
23
|
+
if line.start_with?(MARKER)
|
|
24
|
+
exit_code = line.sub(MARKER, "").to_i
|
|
25
|
+
next
|
|
26
|
+
end
|
|
27
|
+
puts line if UserConfig.get(:verbose) || Time.now - start_time > FORCE_OUTPUT_AFTER
|
|
22
28
|
stdout << line
|
|
23
29
|
end
|
|
30
|
+
rescue Errno::EIO
|
|
31
|
+
# PTY closes when process ends — safe to ignore
|
|
24
32
|
ensure
|
|
25
|
-
|
|
33
|
+
Process.wait(pid)
|
|
26
34
|
end
|
|
27
35
|
|
|
36
|
+
final_code = exit_code || $CHILD_STATUS.exitstatus
|
|
37
|
+
status = Struct.new(:exitstatus) do
|
|
38
|
+
def success?
|
|
39
|
+
exitstatus.zero?
|
|
40
|
+
end
|
|
41
|
+
end.new(final_code)
|
|
28
42
|
new(stdout, status)
|
|
29
43
|
end
|
|
44
|
+
# rubocop:enable Metrics/AbcSize
|
|
45
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
|
46
|
+
# rubocop:enable Metrics/MethodLength
|
|
30
47
|
|
|
31
48
|
def self.silent_run!(command)
|
|
32
49
|
return run!(command) if UserConfig.get(:verbose)
|
data/lib/gotsha/version.rb
CHANGED
data/lib/gotsha.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "toml-rb"
|
|
|
5
5
|
|
|
6
6
|
require_relative "gotsha/action_dispatcher"
|
|
7
7
|
require_relative "gotsha/actions/commit"
|
|
8
|
+
require_relative "gotsha/actions/configure"
|
|
8
9
|
require_relative "gotsha/actions/help"
|
|
9
10
|
require_relative "gotsha/actions/init"
|
|
10
11
|
require_relative "gotsha/actions/show"
|
data/web/img/commit.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/web/img/push.png
ADDED
|
Binary file
|
data/web/index.html
CHANGED
|
@@ -109,15 +109,14 @@
|
|
|
109
109
|
<p>Gotsha is distrubuted as a Ruby gem, so you need to
|
|
110
110
|
have <strong>Ruby</strong> working in your system. Apart from that, the only
|
|
111
111
|
other dependency is <strong>Git</strong>.</p>
|
|
112
|
-
|
|
113
|
-
<pre><code># Install manually
|
|
112
|
+
<pre><code># Install manually; language agnostic
|
|
114
113
|
gem install gotsha
|
|
115
114
|
|
|
116
|
-
# Or via your Gemfile
|
|
115
|
+
# Or install via your Gemfile in Ruby projects
|
|
117
116
|
gem 'gotsha'
|
|
118
117
|
</code></pre>
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
<p>Then just go to your project folder, run <code>gotsha</code> command, and follow the prompts — Gotsha will guide you through the setup. It won't take more than 3 minutes!</p>
|
|
119
|
+
<p>If you got stuck somewhere, you can always use <code>gotsha help</code>.</p>
|
|
121
120
|
</section>
|
|
122
121
|
|
|
123
122
|
<section class="card">
|
|
@@ -125,6 +124,10 @@ gem 'gotsha'
|
|
|
125
124
|
<article>
|
|
126
125
|
<h3>1) Runs locally</h3>
|
|
127
126
|
<p>Gotsha runs the project test suite on your machine. This can happen automatically (for every Git commit or push), or manually; right before you ask for review. You can easily configure it whatever way suits your project best.</p>
|
|
127
|
+
<img
|
|
128
|
+
style="max-width: 100%; height: auto; display: block; margin: 15px auto;"
|
|
129
|
+
src="img/commit.png"
|
|
130
|
+
/>
|
|
128
131
|
</article>
|
|
129
132
|
<article>
|
|
130
133
|
<h3>2) Stores test results for commit SHA</h3>
|
|
@@ -133,13 +136,28 @@ gem 'gotsha'
|
|
|
133
136
|
<article>
|
|
134
137
|
<h3>3) Displays results in your GitHub PR</h3>
|
|
135
138
|
<p>Push as usual — the note follows your commit, and tiny Github Action instantly verifies it
|
|
136
|
-
and makes the tests result visible to reviewers.
|
|
139
|
+
and makes the tests result visible to reviewers.
|
|
140
|
+
<img
|
|
141
|
+
style="max-width: 100%; height: auto; display: block; margin: 15px auto;"
|
|
142
|
+
src="img/push.png"
|
|
143
|
+
/>
|
|
144
|
+
|
|
145
|
+
<img
|
|
146
|
+
style="max-width: 100%; height: auto; width: 71%; display: block; margin: 15px auto;"
|
|
147
|
+
src="img/gh_action.png"
|
|
148
|
+
/>
|
|
149
|
+
|
|
150
|
+
<img
|
|
151
|
+
style="max-width: 100%; height: auto; display: block; margin: 15px auto;"
|
|
152
|
+
src="img/commit_checked.png"
|
|
153
|
+
/>
|
|
137
154
|
</article>
|
|
138
155
|
</section>
|
|
139
156
|
|
|
140
157
|
|
|
141
158
|
<p class="foot">
|
|
142
159
|
© <span id="y"></span> <a target="_blank" href="https://x.com/melounvitek">Vítek Meloun</a> (<a target="_blank" href="mailto:vitek@meloun.info">vitek@meloun.info</a>)
|
|
160
|
+
<script type="text/javascript" src="https://cdnjs.buymeacoffee.com/1.0.0/button.prod.min.js" data-name="bmc-button" data-slug="gotsha" data-color="#FFDD00" data-emoji="" data-font="Cookie" data-text="Buy me a coffee" data-outline-color="#000000" data-font-color="#000000" data-coffee-color="#ffffff" ></script>
|
|
143
161
|
</p>
|
|
144
162
|
</main>
|
|
145
163
|
</div>
|
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.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vitek Meloun
|
|
@@ -44,6 +44,7 @@ files:
|
|
|
44
44
|
- lib/gotsha.rb
|
|
45
45
|
- lib/gotsha/action_dispatcher.rb
|
|
46
46
|
- lib/gotsha/actions/commit.rb
|
|
47
|
+
- lib/gotsha/actions/configure.rb
|
|
47
48
|
- lib/gotsha/actions/help.rb
|
|
48
49
|
- lib/gotsha/actions/init.rb
|
|
49
50
|
- lib/gotsha/actions/show.rb
|
|
@@ -61,6 +62,10 @@ files:
|
|
|
61
62
|
- lib/gotsha/version.rb
|
|
62
63
|
- sig/gotsha.rbs
|
|
63
64
|
- web/favicon.ico
|
|
65
|
+
- web/img/commit.png
|
|
66
|
+
- web/img/commit_checked.png
|
|
67
|
+
- web/img/gh_action.png
|
|
68
|
+
- web/img/push.png
|
|
64
69
|
- web/index.html
|
|
65
70
|
- web/logo.png
|
|
66
71
|
homepage: https://www.gotsha.org/
|