gitti 0.4.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +166 -150
- data/Rakefile +3 -2
- data/lib/gitti/base.rb +60 -57
- data/lib/gitti/git.rb +31 -56
- data/lib/gitti/mirror.rb +33 -33
- data/lib/gitti/project.rb +6 -0
- data/lib/gitti/version.rb +3 -3
- data/test/test_base.rb +10 -0
- metadata +26 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af5dbeb98c92b61217e79f16a009baea537c068
|
4
|
+
data.tar.gz: '0378847df0d03662f0a7d89d25c51b01ff887ce7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a43608097a13b762821df5a576e8f8346cd684680b1494fce35e0d0b2f3f043ba6ef8e36b931f2eb447b526cab753b62287206eee984f6323c6ee33c0a96c00
|
7
|
+
data.tar.gz: 60aaf0d3ee8c9582ec276a65e700391e1b0f3ae388f2dd53143c30c322218e9c20bf94fa3ee0269952aca453388d0097b747ed33749e44d10a412e951b51a994
|
data/README.md
CHANGED
@@ -1,150 +1,166 @@
|
|
1
|
-
# gitti
|
2
|
-
|
3
|
-
gitti gem - (yet) another (lite) git command line helper / wrapper
|
4
|
-
|
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
|
-
* gem :: [rubygems.org/gems/gitti](https://rubygems.org/gems/gitti)
|
8
|
-
* rdoc :: [rubydoc.info/gems/gitti](http://rubydoc.info/gems/gitti)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
## Usage
|
13
|
-
|
14
|
-
`Git` • `GitProject` • `GitMirror`
|
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( "
|
29
|
-
Git.clone( "
|
30
|
-
|
31
|
-
Git.
|
32
|
-
|
33
|
-
|
34
|
-
##
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
Git.
|
40
|
-
|
41
|
-
|
42
|
-
## status
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
##
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
Git.
|
55
|
-
Git.
|
56
|
-
Git.
|
57
|
-
Git.
|
58
|
-
Git.
|
59
|
-
|
60
|
-
Git.
|
61
|
-
|
62
|
-
|
63
|
-
Git.
|
64
|
-
|
65
|
-
|
66
|
-
Git.
|
67
|
-
Git.
|
68
|
-
|
69
|
-
Git.
|
70
|
-
|
71
|
-
|
72
|
-
Git.
|
73
|
-
Git.
|
74
|
-
Git.
|
75
|
-
|
76
|
-
|
77
|
-
Git.config(
|
78
|
-
Git.config(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
proj.
|
96
|
-
|
97
|
-
proj.
|
98
|
-
proj.
|
99
|
-
proj.
|
100
|
-
proj.
|
101
|
-
|
102
|
-
proj.
|
103
|
-
|
104
|
-
proj.
|
105
|
-
proj.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
proj.
|
111
|
-
proj.
|
112
|
-
|
113
|
-
proj.
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
```
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
1
|
+
# gitti
|
2
|
+
|
3
|
+
gitti gem - (yet) another (lite) git command line helper / wrapper
|
4
|
+
|
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
|
+
* gem :: [rubygems.org/gems/gitti](https://rubygems.org/gems/gitti)
|
8
|
+
* rdoc :: [rubydoc.info/gems/gitti](http://rubydoc.info/gems/gitti)
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
`Git` • `GitProject` • `GitMirror`
|
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( "https://github.com/rubycoco/gitti.git" )
|
29
|
+
Git.clone( "https://github.com/rubycoco/gitti.git", "gitti-clone" )
|
30
|
+
# -or- -- if you have write / commit access use ssh
|
31
|
+
Git.clone( "git@github.com:rubycoco/gitti.git" )
|
32
|
+
Git.clone( "git@github.com:rubycoco/gitti.git", "gitti-clone" )
|
33
|
+
|
34
|
+
Git.mirror( "https://github.com/rubycoco/gitti.git" ) ## same as git clone --mirror
|
35
|
+
|
36
|
+
#################
|
37
|
+
## standard git commands
|
38
|
+
|
39
|
+
Git.version ## same as git --version
|
40
|
+
Git.status
|
41
|
+
Git.status( short: true ) ## same as Git.changes
|
42
|
+
Git.changes ## same as git status --short
|
43
|
+
|
44
|
+
#####################
|
45
|
+
## status helpers
|
46
|
+
|
47
|
+
Git.clean?
|
48
|
+
Git.changes?
|
49
|
+
Git.dirty? ## alias for changes?
|
50
|
+
|
51
|
+
#######
|
52
|
+
## more (major) git commands
|
53
|
+
|
54
|
+
Git.fetch
|
55
|
+
Git.pull
|
56
|
+
Git.fast_forward ## same as git pull --ff-only
|
57
|
+
Git.ff ## alias for fast_forward
|
58
|
+
Git.push
|
59
|
+
Git.add( "pathspec" )
|
60
|
+
Git.add_all ## same as git --all
|
61
|
+
Git.commit( "message" )
|
62
|
+
|
63
|
+
Git.files ## same as git ls-tree --full-tree --name-only -r HEAD
|
64
|
+
|
65
|
+
Git.check ## same as git fsck
|
66
|
+
Git.fsck ## alias for check
|
67
|
+
Git.checksum ## another alias for check
|
68
|
+
|
69
|
+
Git.master? ## on master branch
|
70
|
+
Git.main? ## on main branch
|
71
|
+
|
72
|
+
Git.origin ## same as git remote show origin
|
73
|
+
Git.upstream ## same as git remote show upstream
|
74
|
+
Git.origin?
|
75
|
+
Git.upstream?
|
76
|
+
|
77
|
+
Git.config( "user.name" ) ## use --get option
|
78
|
+
Git.config( "user.name", show_origin: true ) ## add --show-origin flag
|
79
|
+
Git.config( "user.name", show_scope: true ) ## add --show-scope flag
|
80
|
+
|
81
|
+
Git.config( /user/ ) ## use --get-regexp option
|
82
|
+
Git.config( /user/, show_origin: true ) ## add --show-origin flag
|
83
|
+
Git.config( /user/, show_scope: true ) ## add --show-scope flag
|
84
|
+
```
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
### `GitProject` Class
|
89
|
+
|
90
|
+
Use the `GitProject` class for existing git repo(sitories)
|
91
|
+
with workspace. Example:
|
92
|
+
|
93
|
+
``` ruby
|
94
|
+
GitProject.open( "rubycoco/gitti" ) do |proj|
|
95
|
+
proj.status
|
96
|
+
proj.status( short: true )
|
97
|
+
proj.changes
|
98
|
+
proj.clean?
|
99
|
+
proj.changes?
|
100
|
+
proj.dirty?
|
101
|
+
|
102
|
+
proj.fetch
|
103
|
+
proj.pull
|
104
|
+
proj.fast_forward
|
105
|
+
proj.ff
|
106
|
+
|
107
|
+
proj.push
|
108
|
+
|
109
|
+
proj.add( "pathspec" )
|
110
|
+
proj.add_all
|
111
|
+
proj.commit( "message" )
|
112
|
+
|
113
|
+
proj.files
|
114
|
+
|
115
|
+
proj.master?
|
116
|
+
proj.main?
|
117
|
+
|
118
|
+
proj.origin
|
119
|
+
proj.upstream
|
120
|
+
proj.origin?
|
121
|
+
proj.upstream?
|
122
|
+
end
|
123
|
+
```
|
124
|
+
|
125
|
+
|
126
|
+
### `GitMirror` Class
|
127
|
+
|
128
|
+
Use the `GitMirror` class for existing mirrored (bare) git repo(sitories)
|
129
|
+
without workspace. Example:
|
130
|
+
|
131
|
+
``` ruby
|
132
|
+
GitMirror.open( "rubycoco/gitti.git" ) do |mirror|
|
133
|
+
mirror.update # sames as git remote update
|
134
|
+
end
|
135
|
+
```
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
That's it for now.
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
## Real World Usage
|
144
|
+
|
145
|
+
The [`monos`](https://github.com/rubycoco/monos) gem incl. some monorepo / mono source tree tools and (startup) scripts
|
146
|
+
that let you run git commands on multiple repos.
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
## Installation
|
151
|
+
|
152
|
+
Use
|
153
|
+
|
154
|
+
gem install gitti
|
155
|
+
|
156
|
+
or add to your Gemfile
|
157
|
+
|
158
|
+
gem 'gitti'
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
## License
|
163
|
+
|
164
|
+
The `gitti` scripts are dedicated to the public domain.
|
165
|
+
Use it as you please with no restrictions whatsoever.
|
166
|
+
|
data/Rakefile
CHANGED
@@ -17,12 +17,13 @@ Hoe.spec 'gitti' do
|
|
17
17
|
self.readme_file = 'README.md'
|
18
18
|
self.history_file = 'CHANGELOG.md'
|
19
19
|
|
20
|
-
self.extra_deps = [
|
20
|
+
self.extra_deps = [
|
21
|
+
['shell-lite', '>= 0.0.1' ],
|
22
|
+
]
|
21
23
|
|
22
24
|
self.licenses = ['Public Domain']
|
23
25
|
|
24
26
|
self.spec_extras = {
|
25
27
|
required_ruby_version: '>= 2.2.2'
|
26
28
|
}
|
27
|
-
|
28
29
|
end
|
data/lib/gitti/base.rb
CHANGED
@@ -1,57 +1,60 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
require 'gitti/
|
19
|
-
require 'gitti/
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
1
|
+
require 'shell-lite' ## note: move shell execute for (re)use to its own (upstream) gem
|
2
|
+
|
3
|
+
module Gitti
|
4
|
+
Shell = Computer::Shell
|
5
|
+
ShellError = Computer::ShellError
|
6
|
+
GitError = Computer::ShellError ## raised if git exec returns with non-zero exit - just use ShellError - why? why not?
|
7
|
+
## raised by Git::Shell.run
|
8
|
+
## todo/check: use ShellError or RunError - why? why not?
|
9
|
+
## and make Git::Shell top-level e.g. Shell - why? why not?
|
10
|
+
|
11
|
+
## differentiate into/use
|
12
|
+
## GitShell.run/GitCmd.run() or such and Shell.run - why? why not?
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
# our own code
|
18
|
+
require 'gitti/version' # note: let version always go first
|
19
|
+
require 'gitti/git'
|
20
|
+
require 'gitti/project'
|
21
|
+
require 'gitti/mirror'
|
22
|
+
require 'gitti/reposet'
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
module Gitti
|
27
|
+
## todo: change to GitHubRepoRef or GitHubProject
|
28
|
+
## or Git::GitHub or Git::Source::GitHub or such - why? why not?
|
29
|
+
class GitHubRepo
|
30
|
+
attr_reader :owner, :name
|
31
|
+
|
32
|
+
def initialize( owner, name )
|
33
|
+
@owner = owner ## use/rename to login or something - why? why not??
|
34
|
+
@name = name # e.g. "rubylibs/webservice"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def ssh_clone_url
|
39
|
+
## check: use https: as default? for github - http:// still supported? or redirected?
|
40
|
+
## "http://github.com/#{@owner}/#{@name}"
|
41
|
+
"git@github.com:#{@owner}/#{@name}.git"
|
42
|
+
end
|
43
|
+
|
44
|
+
def http_clone_url ## use clone_url( http: true ) -- why? why not?
|
45
|
+
## note: https is default for github - http:// gets redirected to https://
|
46
|
+
"http://github.com/#{@owner}/#{@name}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def https_clone_url
|
50
|
+
"https://github.com/#{@owner}/#{@name}"
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
end ## class GitHubRepo
|
55
|
+
end ## module Gitti
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
# say hello
|
60
|
+
puts GittiCore.banner ## if defined?( $RUBYCOCO_DEBUG )
|
data/lib/gitti/git.rb
CHANGED
@@ -1,24 +1,18 @@
|
|
1
1
|
module Gitti
|
2
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
3
|
class Git ## make Git a module - why? why not?
|
11
4
|
|
12
5
|
###
|
13
6
|
## todo/fix: change opts=nil to *args or such - why? why not?
|
14
7
|
|
15
|
-
|
16
8
|
###############
|
17
9
|
## "setup" starter git commands
|
18
10
|
|
19
|
-
def self.clone( repo, name=nil )
|
20
|
-
cmd = "git clone
|
21
|
-
cmd << " #{
|
11
|
+
def self.clone( repo, name=nil, depth: nil )
|
12
|
+
cmd = "git clone"
|
13
|
+
cmd << " --depth #{depth}" unless depth.nil?
|
14
|
+
cmd << " #{repo}"
|
15
|
+
cmd << " #{name}" unless name.nil? || name.empty?
|
22
16
|
Shell.run( cmd )
|
23
17
|
end
|
24
18
|
|
@@ -194,6 +188,21 @@ class Git ## make Git a module - why? why not?
|
|
194
188
|
end
|
195
189
|
|
196
190
|
|
191
|
+
def self.branch
|
192
|
+
cmd = 'git branch'
|
193
|
+
Shell.run( cmd )
|
194
|
+
end
|
195
|
+
|
196
|
+
def self.master?
|
197
|
+
output = branch ## check for '* master'
|
198
|
+
output.split( /\r?\n/ ).include?( '* master' )
|
199
|
+
end
|
200
|
+
|
201
|
+
def self.main?
|
202
|
+
output = branch ## check for '* main'
|
203
|
+
output.split( /\r?\n/ ).include?('* main')
|
204
|
+
end
|
205
|
+
|
197
206
|
## git remote update will update all of your branches
|
198
207
|
## set to track remote ones, but not merge any changes in.
|
199
208
|
##
|
@@ -214,6 +223,7 @@ class Git ## make Git a module - why? why not?
|
|
214
223
|
Shell.run( cmd )
|
215
224
|
end
|
216
225
|
|
226
|
+
|
217
227
|
def self.origin ## e.g. git remote show origin
|
218
228
|
cmd = "git remote show origin"
|
219
229
|
Shell.run( cmd )
|
@@ -224,15 +234,23 @@ class Git ## make Git a module - why? why not?
|
|
224
234
|
Shell.run( cmd )
|
225
235
|
end
|
226
236
|
|
237
|
+
def self.remote
|
238
|
+
cmd = "git remote"
|
239
|
+
Shell.run( cmd )
|
240
|
+
end
|
241
|
+
|
227
242
|
def self.origin?
|
228
|
-
|
243
|
+
output = remote ## check for 'origin'
|
244
|
+
output.split( /\r?\n/ ).include?( 'origin' )
|
229
245
|
end
|
230
246
|
|
231
247
|
def self.upstream?
|
232
|
-
|
248
|
+
output = remote ## check for 'upstream'
|
249
|
+
output.split( /\r?\n/ ).include?( 'upstream' )
|
233
250
|
end
|
234
251
|
|
235
252
|
|
253
|
+
|
236
254
|
def self.check ## e.g. git fsck - check/validate hash of objects
|
237
255
|
cmd = "git fsck"
|
238
256
|
Shell.run( cmd )
|
@@ -242,49 +260,6 @@ class Git ## make Git a module - why? why not?
|
|
242
260
|
alias_method :checksum, :check
|
243
261
|
end
|
244
262
|
|
245
|
-
|
246
|
-
|
247
|
-
###
|
248
|
-
# use nested class for "base" for running commands - why? why not?
|
249
|
-
class Shell
|
250
|
-
def self.run( cmd )
|
251
|
-
print "cmd exec >#{cmd}<..."
|
252
|
-
stdout, stderr, status = Open3.capture3( cmd )
|
253
|
-
|
254
|
-
if status.success?
|
255
|
-
print " OK"
|
256
|
-
print "\n"
|
257
|
-
else
|
258
|
-
print " FAIL (#{status.exitstatus})"
|
259
|
-
print "\n"
|
260
|
-
end
|
261
|
-
|
262
|
-
unless stdout.empty?
|
263
|
-
puts stdout
|
264
|
-
end
|
265
|
-
|
266
|
-
unless stderr.empty?
|
267
|
-
## todo/check: or use >2: or &2: or such
|
268
|
-
## stderr output not always an error (that is, exit status might be 0)
|
269
|
-
puts "STDERR:"
|
270
|
-
puts stderr
|
271
|
-
end
|
272
|
-
|
273
|
-
if status.success?
|
274
|
-
stdout # return stdout string
|
275
|
-
else
|
276
|
-
puts "!! ERROR: cmd exec >#{cmd}< failed with exit status #{status.exitstatus}:"
|
277
|
-
puts stderr
|
278
|
-
|
279
|
-
### todo/fix: do NOT use GitError here!!! make it more "general"
|
280
|
-
### use a Git::Shell.run() wrapper or such - why? why not?
|
281
|
-
## or use a Shell.git() or Shell.git_run() ???
|
282
|
-
## or pass in error class - why? why not?
|
283
|
-
raise GitError, "cmd exec >#{cmd}< failed with exit status #{status.exitstatus}<: #{stderr}"
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end # class Git::Shell
|
287
|
-
|
288
263
|
end # class Git
|
289
264
|
|
290
265
|
end # module Gitti
|
data/lib/gitti/mirror.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
module Gitti
|
2
|
-
|
3
|
-
class GitMirror
|
4
|
-
def self.open( path, &blk )
|
5
|
-
new( path ).open( &blk )
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.update( path ) ### all-in-one convenience shortcut
|
9
|
-
new( path).open { |mirror| mirror.update }
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def initialize( path )
|
15
|
-
raise ArgumentError, "dir >#{path}< not found; dir MUST already exist for GitMirror class - sorry" unless Dir.exist?( path )
|
16
|
-
## todo/check: check for more dirs and files e.g.
|
17
|
-
## /info,/objects,/refs, /hooks, HEAD, config, description -- why? why not?
|
18
|
-
raise ArgumentError, "dir >#{path}/objects< not found; dir MUST already be initialized with git for GitMirror class - sorry" unless Dir.exist?( "#{path}/objects" )
|
19
|
-
@path = path
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
def open( &blk )
|
24
|
-
Dir.chdir( @path ) do
|
25
|
-
blk.call( self )
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def update() Git.update; end
|
30
|
-
|
31
|
-
end # class GitMirror
|
32
|
-
end # module Gitti
|
33
|
-
|
1
|
+
module Gitti
|
2
|
+
|
3
|
+
class GitMirror
|
4
|
+
def self.open( path, &blk )
|
5
|
+
new( path ).open( &blk )
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.update( path ) ### all-in-one convenience shortcut
|
9
|
+
new( path).open { |mirror| mirror.update }
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
def initialize( path )
|
15
|
+
raise ArgumentError, "dir >#{path}< not found; dir MUST already exist for GitMirror class - sorry" unless Dir.exist?( path )
|
16
|
+
## todo/check: check for more dirs and files e.g.
|
17
|
+
## /info,/objects,/refs, /hooks, HEAD, config, description -- why? why not?
|
18
|
+
raise ArgumentError, "dir >#{path}/objects< not found; dir MUST already be initialized with git for GitMirror class - sorry" unless Dir.exist?( "#{path}/objects" )
|
19
|
+
@path = path
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def open( &blk )
|
24
|
+
Dir.chdir( @path ) do
|
25
|
+
blk.call( self )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def update() Git.update; end
|
30
|
+
|
31
|
+
end # class GitMirror
|
32
|
+
end # module Gitti
|
33
|
+
|
data/lib/gitti/project.rb
CHANGED
@@ -43,11 +43,17 @@ class GitProject
|
|
43
43
|
|
44
44
|
|
45
45
|
### remote show origin|upstream|etc.
|
46
|
+
def remote() Git.remote; end
|
46
47
|
def origin() Git.origin; end
|
47
48
|
def upstream() Git.upstream; end
|
48
49
|
def origin?() Git.origin?; end
|
49
50
|
def upstream?() Git.upstream?; end
|
50
51
|
|
52
|
+
### branch management
|
53
|
+
def branch() Git.branch; end
|
54
|
+
def master?() Git.master?; end
|
55
|
+
def main?() Git.main?; end
|
56
|
+
|
51
57
|
|
52
58
|
def run( cmd ) Git::Shell.run( cmd ); end
|
53
59
|
end # class GitProject
|
data/lib/gitti/version.rb
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
|
8
8
|
module GittiCore ## todo/check: rename GittiBase or GittiMeta or such - why? why not?
|
9
9
|
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
10
|
-
MINOR =
|
11
|
-
PATCH =
|
10
|
+
MINOR = 6
|
11
|
+
PATCH = 1
|
12
12
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
13
13
|
|
14
14
|
def self.version
|
@@ -20,7 +20,7 @@ module GittiCore ## todo/check: rename GittiBase or GittiMeta or such - why?
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.root
|
23
|
-
|
23
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
|
24
24
|
end
|
25
25
|
end # module GittiCore
|
26
26
|
|
data/test/test_base.rb
CHANGED
@@ -6,6 +6,16 @@ require 'helper'
|
|
6
6
|
|
7
7
|
class TestBase < MiniTest::Test
|
8
8
|
|
9
|
+
def test_branch
|
10
|
+
Git.branch
|
11
|
+
assert_equal true, Git.master?
|
12
|
+
assert_equal false, Git.main?
|
13
|
+
|
14
|
+
Git.remote
|
15
|
+
assert_equal true, Git.origin?
|
16
|
+
assert_equal false, Git.upstream?
|
17
|
+
end
|
18
|
+
|
9
19
|
|
10
20
|
def test_git_config
|
11
21
|
puts "---"
|
metadata
CHANGED
@@ -1,43 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: shell-lite
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rdoc
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: '4.0'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '7'
|
20
37
|
type: :development
|
21
38
|
prerelease: false
|
22
39
|
version_requirements: !ruby/object:Gem::Requirement
|
23
40
|
requirements:
|
24
|
-
- - "
|
41
|
+
- - ">="
|
25
42
|
- !ruby/object:Gem::Version
|
26
43
|
version: '4.0'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '7'
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: hoe
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
30
50
|
requirements:
|
31
51
|
- - "~>"
|
32
52
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
53
|
+
version: '3.22'
|
34
54
|
type: :development
|
35
55
|
prerelease: false
|
36
56
|
version_requirements: !ruby/object:Gem::Requirement
|
37
57
|
requirements:
|
38
58
|
- - "~>"
|
39
59
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
60
|
+
version: '3.22'
|
41
61
|
description: gitti - (yet) another (lite) git command line helper / wrapper
|
42
62
|
email: ruby-talk@ruby-lang.org
|
43
63
|
executables: []
|