gitti 0.2.1 → 0.3.0
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/{HISTORY.md → CHANGELOG.md} +0 -0
- data/Manifest.txt +6 -3
- data/README.md +103 -3
- data/Rakefile +4 -6
- data/lib/gitti.rb +29 -13
- data/lib/gitti/base.rb +220 -0
- data/lib/gitti/project.rb +48 -0
- data/lib/gitti/{support/reposet.rb → reposet.rb} +4 -5
- data/lib/gitti/version.rb +2 -3
- data/test/helper.rb +7 -0
- data/test/test_base.rb +34 -0
- metadata +14 -25
- data/lib/gitti/lib.rb +0 -118
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cedf4859bb7b5521d3680c64f310f0a3456d1fbb
|
4
|
+
data.tar.gz: 32e27bc777a0381db476082563b466d2438be218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b23e5ed7a99c1e632b0ccfecc7e9a3afc8aeee943884b72367e354e6829f2360cd3b8ba2f43e3bb8f54467fd262d72d7dcd54b26bfb29b647b7a9a93833c367
|
7
|
+
data.tar.gz: ba2a18948bf92d98d9c4a09396ee95dcd05da757a3ce65aa633438530a43cdc133784054e3755fa72168eaa06c652beedc1aabeb8de73affd6a20b6f4b9c2d12
|
data/{HISTORY.md → CHANGELOG.md}
RENAMED
File without changes
|
data/Manifest.txt
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
CHANGELOG.md
|
2
2
|
Manifest.txt
|
3
3
|
README.md
|
4
4
|
Rakefile
|
5
5
|
lib/gitti.rb
|
6
|
-
lib/gitti/
|
7
|
-
lib/gitti/
|
6
|
+
lib/gitti/base.rb
|
7
|
+
lib/gitti/project.rb
|
8
|
+
lib/gitti/reposet.rb
|
8
9
|
lib/gitti/version.rb
|
10
|
+
test/helper.rb
|
11
|
+
test/test_base.rb
|
data/README.md
CHANGED
@@ -2,15 +2,115 @@
|
|
2
2
|
|
3
3
|
gitti gem - (yet) another (lite) git command line wrapper / library
|
4
4
|
|
5
|
-
* home :: [github.com/
|
6
|
-
* bugs :: [github.com/
|
5
|
+
* home :: [github.com/rubycoco/gitti](https://github.com/rubycoco/gitti)
|
6
|
+
* bugs :: [github.com/rubycoco/gitti/issues](https://github.com/rubycoco/gitti/issues)
|
7
7
|
* gem :: [rubygems.org/gems/gitti](https://rubygems.org/gems/gitti)
|
8
8
|
* rdoc :: [rubydoc.info/gems/gitti](http://rubydoc.info/gems/gitti)
|
9
9
|
|
10
10
|
|
11
|
+
|
11
12
|
## Usage
|
12
13
|
|
13
|
-
|
14
|
+
`Git` • `GitProject`
|
15
|
+
|
16
|
+
|
17
|
+
### `Git` Class
|
18
|
+
|
19
|
+
Use the `Git` class for "low-level / to the metal" git commands
|
20
|
+
that run in your current working directory.
|
21
|
+
Example:
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
|
25
|
+
###############
|
26
|
+
## "setup" starter git commands
|
27
|
+
|
28
|
+
Git.clone( "git@github.com:rubycoco/gitti.git" )
|
29
|
+
Git.clone( "git@github.com:rubycoco/gitti.git", "gitti-clone" )
|
30
|
+
|
31
|
+
Git.mirror( "git@github.com:rubycoco/gitti.git" ) ## same as git clone --mirror
|
32
|
+
|
33
|
+
#################
|
34
|
+
## standard git commands
|
35
|
+
|
36
|
+
Git.version ## same as git --version
|
37
|
+
Git.status
|
38
|
+
Git.status( short: true ) ## same as Git.changes
|
39
|
+
Git.changes ## same as git status --short
|
40
|
+
|
41
|
+
#####################
|
42
|
+
## status helpers
|
43
|
+
|
44
|
+
Git.clean?
|
45
|
+
Git.changes?
|
46
|
+
Git.dirty? ## alias for changes?
|
47
|
+
|
48
|
+
#######
|
49
|
+
## more (major) git commands
|
50
|
+
|
51
|
+
Git.fetch
|
52
|
+
Git.pull
|
53
|
+
Git.fast_forward ## same as git pull --ff-only
|
54
|
+
Git.ff ## alias for fast_forward
|
55
|
+
Git.push
|
56
|
+
Git.add( "pathspec" )
|
57
|
+
Git.add_all ## same as git --all
|
58
|
+
Git.commit( "message" )
|
59
|
+
|
60
|
+
Git.files ## same as git ls-tree --full-tree --name-only -r HEAD
|
61
|
+
Git.config( "user.name" ) ## use --get option
|
62
|
+
Git.config( "user.name", show_origin: true ) ## add --show-origin flag
|
63
|
+
Git.config( "user.name", show_scope: true ) ## add --show-scope flag
|
64
|
+
|
65
|
+
Git.config( /user/ ) ## use --get-regexp option
|
66
|
+
Git.config( /user/, show_origin: true ) ## add --show-origin flag
|
67
|
+
Git.config( /user/, show_scope: true ) ## add --show-scope flag
|
68
|
+
```
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
### `GitProject` Class
|
73
|
+
|
74
|
+
Use the `GitProject` class for existing git repo(sitories)
|
75
|
+
with workspace. Example:
|
76
|
+
|
77
|
+
``` ruby
|
78
|
+
GitProject.open( "rubycoco/gitti" ) do |proj|
|
79
|
+
proj.status
|
80
|
+
proj.status( short: true )
|
81
|
+
proj.changes
|
82
|
+
proj.clean?
|
83
|
+
proj.changes?
|
84
|
+
proj.dirty?
|
85
|
+
|
86
|
+
proj.fetch
|
87
|
+
proj.pull
|
88
|
+
proj.fast_forward
|
89
|
+
proj.ff
|
90
|
+
|
91
|
+
proj.push
|
92
|
+
|
93
|
+
proj.add( "pathspec" )
|
94
|
+
proj.add_all
|
95
|
+
proj.commit( "message" )
|
96
|
+
|
97
|
+
proj.files
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
That's it for now.
|
102
|
+
|
103
|
+
|
104
|
+
## Installation
|
105
|
+
|
106
|
+
Use
|
107
|
+
|
108
|
+
gem install gitti
|
109
|
+
|
110
|
+
or add to your Gemfile
|
111
|
+
|
112
|
+
gem 'gitti'
|
113
|
+
|
14
114
|
|
15
115
|
|
16
116
|
## License
|
data/Rakefile
CHANGED
@@ -8,23 +8,21 @@ Hoe.spec 'gitti' do
|
|
8
8
|
self.summary = 'gitti - (yet) another (lite) git command line wrapper / library'
|
9
9
|
self.description = summary
|
10
10
|
|
11
|
-
self.urls =
|
11
|
+
self.urls = { home: 'https://github.com/rubycoco/gitti' }
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
14
|
self.email = 'ruby-talk@ruby-lang.org'
|
15
15
|
|
16
16
|
# switch extension to .markdown for gihub formatting
|
17
17
|
self.readme_file = 'README.md'
|
18
|
-
self.history_file = '
|
18
|
+
self.history_file = 'CHANGELOG.md'
|
19
19
|
|
20
|
-
self.extra_deps = [
|
21
|
-
['logutils' ],
|
22
|
-
]
|
20
|
+
self.extra_deps = []
|
23
21
|
|
24
22
|
self.licenses = ['Public Domain']
|
25
23
|
|
26
24
|
self.spec_extras = {
|
27
|
-
required_ruby_version: '>=
|
25
|
+
required_ruby_version: '>= 2.2.2'
|
28
26
|
}
|
29
27
|
|
30
28
|
end
|
data/lib/gitti.rb
CHANGED
@@ -1,28 +1,44 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'pp'
|
4
|
-
require '
|
5
|
-
require 'yaml'
|
2
|
+
require 'time'
|
6
3
|
require 'date' ## e.g. Date.today etc.
|
7
|
-
|
4
|
+
require 'yaml'
|
5
|
+
require 'json'
|
6
|
+
require 'uri'
|
8
7
|
require 'net/http'
|
9
8
|
require "net/https"
|
10
|
-
require '
|
11
|
-
|
9
|
+
require 'open3'
|
12
10
|
require 'fileutils' ## e.g. FileUtils.mkdir_p etc.
|
13
11
|
|
14
12
|
|
15
|
-
# 3rd party gems/libs
|
16
|
-
require 'logutils'
|
17
13
|
|
18
14
|
# our own code
|
19
15
|
require 'gitti/version' # note: let version always go first
|
20
|
-
require 'gitti/
|
16
|
+
require 'gitti/base'
|
17
|
+
require 'gitti/project'
|
18
|
+
require 'gitti/reposet'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
module Gitti
|
23
|
+
## todo: change to GitHubRepoRef or GitHubProject
|
24
|
+
## or Git::GitHub or Git::Source::GitHub or such - why? why not?
|
25
|
+
class GitHubRepo
|
26
|
+
attr_reader :owner, :name
|
27
|
+
|
28
|
+
def initialize( owner, name )
|
29
|
+
@owner = owner ## use/rename to login or something - why? why not??
|
30
|
+
@name = name # e.g. "rubylibs/webservice"
|
31
|
+
end
|
21
32
|
|
33
|
+
def ssh_clone_url
|
34
|
+
## check: use https: as default? for github - http:// still supported? or redirected?
|
35
|
+
## "http://github.com/#{@owner}/#{@name}"
|
36
|
+
"git@github.com:#{@owner}/#{@name}.git"
|
37
|
+
end
|
38
|
+
end ## class GitHubRepo
|
39
|
+
end ## module Gitti
|
22
40
|
|
23
|
-
## todo/check: move to its own gem e.g. gitti-support later - why? why not??
|
24
|
-
require 'gitti/support/reposet'
|
25
41
|
|
26
42
|
|
27
43
|
# say hello
|
28
|
-
puts Gitti.banner
|
44
|
+
puts Gitti.banner ## if defined?( $RUBYCOCO_DEBUG )
|
data/lib/gitti/base.rb
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
module Gitti
|
2
|
+
|
3
|
+
## raised by Git::Shell.run -- check if top-level ShellError alread exists?
|
4
|
+
## use ShellError or RunError - why? why not?
|
5
|
+
## and make Git::Shell top-level e.g. Shell - why? why not?
|
6
|
+
class GitError < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
class Git ## make Git a module - why? why not?
|
11
|
+
|
12
|
+
###
|
13
|
+
## todo/fix: change opts=nil to *args or such - why? why not?
|
14
|
+
|
15
|
+
|
16
|
+
###############
|
17
|
+
## "setup" starter git commands
|
18
|
+
|
19
|
+
def self.clone( repo, name=nil )
|
20
|
+
cmd = "git clone #{repo}"
|
21
|
+
cmd << " #{name}" unless name.nil? || name.empty?
|
22
|
+
Shell.run( cmd )
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.mirror( repo )
|
26
|
+
cmd = "git clone --mirror #{repo}"
|
27
|
+
Shell.run( cmd )
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
#################
|
32
|
+
## standard git commands
|
33
|
+
|
34
|
+
def self.version
|
35
|
+
cmd = 'git --version'
|
36
|
+
Shell.run( cmd )
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.status( short: false )
|
40
|
+
cmd = 'git status'
|
41
|
+
cmd << " --short" if short
|
42
|
+
Shell.run( cmd )
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.changes ## same as git status --short - keep shortcut / alias - why? why not?
|
46
|
+
## returns changed files - one per line or empty if no changes
|
47
|
+
cmd = 'git status --short'
|
48
|
+
Shell.run( cmd )
|
49
|
+
end
|
50
|
+
|
51
|
+
#####################
|
52
|
+
## status helpers
|
53
|
+
|
54
|
+
## git status --short returns empty stdout/list
|
55
|
+
def self.clean?() changes.empty?; end
|
56
|
+
|
57
|
+
def self.changes?() clean? == false; end ## reverse of clean?
|
58
|
+
class << self
|
59
|
+
alias_method :dirty?, :changes? ## add alias
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
#######
|
64
|
+
## more (major) git commands
|
65
|
+
|
66
|
+
def self.fetch
|
67
|
+
cmd = 'git fetch'
|
68
|
+
Shell.run( cmd )
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.pull
|
72
|
+
cmd = 'git pull'
|
73
|
+
Shell.run( cmd )
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.fast_forward
|
77
|
+
cmd = 'git pull --ff-only'
|
78
|
+
Shell.run( cmd )
|
79
|
+
end
|
80
|
+
class << self
|
81
|
+
alias_method :ff, :fast_forward ## add alias
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def self.push
|
86
|
+
cmd = 'git push'
|
87
|
+
Shell.run( cmd )
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.add( pathspec=nil ) ## e.g. git add . or git add *.rb or such
|
91
|
+
cmd = 'git add'
|
92
|
+
cmd << " #{pathspec}" unless pathspec.nil? || pathspec.empty?
|
93
|
+
Shell.run( cmd )
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.add_all
|
97
|
+
cmd = 'git add --all'
|
98
|
+
Shell.run( cmd )
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.commit( message )
|
102
|
+
### todo/check: make message.nil? an ArgumentError - why? why not?
|
103
|
+
### if message.nil? || message.empty?
|
104
|
+
|
105
|
+
cmd = 'git commit'
|
106
|
+
cmd << %Q{ -m "#{message}"}
|
107
|
+
|
108
|
+
Shell.run( cmd )
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
#############
|
113
|
+
# change git ls-files to git ls-tree ... - why? why not?
|
114
|
+
## - note: git ls-files will include stages files too
|
115
|
+
# not only committed ones!!!
|
116
|
+
#
|
117
|
+
# git ls-tree --full-tree --name-only -r HEAD
|
118
|
+
# 1) --full-tree makes the command run as if you were in the repo's root directory.
|
119
|
+
# 2) -r recurses into subdirectories. Combined with --full-tree, this gives you all committed, tracked files.
|
120
|
+
# 3) --name-only removes SHA / permission info for when you just want the file paths.
|
121
|
+
# 4) HEAD specifies which branch you want the list of tracked, committed files for.
|
122
|
+
# You could change this to master or any other branch name, but HEAD is the commit you have checked out right now.
|
123
|
+
#
|
124
|
+
# see https://stackoverflow.com/questions/15606955/how-can-i-make-git-show-a-list-of-the-files-that-are-being-tracked
|
125
|
+
#
|
126
|
+
# was:
|
127
|
+
|
128
|
+
def self.files ## was: e.g. git ls-files . or git ls-files *.rb or such
|
129
|
+
### todo/check: include --full-tree - why? why not?
|
130
|
+
## will ALWAYS list all files NOT depending on (current) working directory
|
131
|
+
|
132
|
+
cmd = 'git ls-tree --full-tree --name-only -r HEAD' # was: 'git ls-files'
|
133
|
+
Shell.run( cmd )
|
134
|
+
end
|
135
|
+
## add list_files or ls_files alias - why? why not?
|
136
|
+
|
137
|
+
|
138
|
+
########
|
139
|
+
## query git configuration helpers
|
140
|
+
def self.config( prop,
|
141
|
+
show_origin: false,
|
142
|
+
show_scope: false ) ## find a better name e.g. config_get? why? why not?
|
143
|
+
cmd = "git config"
|
144
|
+
cmd << " --show-origin" if show_origin
|
145
|
+
cmd << " --show-scope" if show_scope
|
146
|
+
|
147
|
+
if prop.is_a?( Regexp )
|
148
|
+
## note: use Regexp#source
|
149
|
+
## Returns the original string of the pattern.
|
150
|
+
## e.g. /ab+c/ix.source #=> "ab+c"
|
151
|
+
## Note that escape sequences are retained as is.
|
152
|
+
## /\x20\+/.source #=> "\\x20\\+"
|
153
|
+
cmd << " --get-regexp #{prop.source}"
|
154
|
+
else ## assume string
|
155
|
+
cmd << " --get #{prop}"
|
156
|
+
end
|
157
|
+
|
158
|
+
Shell.run( cmd )
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
### add more - why? why not?
|
163
|
+
##
|
164
|
+
## def remote_update( opts={} ) ## e.g. git remote update
|
165
|
+
## command "remote update"
|
166
|
+
## end
|
167
|
+
|
168
|
+
## todo/check: rename remote to shorthand/shortcut or something or to branch - why, why not??
|
169
|
+
## def remote_show( name='origin', opts={}) ## e.g. git remote show origin
|
170
|
+
## command "remote show #{name}"
|
171
|
+
## end
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
###
|
178
|
+
# use nested class for "base" for running commands - why? why not?
|
179
|
+
class Shell
|
180
|
+
def self.run( cmd )
|
181
|
+
print "cmd exec >#{cmd}<..."
|
182
|
+
stdout, stderr, status = Open3.capture3( cmd )
|
183
|
+
|
184
|
+
if status.success?
|
185
|
+
print " OK"
|
186
|
+
print "\n"
|
187
|
+
else
|
188
|
+
print " FAIL (#{status.exitstatus})"
|
189
|
+
print "\n"
|
190
|
+
end
|
191
|
+
|
192
|
+
unless stdout.empty?
|
193
|
+
puts stdout
|
194
|
+
end
|
195
|
+
|
196
|
+
unless stderr.empty?
|
197
|
+
## todo/check: or use >2: or &2: or such
|
198
|
+
## stderr output not always an error (that is, exit status might be 0)
|
199
|
+
puts "STDERR:"
|
200
|
+
puts stderr
|
201
|
+
end
|
202
|
+
|
203
|
+
if status.success?
|
204
|
+
stdout # return stdout string
|
205
|
+
else
|
206
|
+
puts "!! ERROR: cmd exec >#{cmd}< failed with exit status #{status.exitstatus}:"
|
207
|
+
puts stderr
|
208
|
+
|
209
|
+
### todo/fix: do NOT use GitError here!!! make it more "general"
|
210
|
+
### use a Git::Shell.run() wrapper or such - why? why not?
|
211
|
+
## or use a Shell.git() or Shell.git_run() ???
|
212
|
+
## or pass in error class - why? why not?
|
213
|
+
raise GitError, "cmd exec >#{cmd}< failed with exit status #{status.exitstatus}<: #{stderr}"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end # class Git::Shell
|
217
|
+
|
218
|
+
end # class Git
|
219
|
+
|
220
|
+
end # module Gitti
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Gitti
|
2
|
+
|
3
|
+
class GitProject
|
4
|
+
def self.open( path, &blk )
|
5
|
+
new( path ).open( &blk )
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize( path )
|
9
|
+
raise ArgumentError, "dir >#{path}< not found; dir MUST already exist for GitProject class - sorry" unless Dir.exist?( path )
|
10
|
+
raise ArgumentError, "dir >#{path}/.git< not found; dir MUST already be initialized with git for GitProject class - sorry" unless Dir.exist?( "#{path}/.git" )
|
11
|
+
@path = path
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def open( &blk )
|
16
|
+
## puts "Dir.getwd: #{Dir.getwd}"
|
17
|
+
Dir.chdir( @path ) do
|
18
|
+
blk.call( self )
|
19
|
+
end
|
20
|
+
## puts "Dir.getwd: #{Dir.getwd}"
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def status( short: false ) Git.status( short: short ); end
|
25
|
+
def changes() Git.changes; end
|
26
|
+
def clean?() Git.clean?; end
|
27
|
+
def changes?() Git.changes?; end
|
28
|
+
alias_method :dirty?, :changes?
|
29
|
+
|
30
|
+
|
31
|
+
def fetch() Git.fetch; end
|
32
|
+
def pull() Git.pull; end
|
33
|
+
def fast_forward() Git.fast_forward; end
|
34
|
+
alias_method :ff, :fast_forward
|
35
|
+
|
36
|
+
def push() Git.push; end
|
37
|
+
|
38
|
+
def add( pathspec ) Git.add( pathspec ); end
|
39
|
+
def add_all() Git.add_all; end
|
40
|
+
def commit( message ) Git.commit( message ); end
|
41
|
+
|
42
|
+
def files() Git.files; end
|
43
|
+
|
44
|
+
def run( cmd ) Git::Shell.run( cmd ); end
|
45
|
+
|
46
|
+
end # class GitProject
|
47
|
+
end # module Gitti
|
48
|
+
|
@@ -1,13 +1,12 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
|
3
2
|
module Gitti
|
4
3
|
|
5
4
|
|
6
5
|
class GitRepoSet ## todo: rename to Hash/Dict/List/Map or use GitHubRepoSet ??
|
7
6
|
|
8
|
-
def self.from_file( path )
|
7
|
+
def self.from_file( path ) ## todo/fix: change to self.read - why? why not?
|
9
8
|
hash = YAML.load_file( path )
|
10
|
-
|
9
|
+
new( hash )
|
11
10
|
end
|
12
11
|
|
13
12
|
|
@@ -22,7 +21,7 @@ def each
|
|
22
21
|
## mrhydescripts (3) => mrhydescripts
|
23
22
|
## footballjs (4) => footballjs
|
24
23
|
## etc.
|
25
|
-
|
24
|
+
|
26
25
|
key = key_with_counter.sub( /\s+\([0-9]+\)/, '' )
|
27
26
|
|
28
27
|
puts " -- #{key_with_counter} [#{key}] --"
|
@@ -30,7 +29,7 @@ def each
|
|
30
29
|
yield( key, values )
|
31
30
|
end
|
32
31
|
end
|
33
|
-
|
32
|
+
|
34
33
|
end ## class GitRepoSet
|
35
34
|
|
36
35
|
end ## module Gitti
|
data/lib/gitti/version.rb
CHANGED
data/test/helper.rb
ADDED
data/test/test_base.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
###
|
2
|
+
# to run use
|
3
|
+
# ruby -I ./lib -I ./test test/test_base.rb
|
4
|
+
|
5
|
+
require 'helper'
|
6
|
+
|
7
|
+
class TestBase < MiniTest::Test
|
8
|
+
|
9
|
+
include Gitti
|
10
|
+
|
11
|
+
def test_git_config
|
12
|
+
puts "---"
|
13
|
+
Git.config( 'user.name' )
|
14
|
+
Git.config( 'user.name', show_origin: true )
|
15
|
+
## Git.config( 'user.name', show_scope: true )
|
16
|
+
|
17
|
+
puts "---"
|
18
|
+
Git.config( /user/ ) ## note: pass in regex for regex match/search
|
19
|
+
Git.config( /user/, show_origin: true )
|
20
|
+
## Git.config( /user/, show_scope: true )
|
21
|
+
|
22
|
+
puts "---"
|
23
|
+
Git.config( /user\./ ) ## note: pass in regex for regex match/search
|
24
|
+
|
25
|
+
puts "---"
|
26
|
+
## note: if NOT found Git.config will exit(1) !!!
|
27
|
+
## Git.config( /proxy/, show_origin: true )
|
28
|
+
## Git.config( /http/, show_origin: true )
|
29
|
+
|
30
|
+
puts "---"
|
31
|
+
end
|
32
|
+
|
33
|
+
end # class TestBase
|
34
|
+
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: logutils
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rdoc
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,32 +30,35 @@ dependencies:
|
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
33
|
+
version: '3.16'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
40
|
+
version: '3.16'
|
55
41
|
description: gitti - (yet) another (lite) git command line wrapper / library
|
56
42
|
email: ruby-talk@ruby-lang.org
|
57
43
|
executables: []
|
58
44
|
extensions: []
|
59
45
|
extra_rdoc_files:
|
60
|
-
-
|
46
|
+
- CHANGELOG.md
|
61
47
|
- Manifest.txt
|
62
48
|
- README.md
|
63
49
|
files:
|
64
|
-
-
|
50
|
+
- CHANGELOG.md
|
65
51
|
- Manifest.txt
|
66
52
|
- README.md
|
67
53
|
- Rakefile
|
68
54
|
- lib/gitti.rb
|
69
|
-
- lib/gitti/
|
70
|
-
- lib/gitti/
|
55
|
+
- lib/gitti/base.rb
|
56
|
+
- lib/gitti/project.rb
|
57
|
+
- lib/gitti/reposet.rb
|
71
58
|
- lib/gitti/version.rb
|
72
|
-
|
59
|
+
- test/helper.rb
|
60
|
+
- test/test_base.rb
|
61
|
+
homepage: https://github.com/rubycoco/gitti
|
73
62
|
licenses:
|
74
63
|
- Public Domain
|
75
64
|
metadata: {}
|
@@ -83,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
72
|
requirements:
|
84
73
|
- - ">="
|
85
74
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
75
|
+
version: 2.2.2
|
87
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
77
|
requirements:
|
89
78
|
- - ">="
|
@@ -91,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
80
|
version: '0'
|
92
81
|
requirements: []
|
93
82
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.2
|
83
|
+
rubygems_version: 2.5.2
|
95
84
|
signing_key:
|
96
85
|
specification_version: 4
|
97
86
|
summary: gitti - (yet) another (lite) git command line wrapper / library
|
data/lib/gitti/lib.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Gitti
|
4
|
-
|
5
|
-
class GitError < StandardError
|
6
|
-
end
|
7
|
-
|
8
|
-
class GitLib
|
9
|
-
|
10
|
-
#######################
|
11
|
-
## "open" commands
|
12
|
-
|
13
|
-
def clone( repo, opts={} )
|
14
|
-
command "clone #{repo}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def mirror( repo, opts={} )
|
18
|
-
command "clone --mirror #{repo}"
|
19
|
-
end
|
20
|
-
|
21
|
-
#########################
|
22
|
-
## more commands
|
23
|
-
|
24
|
-
def status( opts={} ) ## e.g. git status
|
25
|
-
command "status"
|
26
|
-
end
|
27
|
-
|
28
|
-
def pull( opts={} ) ## e.g. git pull
|
29
|
-
command "pull"
|
30
|
-
end
|
31
|
-
|
32
|
-
def remote_update( opts={} ) ## e.g. git remote update
|
33
|
-
command "remote update"
|
34
|
-
end
|
35
|
-
|
36
|
-
## todo/check: rename remote to shorthand/shortcut or something or to branch - why, why not??
|
37
|
-
def remote_show( name='origin', opts={}) ## e.g. git remote show origin
|
38
|
-
command "remote show #{name}"
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
def add( pathspec='.', opts={} ) ## e.g. git add .
|
43
|
-
command "add #{pathspec}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def commit( message, opts={} ) ## e.g. git commit -m "up standings"
|
47
|
-
command "commit -m \"#{message}\""
|
48
|
-
end
|
49
|
-
|
50
|
-
def push( opts={} ) ## e.g. git push
|
51
|
-
command "push"
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
## todo/fix:
|
57
|
-
## add last_exit or something ?? why? why not??
|
58
|
-
|
59
|
-
def command( cmd )
|
60
|
-
## note: for now use Kernel#system for calling external git command
|
61
|
-
##
|
62
|
-
|
63
|
-
cmdline = "git #{cmd}"
|
64
|
-
puts " trying >#{cmdline}< in (#{Dir.pwd})..."
|
65
|
-
|
66
|
-
result = nil
|
67
|
-
result = system( cmdline )
|
68
|
-
|
69
|
-
pp result
|
70
|
-
|
71
|
-
# note: Kernel#system returns
|
72
|
-
# - true if the command gives zero exit status
|
73
|
-
# - false for non zero exit status
|
74
|
-
# - nil if command execution fails
|
75
|
-
# An error status is available in $?.
|
76
|
-
|
77
|
-
if result.nil?
|
78
|
-
puts "*** error was #{$?}"
|
79
|
-
fail "[Kernel.system] command execution failed >#{cmdline}< - #{$?}"
|
80
|
-
elsif result ## true => zero exit code (OK)
|
81
|
-
puts 'OK' ## zero exit; assume OK
|
82
|
-
true ## assume ok
|
83
|
-
else ## false => non-zero exit code (ERR/NOK)
|
84
|
-
puts "*** error: non-zero exit - #{$?} !!" ## non-zero exit (e.g. 1,2,3,etc.); assume error
|
85
|
-
|
86
|
-
## log error for now ???
|
87
|
-
# File.open( './errors.log', 'a' ) do |f|
|
88
|
-
# f.write "#{Time.now} -- repo #{@owner}/#{@name} - command execution failed - non-zero exit\n"
|
89
|
-
# end
|
90
|
-
raise GitError.new( "command execution failed >#{cmdline}< - non-zero exit (#{$?})" )
|
91
|
-
end
|
92
|
-
end # method command
|
93
|
-
end # class Lib
|
94
|
-
|
95
|
-
|
96
|
-
module Git
|
97
|
-
## todo/fix: use "shared" singelton lib - why? why not??
|
98
|
-
def self.clone( repo, opts={} ) GitLib.new.clone( repo, opts ); end
|
99
|
-
def self.mirror( repo, opts={} ) GitLib.new.mirror( repo, opts ); end
|
100
|
-
|
101
|
-
def self.pull( opts={} ) GitLib.new.pull( opts ); end
|
102
|
-
def self.remote_update( opts={} ) GitLib.new.remote_update( opts ); end
|
103
|
-
def self.remote_show( name='origin', opts={}) GitLib.new.remote_show( name, opts ); end
|
104
|
-
|
105
|
-
def self.status( opts={} ) GitLib.new.status( opts ); end
|
106
|
-
def self.pull( opts={} ) GitLib.new.pull( opts ); end
|
107
|
-
def self.add( pathspec='.', opts={} ) GitLib.new.add( pathspec, opts ); end
|
108
|
-
def self.commit( message, opts={} ) GitLib.new.commit( message, opts ); end
|
109
|
-
def self.push( opts={} ) GitLib.new.push( opts ); end
|
110
|
-
end # module Git
|
111
|
-
|
112
|
-
end # module Gitti
|
113
|
-
|
114
|
-
|
115
|
-
### convenience top level Git module - check if defined? make optional? why? why not??
|
116
|
-
## Git = Gitti::Git
|
117
|
-
|
118
|
-
# for now use include Gitti - why? why not??
|