Module: Bringit

Defined in:
lib/bringit/diff.rb,
lib/bringit.rb,
lib/bringit/ref.rb,
lib/bringit/tag.rb,
lib/bringit/blob.rb,
lib/bringit/hook.rb,
lib/bringit/tree.rb,
lib/bringit/util.rb,
lib/bringit/blame.rb,
lib/bringit/index.rb,
lib/bringit/popen.rb,
lib/bringit/branch.rb,
lib/bringit/commit.rb,
lib/bringit/cloning.rb,
lib/bringit/compare.rb,
lib/bringit/pulling.rb,
lib/bringit/version.rb,
lib/bringit/wrapper.rb,
lib/bringit/rev_list.rb,
lib/bringit/attributes.rb,
lib/bringit/committing.rb,
lib/bringit/repository.rb,
lib/bringit/path_helper.rb,
lib/bringit/blob_snippet.rb,
lib/bringit/commit_stats.rb,
lib/bringit/version_info.rb,
lib/bringit/diff_collection.rb,
lib/bringit/encoding_helper.rb,
lib/bringit/committing/merge.rb

Overview

Bringit::CommitStats counts the additions, deletions, and total changes in a commit.

Defined Under Namespace

Modules: Cloning, Committing, EncodingHelper, Popen, Pulling, Util Classes: Attributes, Blame, BlameLine, Blob, BlobSnippet, Branch, Commit, CommitStats, Compare, Diff, DiffCollection, Error, Hook, Index, InvalidRefName, PathHelper, Ref, Repository, RevList, Tag, Tree, VersionInfo, Wrapper

Constant Summary collapse

BLANK_SHA =
('0' * 40).freeze
TAG_REF_PREFIX =
"refs/tags/".freeze
BRANCH_REF_PREFIX =
"refs/heads/".freeze
VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.blank_ref?(ref) ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/bringit.rb', line 88

def blank_ref?(ref)
  ref == BLANK_SHA
end

.branch_name(ref) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/bringit.rb', line 52

def branch_name(ref)
  ref = ref.to_s
  if self.branch_ref?(ref)
    self.ref_name(ref)
  else
    nil
  end
end

.branch_ref?(ref) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/bringit.rb', line 84

def branch_ref?(ref)
  ref.start_with?(BRANCH_REF_PREFIX)
end

.committer_hash(email:, name:) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/bringit.rb', line 61

def committer_hash(email:, name:)
  return if email.nil? || name.nil?

  {
    email: email,
    name: name,
    time: Time.now
  }
end

.ref_name(ref) ⇒ Object



48
49
50
# File 'lib/bringit.rb', line 48

def ref_name(ref)
  ref.sub(/\Arefs\/(tags|heads)\//, '')
end

.tag_name(ref) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/bringit.rb', line 71

def tag_name(ref)
  ref = ref.to_s
  if self.tag_ref?(ref)
    self.ref_name(ref)
  else
    nil
  end
end

.tag_ref?(ref) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/bringit.rb', line 80

def tag_ref?(ref)
  ref.start_with?(TAG_REF_PREFIX)
end

.versionObject



92
93
94
# File 'lib/bringit.rb', line 92

def version
  Bringit::VersionInfo.parse(Bringit::Popen.popen(%W(git --version)).first)
end