nit 0.0.4 → 0.0.6
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 +5 -5
- data/CHANGES.md +7 -2
- data/Gemfile +1 -0
- data/bin/nit-client +3 -0
- data/bin/nit-server +38 -0
- data/lib/nit/command/commit.rb +2 -1
- data/lib/nit/command/status.rb +4 -1
- data/lib/nit/lines.rb +4 -3
- data/lib/nit/version.rb +1 -1
- data/nit.gemspec +8 -5
- data/test/commands_test.rb +15 -2
- data/test/dummies/git/hooks/applypatch-msg.sample +0 -0
- data/test/dummies/git/hooks/commit-msg.sample +0 -0
- data/test/dummies/git/hooks/post-update.sample +0 -0
- data/test/dummies/git/hooks/pre-applypatch.sample +0 -0
- data/test/dummies/git/hooks/pre-commit.sample +0 -0
- data/test/dummies/git/hooks/pre-rebase.sample +0 -0
- data/test/dummies/git/hooks/prepare-commit-msg.sample +0 -0
- data/test/dummies/git/hooks/update.sample +0 -0
- data/test/lines_test.rb +3 -3
- data/test/nit_test.rb +20 -3
- data/test/status_test.rb +9 -0
- data/test/test_helper.rb +25 -1
- metadata +44 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ed0ddde57650f01656e5feb9d67a49d9b2e4e4d50889d40a2b16ed3291031800
|
4
|
+
data.tar.gz: 7cc40e90614681a5d7abe8b94d1b95b8d4ad0c77d49f7ca2fdc79cbf1a5cb0c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffe6c0c65bc72cf07e08086becc781f7f659c78cda187eb7006a7766b69ad799f982fac9db2f57420f18460d010f71c25f9b40c2f42706ea1115a6243b25391e
|
7
|
+
data.tar.gz: 3bf54fe3597da8495056f7296947cbc33a1a63e7dd3e1f935e2e3ed8364e224a13256020072e7bd4822b22a0437d02fe8aaddc68f7486cda73221ff56e05af29
|
data/CHANGES.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
## 0.0.
|
1
|
+
## 0.0.6
|
2
|
+
|
3
|
+
* Allow Ruby 3.4.
|
2
4
|
|
3
5
|
|
6
|
+
## 0.0.5
|
7
|
+
|
8
|
+
* Make nit compatible with a git upgrade where the status command doesn't prepend lines with a hash (#) anymore (as seen in git 1.8.5.2).
|
4
9
|
|
5
10
|
## 0.0.4
|
6
11
|
|
@@ -10,4 +15,4 @@
|
|
10
15
|
## 0.0.3
|
11
16
|
|
12
17
|
* Some bug fixes.
|
13
|
-
* Allow passing arbitrary git arguments to all nit commands, like `nit commit -m "awesome work" abc"
|
18
|
+
* Allow passing arbitrary git arguments to all nit commands, like `nit commit -m "awesome work" abc"
|
data/Gemfile
CHANGED
data/bin/nit-client
ADDED
data/bin/nit-server
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# client:
|
4
|
+
# echo "bla and more" | netcat -U demo.socket
|
5
|
+
|
6
|
+
require "nit/app"
|
7
|
+
def run!(input)
|
8
|
+
foo = StringIO.new
|
9
|
+
$stdout = foo
|
10
|
+
|
11
|
+
Nit::App.start
|
12
|
+
|
13
|
+
$stdout.string
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
require 'socket'
|
19
|
+
|
20
|
+
socket_file_name = './demo.socket'
|
21
|
+
|
22
|
+
File.unlink socket_file_name
|
23
|
+
server = UNIXServer.new socket_file_name
|
24
|
+
|
25
|
+
loop do
|
26
|
+
client = server.accept
|
27
|
+
input = client.gets
|
28
|
+
|
29
|
+
argv = input.split(" ") # FIXME: this does not include +1 spaces.
|
30
|
+
ARGV = argv # FIXME: this sucks, it's the only interface for Thor. make input injectable for Nit::App
|
31
|
+
# FIXME: make App::run/start return outpub.
|
32
|
+
|
33
|
+
output = run!(input)
|
34
|
+
|
35
|
+
client.puts output
|
36
|
+
client.close
|
37
|
+
end
|
38
|
+
|
data/lib/nit/command/commit.rb
CHANGED
@@ -2,6 +2,7 @@ class Nit::Command
|
|
2
2
|
class Commit < Status
|
3
3
|
def process(state, indexes, args)
|
4
4
|
handle_m!(args)
|
5
|
+
pp state.files
|
5
6
|
system "git add #{state.files.list(indexes)} && git commit #{args.join(" ")}"
|
6
7
|
end
|
7
8
|
|
@@ -12,4 +13,4 @@ class Nit::Command
|
|
12
13
|
args[i+1] = "\"#{args[i+1]}\""
|
13
14
|
end
|
14
15
|
end
|
15
|
-
end
|
16
|
+
end
|
data/lib/nit/command/status.rb
CHANGED
@@ -40,6 +40,9 @@ module Nit
|
|
40
40
|
process_modified(i, file, ln)
|
41
41
|
elsif ln.match(screen.file_patterns[:new])
|
42
42
|
process_new(i, file, ln)
|
43
|
+
# elsif ln.match(screen.file_patterns[:deleted])
|
44
|
+
# raise
|
45
|
+
# process_deleted(i, file, ln)
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
@@ -87,4 +90,4 @@ module Nit
|
|
87
90
|
end
|
88
91
|
end
|
89
92
|
end
|
90
|
-
end
|
93
|
+
end
|
data/lib/nit/lines.rb
CHANGED
@@ -31,8 +31,9 @@ module Nit
|
|
31
31
|
#private
|
32
32
|
def file_patterns
|
33
33
|
{
|
34
|
-
modified:
|
35
|
-
new:
|
34
|
+
modified: /#?\tmodified:(.+)/,
|
35
|
+
new: /#?\t((?!modified:).+)/,
|
36
|
+
deleted: /#?\tdeleted:(.+)/,
|
36
37
|
}
|
37
38
|
end
|
38
39
|
end
|
@@ -60,4 +61,4 @@ module Nit
|
|
60
61
|
path.to_s
|
61
62
|
end
|
62
63
|
end
|
63
|
-
end
|
64
|
+
end
|
data/lib/nit/version.rb
CHANGED
data/nit.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'nit/version'
|
@@ -10,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
10
9
|
spec.email = ["apotonick@gmail.com"]
|
11
10
|
spec.description = %q{Improving your Git workflow since 2013.}
|
12
11
|
spec.summary = %q{Nit improves your git workflows.}
|
13
|
-
spec.homepage = "
|
12
|
+
spec.homepage = "https://github.com/apotonick/nit"
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
15
|
spec.files = `git ls-files`.split($/)
|
@@ -18,9 +17,13 @@ Gem::Specification.new do |spec|
|
|
18
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
|
-
spec.add_dependency "thor",
|
20
|
+
spec.add_dependency "thor", '>= 0.18.1'
|
22
21
|
|
23
|
-
|
22
|
+
# FIXME: this is for nit-server:
|
23
|
+
spec.add_dependency "mkfifo"
|
24
|
+
spec.add_dependency "ruby-fifo"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler"
|
24
27
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "minitest", "5.
|
28
|
+
spec.add_development_dependency "minitest", ">= 5.4.0"
|
26
29
|
end
|
data/test/commands_test.rb
CHANGED
@@ -28,7 +28,6 @@ class CommandsTest < MiniTest::Spec
|
|
28
28
|
|
29
29
|
describe "commit" do
|
30
30
|
let (:klass) { "Commit" }
|
31
|
-
let (:screen) { output }
|
32
31
|
|
33
32
|
it "also ignores files when commiting" do
|
34
33
|
config.ignored_files = ["new.rb", "brandnew.rb", "staged.rb"] # TODO: make this more generic.
|
@@ -41,6 +40,20 @@ class CommandsTest < MiniTest::Spec
|
|
41
40
|
it { cmd.call(["-m", "awesome work", "b"], output).must_equal "git add ../lib/new.rb && git commit -m \"awesome work\"" }
|
42
41
|
|
43
42
|
# TODO: test nit commit -a
|
43
|
+
|
44
|
+
it "allow co with a deleted file, so it gets {git rm}" do
|
45
|
+
output = <<-EOF
|
46
|
+
On branch master
|
47
|
+
Changes not staged for commit:
|
48
|
+
(use "git add/rm <file>..." to update what will be committed)
|
49
|
+
(use "git restore <file>..." to discard changes in working directory)
|
50
|
+
\tmodified: CHANGES.md
|
51
|
+
\tdeleted: bin/nit-client
|
52
|
+
\tmodified: bin/nit-server
|
53
|
+
EOF
|
54
|
+
|
55
|
+
assert_equal cmd.call(["ac"], output),%(git add CHANGES.md && git rm bin/nit-client && git commit )
|
56
|
+
end
|
44
57
|
end
|
45
58
|
end
|
46
59
|
|
@@ -52,4 +65,4 @@ class ArgsProcessorTest < MiniTest::Spec
|
|
52
65
|
it { subject.call(["-a"]).must_equal [[], ["-a"]] }
|
53
66
|
it { subject.call(["-a", "-m", '"message"', "abc"]).must_equal [["abc"], ["-a", "-m", '"message"']] }
|
54
67
|
it { subject.call(["-m", '"message"', "a", "b"]).must_equal [["a", "b"], ["-m", '"message"']] }
|
55
|
-
end
|
68
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/lines_test.rb
CHANGED
@@ -12,8 +12,8 @@ class LinesTest < StatusTest
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#to_s" do
|
15
|
-
let (:
|
16
|
-
it { Nit::Lines.new(
|
15
|
+
let (:out) { "1\n2" }
|
16
|
+
it { Nit::Lines.new(out).to_s.must_equal(out) }
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "Line" do
|
@@ -24,4 +24,4 @@ class LinesTest < StatusTest
|
|
24
24
|
it { subject.delete
|
25
25
|
lines.to_s.must_equal "rocks"}
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
data/test/nit_test.rb
CHANGED
@@ -25,6 +25,8 @@ class NitTest < MiniTest::Spec
|
|
25
25
|
`mkdir stage`
|
26
26
|
`cp -R git stage/.git`
|
27
27
|
`cp files/* stage/`
|
28
|
+
|
29
|
+
yield if block_given?
|
28
30
|
end
|
29
31
|
|
30
32
|
Dir.chdir "test/dummies/stage" do
|
@@ -42,14 +44,16 @@ end
|
|
42
44
|
class DynamicCommandTest < NitTest
|
43
45
|
it "evaluates indexes and invokes git command with it" do
|
44
46
|
# how to capture STDERR: https://www.ruby-forum.com/topic/1103519#982117
|
45
|
-
nit(" checkout e 2>&1")
|
47
|
+
assert_equal nit(" checkout e 2>&1"), "error: pathspec 'new.rb' did not match any file(s) known to git
|
48
|
+
|
49
|
+
"
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
53
|
class ArbitraryGitCommandsTest < NitTest
|
50
54
|
it { nit(" diff b").must_match "a\/staged.rb" }
|
51
55
|
|
52
|
-
it { nit(" diff --raw b").must_equal ":100644 100644 e69de29
|
56
|
+
it { nit(" diff --raw b").must_equal ":100644 100644 e69de29 0000000 M\tstaged.rb\n" }
|
53
57
|
|
54
58
|
# commit:
|
55
59
|
it "allows strings after -m" do # TODO: implement that for all commands?
|
@@ -58,6 +62,19 @@ class ArbitraryGitCommandsTest < NitTest
|
|
58
62
|
output.must_match "1 file changed" # TODO: check if correct file was commited.
|
59
63
|
end
|
60
64
|
|
65
|
+
# FIXME: with one changed, one new file!!!
|
66
|
+
it "what" do
|
67
|
+
output = nit(' ') do
|
68
|
+
`touch stage/new_file`
|
69
|
+
`cd stage && git add stage/new_file`
|
70
|
+
end
|
71
|
+
puts output
|
72
|
+
assert_equal output, "] fixing it\n"
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
61
78
|
# it "allows -m after file indices" do
|
62
79
|
# output = nit(' co ab -m add something 4 u')
|
63
80
|
# puts output
|
@@ -72,4 +89,4 @@ class NitWithCharIndexerTest < NitTest
|
|
72
89
|
out.must_match "a\/staged.rb"
|
73
90
|
out.must_match "a\/on_stage.rb"
|
74
91
|
end
|
75
|
-
end
|
92
|
+
end
|
data/test/status_test.rb
CHANGED
@@ -20,6 +20,15 @@ class StatusTest < MiniTest::Spec
|
|
20
20
|
console.must_match "[3] new.rb"
|
21
21
|
console.must_match "[5] db/migrate/"
|
22
22
|
end
|
23
|
+
|
24
|
+
it "processes `git status` without #" do
|
25
|
+
console = subject.call([], output)
|
26
|
+
console.must_match "modified: [0] on_stage.rb"
|
27
|
+
console.must_match "modified: [1] staged.rb"
|
28
|
+
console.must_match "[2] brandnew.rb"
|
29
|
+
console.must_match "[3] new.rb"
|
30
|
+
console.must_match "[5] db/migrate/"
|
31
|
+
end
|
23
32
|
end
|
24
33
|
|
25
34
|
describe "char indexing" do
|
data/test/test_helper.rb
CHANGED
@@ -21,4 +21,28 @@ MiniTest::Spec.class_eval do
|
|
21
21
|
no changes added to commit (use "git add" and/or "git commit -a")
|
22
22
|
EOF
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
|
+
let (:hashless_output) do <<-EOF
|
26
|
+
On branch master
|
27
|
+
Changes not staged for commit:
|
28
|
+
(use "git add <file>..." to update what will be committed)
|
29
|
+
(use "git checkout -- <file>..." to discard changes in working directory)
|
30
|
+
|
31
|
+
\tmodified: on_stage.rb
|
32
|
+
\tmodified: staged.rb
|
33
|
+
|
34
|
+
Untracked files:
|
35
|
+
(use "git add <file>..." to include in what will be committed)
|
36
|
+
|
37
|
+
\tbrandnew.rb
|
38
|
+
\tnew.rb
|
39
|
+
\t../lib/new.rb
|
40
|
+
\tdb/migrate/
|
41
|
+
no changes added to commit (use "git add" and/or "git commit -a")
|
42
|
+
EOF
|
43
|
+
end
|
44
|
+
|
45
|
+
def assert_equal(expected, asserted)
|
46
|
+
super(asserted, expected)
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.18.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.18.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mkfifo
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-fifo
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: bundler
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
|
-
- - "
|
59
|
+
- - ">="
|
32
60
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
61
|
+
version: '0'
|
34
62
|
type: :development
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
|
-
- - "
|
66
|
+
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rake
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +84,16 @@ dependencies:
|
|
56
84
|
name: minitest
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- -
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: 5.
|
89
|
+
version: 5.4.0
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- -
|
94
|
+
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: 5.
|
96
|
+
version: 5.4.0
|
69
97
|
description: Improving your Git workflow since 2013.
|
70
98
|
email:
|
71
99
|
- apotonick@gmail.com
|
@@ -82,6 +110,8 @@ files:
|
|
82
110
|
- Rakefile
|
83
111
|
- Thorfile
|
84
112
|
- bin/nit
|
113
|
+
- bin/nit-client
|
114
|
+
- bin/nit-server
|
85
115
|
- lib/nit.rb
|
86
116
|
- lib/nit/CHANGES.mk
|
87
117
|
- lib/nit/app.rb
|
@@ -132,7 +162,7 @@ files:
|
|
132
162
|
- test/nit_test.rb
|
133
163
|
- test/status_test.rb
|
134
164
|
- test/test_helper.rb
|
135
|
-
homepage:
|
165
|
+
homepage: https://github.com/apotonick/nit
|
136
166
|
licenses:
|
137
167
|
- MIT
|
138
168
|
metadata: {}
|
@@ -151,8 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
181
|
- !ruby/object:Gem::Version
|
152
182
|
version: '0'
|
153
183
|
requirements: []
|
154
|
-
|
155
|
-
rubygems_version: 2.2.1
|
184
|
+
rubygems_version: 3.2.3
|
156
185
|
signing_key:
|
157
186
|
specification_version: 4
|
158
187
|
summary: Nit improves your git workflows.
|