git.rb 0.10.1 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 908407ea9ebf4972a435d8bbdfec53c677b5ac9497adf4575bc650413ef3a7a7
4
- data.tar.gz: b196e6a46285002e2a4adf2b0e8d1db128c8ce7fee417bb10438eaf7ba909737
3
+ metadata.gz: 73aee3654b476be49b07919f42351e4a215eed644ca265e430fa9ae5bb342602
4
+ data.tar.gz: 5a1d9932d003433378f7e2ca9c3110e1417b0e4758aea2756117e8ad76d8f3d2
5
5
  SHA512:
6
- metadata.gz: c1ce1fd99b757a370dea97f0d8d006b555f9ba83e5bee4378d749afafb1e9584a20a6cb3a6a9d527feea3cc586000866c456b0289e7048764638fb262da6f26d
7
- data.tar.gz: cb8a814563968b969cd3a30b863d8d6a5b888699e539b677c0fc4bb883dd74c68385970cac62b1d63f0ff33fe587f38f58145f3c2c9edbddf6360b99be54bfd3
6
+ metadata.gz: c767573d7f5d0912231e6f8cbd7ac74d725fd4982494d1d2871eaba18b76bea7b4179684601550603f39b93817462184c32e4f22cba1f44b4494f7c1d20a9ea1
7
+ data.tar.gz: 84aa02f3100e0cf04e2321f323d5fb35f3cb848791e261382572ed56de93f0750bbfdfd980a9a4408395474e4699356ab24e79f657fcacb856b6a1d1dd136a97
data/lib/Git/Blame.rb CHANGED
@@ -117,8 +117,7 @@ module Git
117
117
  end
118
118
 
119
119
  def find(line_number)
120
- @line_number = line_number
121
- entries.detect{|entry| entry.line_number == @line_number}
120
+ entries.detect{|entry| entry.line_number == line_number}
122
121
  end
123
122
 
124
123
  end
data/lib/Git/Branch.rb CHANGED
@@ -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
data/lib/Git/Log.rb CHANGED
@@ -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
data/lib/Git/VERSION.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  module Git
2
- VERSION = '0.10.0'
2
+
3
+ VERSION = '0.13.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.1
4
+ version: 0.13.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-03-30 00:00:00.000000000 Z
11
+ date: 2021-07-02 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/String/capture.rb
29
30
  - lib/Thoran/Array/AllButFirst/all_but_first.rb
30
31
  - lib/Thoran/Array/AllButLast/all_but_last.rb
31
32
  - lib/Thoran/Array/FirstX/firstX.rb
32
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.3
55
+ signing_key:
54
56
  specification_version: 4
55
57
  summary: Do git stuff from Ruby.
56
58
  test_files: []