gitti 0.4.0 → 0.4.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 +18 -2
- data/lib/gitti/git.rb +30 -5
- data/lib/gitti/project.rb +6 -0
- data/lib/gitti/version.rb +1 -1
- data/test/test_base.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22e1840beecff16feb5247fa52e7c6c5ce7deaa3
|
4
|
+
data.tar.gz: 70495a4374a990460a505c3b927f3501b91c74a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 196886378c5879ff3ac790e25e017cd0c48af5d8c15f2073f99b2d25caca2ec878e81a073da1ca2cbf4f2fd40e76317b7e01a2a7fb4268d325db4a36f1e58bad
|
7
|
+
data.tar.gz: b15e3d0bbcdfa562ee4ac600fd8b2acd6d72d52c331e124defe04d12cb5e944844f28ba042c3390f7de8cfa5aabea702f2cbce6ed4baacd9c058d60a28662281
|
data/README.md
CHANGED
@@ -25,10 +25,13 @@ Example:
|
|
25
25
|
###############
|
26
26
|
## "setup" starter git commands
|
27
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
|
28
31
|
Git.clone( "git@github.com:rubycoco/gitti.git" )
|
29
32
|
Git.clone( "git@github.com:rubycoco/gitti.git", "gitti-clone" )
|
30
33
|
|
31
|
-
Git.mirror( "
|
34
|
+
Git.mirror( "https://github.com/rubycoco/gitti.git" ) ## same as git clone --mirror
|
32
35
|
|
33
36
|
#################
|
34
37
|
## standard git commands
|
@@ -63,12 +66,14 @@ Git.check ## same as git fsck
|
|
63
66
|
Git.fsck ## alias for check
|
64
67
|
Git.checksum ## another alias for check
|
65
68
|
|
69
|
+
Git.master? ## on master branch
|
70
|
+
Git.main? ## on main branch
|
71
|
+
|
66
72
|
Git.origin ## same as git remote show origin
|
67
73
|
Git.upstream ## same as git remote show upstream
|
68
74
|
Git.origin?
|
69
75
|
Git.upstream?
|
70
76
|
|
71
|
-
|
72
77
|
Git.config( "user.name" ) ## use --get option
|
73
78
|
Git.config( "user.name", show_origin: true ) ## add --show-origin flag
|
74
79
|
Git.config( "user.name", show_scope: true ) ## add --show-scope flag
|
@@ -107,6 +112,9 @@ GitProject.open( "rubycoco/gitti" ) do |proj|
|
|
107
112
|
|
108
113
|
proj.files
|
109
114
|
|
115
|
+
proj.master?
|
116
|
+
proj.main?
|
117
|
+
|
110
118
|
proj.origin
|
111
119
|
proj.upstream
|
112
120
|
proj.origin?
|
@@ -131,6 +139,14 @@ end
|
|
131
139
|
That's it for now.
|
132
140
|
|
133
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
|
+
|
134
150
|
## Installation
|
135
151
|
|
136
152
|
Use
|
data/lib/gitti/git.rb
CHANGED
@@ -16,9 +16,10 @@ class Git ## make Git a module - why? why not?
|
|
16
16
|
###############
|
17
17
|
## "setup" starter git commands
|
18
18
|
|
19
|
-
def self.clone( repo, name=nil )
|
19
|
+
def self.clone( repo, name=nil, depth: nil )
|
20
20
|
cmd = "git clone #{repo}"
|
21
|
-
cmd << " #{name}"
|
21
|
+
cmd << " #{name}" unless name.nil? || name.empty?
|
22
|
+
cmd << " --depth #{depth}" unless depth.nil?
|
22
23
|
Shell.run( cmd )
|
23
24
|
end
|
24
25
|
|
@@ -194,6 +195,21 @@ class Git ## make Git a module - why? why not?
|
|
194
195
|
end
|
195
196
|
|
196
197
|
|
198
|
+
def self.branch
|
199
|
+
cmd = 'git branch'
|
200
|
+
Shell.run( cmd )
|
201
|
+
end
|
202
|
+
|
203
|
+
def self.master?
|
204
|
+
output = branch ## check for '* master'
|
205
|
+
output.split( /\r?\n/ ).include?( '* master' )
|
206
|
+
end
|
207
|
+
|
208
|
+
def self.main?
|
209
|
+
output = branch ## check for '* main'
|
210
|
+
output.split( /\r?\n/ ).include?('* main')
|
211
|
+
end
|
212
|
+
|
197
213
|
## git remote update will update all of your branches
|
198
214
|
## set to track remote ones, but not merge any changes in.
|
199
215
|
##
|
@@ -214,6 +230,7 @@ class Git ## make Git a module - why? why not?
|
|
214
230
|
Shell.run( cmd )
|
215
231
|
end
|
216
232
|
|
233
|
+
|
217
234
|
def self.origin ## e.g. git remote show origin
|
218
235
|
cmd = "git remote show origin"
|
219
236
|
Shell.run( cmd )
|
@@ -224,15 +241,23 @@ class Git ## make Git a module - why? why not?
|
|
224
241
|
Shell.run( cmd )
|
225
242
|
end
|
226
243
|
|
244
|
+
def self.remote
|
245
|
+
cmd = "git remote"
|
246
|
+
Shell.run( cmd )
|
247
|
+
end
|
248
|
+
|
227
249
|
def self.origin?
|
228
|
-
|
250
|
+
output = remote ## check for 'origin'
|
251
|
+
output.split( /\r?\n/ ).include?( 'origin' )
|
229
252
|
end
|
230
253
|
|
231
254
|
def self.upstream?
|
232
|
-
|
255
|
+
output = remote ## check for 'upstream'
|
256
|
+
output.split( /\r?\n/ ).include?( 'upstream' )
|
233
257
|
end
|
234
258
|
|
235
259
|
|
260
|
+
|
236
261
|
def self.check ## e.g. git fsck - check/validate hash of objects
|
237
262
|
cmd = "git fsck"
|
238
263
|
Shell.run( cmd )
|
@@ -266,7 +291,7 @@ def self.run( cmd )
|
|
266
291
|
unless stderr.empty?
|
267
292
|
## todo/check: or use >2: or &2: or such
|
268
293
|
## stderr output not always an error (that is, exit status might be 0)
|
269
|
-
puts "
|
294
|
+
puts "2>"
|
270
295
|
puts stderr
|
271
296
|
end
|
272
297
|
|
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
@@ -8,7 +8,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
10
|
MINOR = 4
|
11
|
-
PATCH =
|
11
|
+
PATCH = 1
|
12
12
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
13
13
|
|
14
14
|
def self.version
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.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-09-
|
11
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|