git-improved 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/shared.rb ADDED
@@ -0,0 +1,96 @@
1
+ # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'tempfile'
5
+
6
+ require 'oktest'
7
+
8
+ require 'git-improved'
9
+ require 'benry/unixcommand'
10
+
11
+
12
+ Oktest.global_scope do
13
+ include Benry::UnixCommand
14
+
15
+
16
+ GitImproved::APP_CONFIG.app_command = "gi"
17
+
18
+
19
+ def main(*args, stdin: "", tty: false)
20
+ output, sout, serr, status = main!(*args, stdin: stdin, tty: tty)
21
+ ok {serr} == ""
22
+ ok {status} == 0
23
+ return output, sout
24
+ end
25
+
26
+ def main!(*args, stdin: "", tty: false)
27
+ status = sout = serr = nil
28
+ output = capture_subprocess do
29
+ sout, serr = capture_sio(stdin, tty: tty) do
30
+ status = GitImproved.main(args)
31
+ end
32
+ end
33
+ return output, sout, serr, status
34
+ end
35
+
36
+ def capture_subprocess(&block)
37
+ prev = $SUBPROCESS_OUTPUT
38
+ return Tempfile.open("capture.", nil) do |f|
39
+ $SUBPROCESS_OUTPUT = f
40
+ begin
41
+ yield
42
+ rescue => exc
43
+ raise
44
+ ensure
45
+ $SUBPROCESS_OUTPUT = prev
46
+ f.rewind()
47
+ output = f.read()
48
+ STDOUT.print output if exc
49
+ end
50
+ output
51
+ end
52
+ end
53
+
54
+ def unesc(str)
55
+ return str.gsub(/\e\[.*?m/, '')
56
+ end
57
+
58
+ def readfile(file)
59
+ return File.read(file, encoding: 'utf-8')
60
+ end
61
+
62
+ def writefile(file, content)
63
+ return File.write(file, content, encoding: 'utf-8')
64
+ end
65
+
66
+ def system!(*args)
67
+ system(*args, exception: true)
68
+ end
69
+
70
+ def rm_rf(dir)
71
+ echoback_off do
72
+ rm :rf, dir
73
+ end
74
+ end
75
+
76
+ def dryrun_mode(&block)
77
+ $DRYRUN_MODE = true
78
+ yield
79
+ ensure
80
+ $DRYRUN_MODE = false
81
+ end
82
+
83
+ def curr_branch()
84
+ return `git branch --show-current`.strip()
85
+ end
86
+
87
+ def _reset_all_commits()
88
+ system! "git reset -q --hard #{$initial_commit_id}"
89
+ end
90
+
91
+ def delete_all_branches_except_main()
92
+ branch_names = `git branch -l`.sub(/^\* .*\n/, '').sub(/^.*main\n/, '').split()
93
+ system! "git branch -D -q #{branch_names.join(' ')}"
94
+ end
95
+
96
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-improved
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kwatch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: benry-cmdapp
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: benry-unixcommand
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: oktest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ description: |
56
+ Git-Improved is a wrapper script for Git command.
57
+ It provides much better interface than Git.
58
+
59
+ See https://kwatch.github.io/git-improved/ for details.
60
+ email: kwatch@gmail.com
61
+ executables:
62
+ - gi
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - CHANGES.md
67
+ - MIT-LICENSE
68
+ - README.md
69
+ - bin/gi
70
+ - git-improved.gemspec
71
+ - lib/git-improved.rb
72
+ - test/action_test.rb
73
+ - test/shared.rb
74
+ homepage: https://kwatch.github.io/git-improved/
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '2.3'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 3.4.10
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Improved interface for Git command
97
+ test_files:
98
+ - test/action_test.rb