gitlab_git 7.2.23 → 7.2.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/gitlab_git/repository.rb +33 -13
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 526652cdb899fa7a93b738a96cdbaf3bd4253696
4
- data.tar.gz: 72c0a8515d8ff04ad5883a2df941d12f73e6042e
3
+ metadata.gz: 320a203e93a3ce0ad48aa4edec7afa9b72da8b99
4
+ data.tar.gz: cc651b333e40c5152e3e732bcb3bccbe267b012b
5
5
  SHA512:
6
- metadata.gz: 20e1b6d5258a55c78e9ba98f64dfb4c307aca056937f5c2f3b50a30cccedc85f9ded4c0f29186a7d9c1ef6936bbd59c63870abdc4b3c073175fd27312ba10e67
7
- data.tar.gz: d1abe2c401395bb8e05de03c1d681a5c7848d9fe1be9f1e1e06120c3977b17de7c99b2770fd7cb9e0e83bf965bdb3d4ea03fdccd6140c95020d37830d8f27dfb
6
+ metadata.gz: c3ee43227084d36f9cf9544ccbab03787e3f453341ee4af66bd71bce154fd238804501324ded8ea331a778a511ea8598ad6b047a9f8a270a130a739438fd8336
7
+ data.tar.gz: 67d85099411399ddad30d001d12704def155f08d716de240b3675e7aff08c5b59ace76bbe28100413a3b2c456c534c24a93ed285ed659bcf606a995bf0148663
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.2.23
1
+ 7.2.24
@@ -15,9 +15,6 @@ module Gitlab
15
15
  class InvalidBlobName < StandardError; end
16
16
  class InvalidRef < StandardError; end
17
17
 
18
- # Default branch in the repository
19
- attr_accessor :root_ref
20
-
21
18
  # Full path to repo
22
19
  attr_reader :path
23
20
 
@@ -32,7 +29,11 @@ module Gitlab
32
29
  def initialize(path)
33
30
  @path = path
34
31
  @name = path.split("/").last
35
- @root_ref = discover_default_branch
32
+ end
33
+
34
+ # Default branch in the repository
35
+ def root_ref
36
+ @root_ref ||= discover_default_branch
36
37
  end
37
38
 
38
39
  # Alias to old method for compatibility
@@ -63,6 +64,19 @@ module Gitlab
63
64
  end.compact.sort_by(&:name)
64
65
  end
65
66
 
67
+ # Returns the number of valid branches
68
+ def branch_count
69
+ rugged.branches.count do |ref|
70
+ begin
71
+ ref.name && ref.target # ensures the branch is valid
72
+
73
+ true
74
+ rescue Rugged::ReferenceError
75
+ false
76
+ end
77
+ end
78
+ end
79
+
66
80
  # Returns an Array of tag names
67
81
  def tag_names
68
82
  rugged.tags.map { |t| t.name }
@@ -119,16 +133,22 @@ module Gitlab
119
133
  # - If one branch is present, returns its name
120
134
  # - If two or more branches are present, returns current HEAD or master or first branch
121
135
  def discover_default_branch
122
- if branch_names.length == 0
123
- nil
124
- elsif branch_names.length == 1
125
- branch_names.first
126
- elsif rugged_head && branch_names.include?(Ref.extract_branch_name(rugged_head.name))
127
- Ref.extract_branch_name(rugged_head.name)
128
- elsif branch_names.include?("master")
129
- "master"
136
+ names = branch_names
137
+
138
+ return if names.empty?
139
+
140
+ return names[0] if names.length == 1
141
+
142
+ if rugged_head
143
+ extracted_name = Ref.extract_branch_name(rugged_head.name)
144
+
145
+ return extracted_name if names.include?(extracted_name)
146
+ end
147
+
148
+ if names.include?('master')
149
+ 'master'
130
150
  else
131
- branch_names.first
151
+ names[0]
132
152
  end
133
153
  end
134
154
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.23
4
+ version: 7.2.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Zaporozhets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github-linguist