Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
2df3b310
Commit
2df3b310
authored
Sep 26, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename branches and tags Repo methods to branch_names and tag_names
parent
5cea3e57
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
app/roles/repository.rb
app/roles/repository.rb
+7
-7
spec/roles/repository_spec.rb
spec/roles/repository_spec.rb
+4
-4
No files found.
app/roles/repository.rb
View file @
2df3b310
...
...
@@ -46,18 +46,18 @@ module Repository
end
# Returns an Array of branch names
def
branches
def
branch
_nam
es
repo
.
branches
.
collect
(
&
:name
).
sort
end
# Returns an Array of tag names
def
tags
def
tag
_name
s
repo
.
tags
.
collect
(
&
:name
).
sort
.
reverse
end
# Returns an Array of branch and tag names
def
ref_names
[
branch
es
+
tag
s
].
flatten
[
branch
_names
+
tag_name
s
].
flatten
end
def
repo
...
...
@@ -112,12 +112,12 @@ module Repository
# - If two or more branches are present, returns the one that has a name
# matching root_ref (default_branch or 'master' if default_branch is nil)
def
discover_default_branch
if
branches
.
length
==
0
if
branch
_nam
es
.
length
==
0
nil
elsif
branches
.
length
==
1
branches
.
first
elsif
branch
_nam
es
.
length
==
1
branch
_nam
es
.
first
else
branches
.
select
{
|
v
|
v
==
root_ref
}.
first
branch
_nam
es
.
select
{
|
v
|
v
==
root_ref
}.
first
end
end
...
...
spec/roles/repository_spec.rb
View file @
2df3b310
...
...
@@ -25,23 +25,23 @@ describe Project, "Repository" do
let
(
:stable
)
{
'stable'
}
it
"returns 'master' when master exists"
do
project
.
should_receive
(
:branches
).
at_least
(
:once
).
and_return
([
stable
,
master
])
project
.
should_receive
(
:branch
_nam
es
).
at_least
(
:once
).
and_return
([
stable
,
master
])
project
.
discover_default_branch
.
should
==
'master'
end
it
"returns non-master when master exists but default branch is set to something else"
do
project
.
default_branch
=
'stable'
project
.
should_receive
(
:branches
).
at_least
(
:once
).
and_return
([
stable
,
master
])
project
.
should_receive
(
:branch
_nam
es
).
at_least
(
:once
).
and_return
([
stable
,
master
])
project
.
discover_default_branch
.
should
==
'stable'
end
it
"returns a non-master branch when only one exists"
do
project
.
should_receive
(
:branches
).
at_least
(
:once
).
and_return
([
stable
])
project
.
should_receive
(
:branch
_nam
es
).
at_least
(
:once
).
and_return
([
stable
])
project
.
discover_default_branch
.
should
==
'stable'
end
it
"returns nil when no branch exists"
do
project
.
should_receive
(
:branches
).
at_least
(
:once
).
and_return
([])
project
.
should_receive
(
:branch
_nam
es
).
at_least
(
:once
).
and_return
([])
project
.
discover_default_branch
.
should
be_nil
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment