git.rb 0.10.0 → 0.12.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
  SHA256:
3
- metadata.gz: 52833f20baf0598073541425701ec14677832f98aa5a5f10d6b6fabb647c6b5e
4
- data.tar.gz: f579c6fcc86ad91fdb91983ab08c0acb2bdfe33f7c160693406daeccfc6a9b62
3
+ metadata.gz: 459398f5d902325a3770ac8c518c9a8013fcc1628cdd9b378928c511bc4ef60d
4
+ data.tar.gz: 8ca58382ad1011dad9a66e78cf4afefbc6ccc9ce4c7bf5b257d019a5a60a6f7e
5
5
  SHA512:
6
- metadata.gz: 8eec775af216cf3e2a1c3d87eb23763d74c7e7f2f6f29e764f5e70ba6880533ea7245f5d7722c980c082e24a4463eebf274d617af5ce62779b1ef940cf6d477d
7
- data.tar.gz: 74ccdf65e4842e68b17f5f9f64cb8c79eda27d5b4b12753ea5cc4965041e72a6e4d608387f02f390b7ffe9a594b46d9753f5c383cdc4093c9afd5985373d96b9
6
+ metadata.gz: 1c34905fa20b9f3c0ae51d5525afab7cc2714c7c4f68e89c3be1a8cd114b662b7564a31d1dbb511aa8f1c06b01a64602612c51a5d418764bb245a6830365b8db
7
+ data.tar.gz: 6022dd1235db64aef9b2a9d64775a3603c97fb7d73632b10836438c1f8bbc5064663bff882df1c6686d6ea0a335370a78ccc6e6377ed668213bb65ec85b75f0d
data/lib/Git.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # Git.rb
2
2
  # Git
3
3
 
4
- # 20200127, 0128, 0202, 0207, 0208
5
- # 0.10.0
4
+ # 20200330
5
+ # 0.10.1
6
6
 
7
7
  lib_dir = File.expand_path(File.join(__FILE__, '..'))
8
8
  $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
@@ -94,6 +94,10 @@ module Git
94
94
  end
95
95
  alias_method :head, :current
96
96
 
97
+ def default
98
+ `git rev-parse --abbrev-ref origin/HEAD`.strip.split('/').last
99
+ end
100
+
97
101
  end # class << self
98
102
 
99
103
  attr_accessor :name
@@ -18,6 +18,7 @@
18
18
  # => "thoran"
19
19
 
20
20
  require 'Ordinal/Array'
21
+ require 'String/capture'
21
22
 
22
23
  module Git
23
24
  class Log
@@ -26,23 +27,45 @@ module Git
26
27
 
27
28
  class << self
28
29
  def parse(commit_string)
29
- parsed_commit_string = commit_string.split("\n").collect{|line| line.strip}.select{|line| !line.empty?}
30
- Commit.new(
31
- hash: parsed_commit_string.first.gsub(/^commit /, ''),
32
- author: parsed_commit_string.second.gsub(/^Author: /, ''),
33
- date: parsed_commit_string.third.gsub(/^Date: /, ''),
34
- message: parsed_commit_string.fourth
35
- )
30
+ hash = merge = author = date = message = ''
31
+ commit_string.split("\n").each do |line|
32
+ case line.strip
33
+ when /^commit (\w+)/
34
+ hash = line.strip.capture(/^commit (\w+)/)
35
+ when /^Merge: /
36
+ merge = line.strip.gsub(/^Merge: /, '')
37
+ when /^Author: /
38
+ author = line.strip.gsub(/^Author: /, '')
39
+ when /^Date: /
40
+ date = line.strip.gsub(/^Date: /, '')
41
+ else
42
+ if line.strip.empty?
43
+ (message ||= '') << "\n\n"
44
+ else
45
+ (message ||= '') << line.lstrip
46
+ end
47
+ end
48
+ end
49
+ commit_args = {
50
+ hash: hash,
51
+ author: author,
52
+ date: date,
53
+ message: message.lstrip
54
+ }
55
+ commit_args.merge!(merge: merge)
56
+ Commit.new(commit_args)
36
57
  end
37
58
  end # class << self
38
59
 
39
60
  attr_reader :hash
61
+ attr_reader :merge
40
62
  attr_reader :author
41
63
  attr_reader :date
42
64
  attr_reader :message
43
65
 
44
66
  def initialize(values = {})
45
67
  @hash = values[:hash]
68
+ @merge = values[:merge]
46
69
  @author = values[:author]
47
70
  @date = values[:date]
48
71
  @message = values[:message]
@@ -60,7 +83,6 @@ module Git
60
83
  commit_log = Log.new
61
84
  commit_string = ''
62
85
  log_stream.each_line do |line|
63
- line.lstrip!
64
86
  if line =~ /^commit/ && !commit_string.empty?
65
87
  commit_log.prepend(Commit.parse(commit_string))
66
88
  commit_string = line
@@ -1,3 +1,5 @@
1
1
  module Git
2
- VERSION = '0.10.0'
2
+
3
+ VERSION = '0.12.0'
4
+
3
5
  end
@@ -0,0 +1,28 @@
1
+ # Thoran/String/Capture/capture.rb
2
+ # Thoran::String::Capture#capture
3
+
4
+ # 20161109
5
+ # 0.3.1
6
+
7
+ # Changes since 0.2:
8
+ # 1. + Thoran namespace.
9
+ # 0/1
10
+ # 2. Updated the MiniTest superclass only---no implementation changes.
11
+
12
+ module Thoran
13
+ module String
14
+ module Capture
15
+
16
+ def capture(regex)
17
+ if md = self.match(regex)
18
+ md[1]
19
+ else
20
+ nil
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
28
+ String.send(:include, Thoran::String::Capture)
@@ -0,0 +1,7 @@
1
+ # String/capture.rb
2
+ # String#capture
3
+
4
+ # 20201008
5
+ # 0.3.1 (The same version number as the current version of Thoran/String/Capture.)
6
+
7
+ require 'Thoran/String/Capture/capture'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-08 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Do stuff with git-blame, git-branch, git-log, and git-remote from Ruby.
14
14
  email: code@thoran.com
@@ -26,15 +26,17 @@ files:
26
26
  - lib/Git/VERSION.rb
27
27
  - lib/Ordinal.rb
28
28
  - lib/Ordinal/Array.rb
29
- - lib/Thoran/AllButFirst/all_but_first.rb
30
- - lib/Thoran/AllButLast/all_but_last.rb
31
- - lib/Thoran/FirstX/firstX.rb
32
- - lib/Thoran/LastX/lastX.rb
29
+ - lib/String/capture.rb
30
+ - lib/Thoran/Array/AllButFirst/all_but_first.rb
31
+ - lib/Thoran/Array/AllButLast/all_but_last.rb
32
+ - lib/Thoran/Array/FirstX/firstX.rb
33
+ - lib/Thoran/Array/LastX/lastX.rb
34
+ - lib/Thoran/String/Capture/capture.rb
33
35
  homepage: http://github.com/thoran/git.rb
34
36
  licenses:
35
37
  - MIT
36
38
  metadata: {}
37
- post_install_message:
39
+ post_install_message:
38
40
  rdoc_options: []
39
41
  require_paths:
40
42
  - lib
@@ -49,8 +51,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
51
  - !ruby/object:Gem::Version
50
52
  version: '0'
51
53
  requirements: []
52
- rubygems_version: 3.1.2
53
- signing_key:
54
+ rubygems_version: 3.2.0.rc.1
55
+ signing_key:
54
56
  specification_version: 4
55
57
  summary: Do git stuff from Ruby.
56
58
  test_files: []