gitti 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 651f519f3b5f3ecf8a13a5125554cac2d69790f6
4
- data.tar.gz: 7ae7285e8ac625336869c7d4de1d078c11c5ee6d
3
+ metadata.gz: 82d9e96c41bfe2c9fa31a16a4370dd7ed22fe77d
4
+ data.tar.gz: f9fcafde391fbba16b951a4858dda109898e41dd
5
5
  SHA512:
6
- metadata.gz: 7c002bac4f5622a3083b27fa2e29d69736821d14c7b521ecd1a00b06cd62d80cae762e853e96943baa242e77568043a356fecc8c036c8856f18c8eac42facf0c
7
- data.tar.gz: 694934d8ea8263d11b90f7a14a01f8f59d3d71a695b728ebd82927e66d554cf1e59195199af7c960e930cc9cb4d9ad4c3d93abec28df9fe1aca931304e1f4698
6
+ metadata.gz: 1691456f72d2502668611903944cc1540b48266f733ba29ff5994f681e7911382e8bea3b45d2e6061ef7cf570b56b78d0c3c39124ccde9e28b93ba2cfdcb33ad
7
+ data.tar.gz: 846f28155f8e0a36ff0e8064fff12389c6cfee5b5f13b69e454842a2554dc89cf72f38fd34e395a1094708018b240811420608112fe5fabc63495bc9e0c13ee9
data/README.md CHANGED
@@ -1,166 +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( "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
-
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
+ ['yorobot-shell', '>= 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
@@ -1,57 +1,60 @@
1
- require 'pp'
2
- require 'time'
3
- require 'date' ## e.g. Date.today etc.
4
- require 'yaml'
5
- require 'json'
6
- require 'uri'
7
- require 'net/http'
8
- require "net/https"
9
- require 'open3'
10
- require 'fileutils' ## e.g. FileUtils.mkdir_p etc.
11
-
12
-
13
-
14
- # our own code
15
- require 'gitti/version' # note: let version always go first
16
- require 'gitti/git'
17
- require 'gitti/project'
18
- require 'gitti/mirror'
19
- require 'gitti/reposet'
20
-
21
-
22
-
23
- module Gitti
24
- ## todo: change to GitHubRepoRef or GitHubProject
25
- ## or Git::GitHub or Git::Source::GitHub or such - why? why not?
26
- class GitHubRepo
27
- attr_reader :owner, :name
28
-
29
- def initialize( owner, name )
30
- @owner = owner ## use/rename to login or something - why? why not??
31
- @name = name # e.g. "rubylibs/webservice"
32
- end
33
-
34
-
35
- def ssh_clone_url
36
- ## check: use https: as default? for github - http:// still supported? or redirected?
37
- ## "http://github.com/#{@owner}/#{@name}"
38
- "git@github.com:#{@owner}/#{@name}.git"
39
- end
40
-
41
- def http_clone_url ## use clone_url( http: true ) -- why? why not?
42
- ## note: https is default for github - http:// gets redirected to https://
43
- "http://github.com/#{@owner}/#{@name}"
44
- end
45
-
46
- def https_clone_url
47
- "https://github.com/#{@owner}/#{@name}"
48
- end
49
-
50
-
51
- end ## class GitHubRepo
52
- end ## module Gitti
53
-
54
-
55
-
56
- # say hello
57
- puts GittiCore.banner ## if defined?( $RUBYCOCO_DEBUG )
1
+ require 'yorobot/shell' ## note: move shell execute for (re)use to its own (upstream) gem
2
+
3
+ module Gitti
4
+ Shell = Yorobot::Shell
5
+ ShellError = Yorobot::ShellError
6
+ GitError = Yorobot::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 )
@@ -1,18 +1,10 @@
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
 
@@ -268,49 +260,6 @@ class Git ## make Git a module - why? why not?
268
260
  alias_method :checksum, :check
269
261
  end
270
262
 
271
-
272
-
273
- ###
274
- # use nested class for "base" for running commands - why? why not?
275
- class Shell
276
- def self.run( cmd )
277
- print "cmd exec >#{cmd}<..."
278
- stdout, stderr, status = Open3.capture3( cmd )
279
-
280
- if status.success?
281
- print " OK"
282
- print "\n"
283
- else
284
- print " FAIL (#{status.exitstatus})"
285
- print "\n"
286
- end
287
-
288
- unless stdout.empty?
289
- puts stdout
290
- end
291
-
292
- unless stderr.empty?
293
- ## todo/check: or use >2: or &2: or such
294
- ## stderr output not always an error (that is, exit status might be 0)
295
- puts "2>"
296
- puts stderr
297
- end
298
-
299
- if status.success?
300
- stdout # return stdout string
301
- else
302
- puts "!! ERROR: cmd exec >#{cmd}< failed with exit status #{status.exitstatus}:"
303
- puts stderr
304
-
305
- ### todo/fix: do NOT use GitError here!!! make it more "general"
306
- ### use a Git::Shell.run() wrapper or such - why? why not?
307
- ## or use a Shell.git() or Shell.git_run() ???
308
- ## or pass in error class - why? why not?
309
- raise GitError, "cmd exec >#{cmd}< failed with exit status #{status.exitstatus}<: #{stderr}"
310
- end
311
- end
312
- end # class Git::Shell
313
-
314
263
  end # class Git
315
264
 
316
265
  end # module Gitti
@@ -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
+
@@ -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 = 4
11
- PATCH = 2
10
+ MINOR = 5
11
+ PATCH = 0
12
12
  VERSION = [MAJOR,MINOR,PATCH].join('.')
13
13
 
14
14
  def self.version
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.2
4
+ version: 0.5.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: 2020-09-21 00:00:00.000000000 Z
11
+ date: 2020-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yorobot-shell
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.16'
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.16'
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: []