Module: Gollum::Git
- Defined in:
- lib/rjgit_adapter/git_layer_rjgit.rb
Defined Under Namespace
Classes: Actor, Blob, Commit, Diff, Git, Index, NoSuchShaFound, Ref, Repo, Tree
Constant Summary
collapse
- BACKUP_DEFAULT_REF =
'refs/heads/master'
Class Method Summary
collapse
Class Method Details
.canonicalize(ref) ⇒ Object
Don’t touch if ref is a SHA or Git::Ref, otherwise convert it to jgit canonical form
41
42
43
44
45
|
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 41
def self.canonicalize(ref)
return ref if ref.is_a?(String) and sha?(ref)
result = ref.is_a?(Gollum::Git::Ref) ? ref.name : ref
(result =~ /^refs\/heads\// || result.upcase == 'HEAD') ? result : "refs/heads/#{result}"
end
|
.decanonicalize(ref_name) ⇒ Object
47
48
49
50
|
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 47
def self.decanonicalize(ref_name)
match = /^refs\/heads\/(.*)/.match(ref_name)
match ? match[1] : nil
end
|
.default_ref_for_repo(repo) ⇒ Object
36
37
38
|
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 36
def self.default_ref_for_repo(repo)
self.head_ref_name(repo) || self.global_default_branch || BACKUP_DEFAULT_REF
end
|
.global_default_branch ⇒ Object
32
33
34
|
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 32
def self.global_default_branch
org.eclipse.jgit.util.SystemReader.getInstance().getUserConfig().getString(ConfigConstants::CONFIG_INIT_SECTION, nil, ConfigConstants::CONFIG_KEY_DEFAULT_BRANCH)
end
|
.head_ref_name(repo) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 22
def self.head_ref_name(repo)
r = RJGit.repository_type(repo)
begin
r.resolve('HEAD') ? r.getFullBranch : nil
rescue Java::OrgEclipseJgitApiErrors::RefNotFoundException
nil
end
end
|
.sha?(str) ⇒ Boolean
52
53
54
|
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 52
def self.sha?(str)
!!(str =~ /^[0-9a-f]{40}$/)
end
|