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
Tatuya Kamada
gitlab-ce
Commits
8adf6ba8
Commit
8adf6ba8
authored
Aug 09, 2015
by
Florent (HP)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add merged label on branches page
parent
cb6ad67f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
0 deletions
+37
-0
CHANGELOG
CHANGELOG
+1
-0
app/models/repository.rb
app/models/repository.rb
+11
-0
app/views/projects/branches/_branch.html.haml
app/views/projects/branches/_branch.html.haml
+5
-0
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+20
-0
No files found.
CHANGELOG
View file @
8adf6ba8
...
@@ -55,6 +55,7 @@ v 7.14.0 (unreleased)
...
@@ -55,6 +55,7 @@ v 7.14.0 (unreleased)
- Fix bug causing error when the target branch of a symbolic ref was deleted
- Fix bug causing error when the target branch of a symbolic ref was deleted
- Include branch/tag name in archive file and directory name
- Include branch/tag name in archive file and directory name
- Add dropzone upload progress
- Add dropzone upload progress
- Add a label for merged branches on branches page (Florent Baldino)
v 7.13.3
v 7.13.3
- Fix bug causing Bitbucket importer to crash when OAuth application had been removed.
- Fix bug causing Bitbucket importer to crash when OAuth application had been removed.
...
...
app/models/repository.rb
View file @
8adf6ba8
...
@@ -364,6 +364,17 @@ class Repository
...
@@ -364,6 +364,17 @@ class Repository
@root_ref
||=
raw_repository
.
root_ref
@root_ref
||=
raw_repository
.
root_ref
end
end
def
merged_to_root_ref?
(
branch_name
)
branch_commit
=
commit
(
branch_name
)
root_ref_commit
=
commit
(
root_ref
)
if
branch_commit
rugged
.
merge_base
(
root_ref_commit
.
id
,
branch_commit
.
id
)
==
branch_commit
.
id
else
nil
end
end
def
search_files
(
query
,
ref
)
def
search_files
(
query
,
ref
)
offset
=
2
offset
=
2
args
=
%W(git grep -i -n --before-context
#{
offset
}
--after-context
#{
offset
}
#{
query
}
#{
ref
||
root_ref
}
)
args
=
%W(git grep -i -n --before-context
#{
offset
}
--after-context
#{
offset
}
#{
query
}
#{
ref
||
root_ref
}
)
...
...
app/views/projects/branches/_branch.html.haml
View file @
8adf6ba8
...
@@ -5,6 +5,11 @@
...
@@ -5,6 +5,11 @@
%strong
.str-truncated
=
branch
.
name
%strong
.str-truncated
=
branch
.
name
-
if
branch
.
name
==
@repository
.
root_ref
-
if
branch
.
name
==
@repository
.
root_ref
%span
.label.label-info
default
%span
.label.label-info
default
-
elsif
@repository
.
merged_to_root_ref?
branch
.
name
%span
.label.label-primary.has_tooltip
(
title=
"Merged into #{@repository.root_ref}"
)
%i
.fa.fa-check
merged
-
if
@project
.
protected_branch?
branch
.
name
-
if
@project
.
protected_branch?
branch
.
name
%span
.label.label-success
%span
.label.label-success
%i
.fa.fa-lock
%i
.fa.fa-lock
...
...
spec/models/repository_spec.rb
View file @
8adf6ba8
...
@@ -34,6 +34,26 @@ describe Repository do
...
@@ -34,6 +34,26 @@ describe Repository do
end
end
end
end
describe
:merged_to_root_ref?
do
context
'merged branch'
do
subject
{
repository
.
merged_to_root_ref?
(
'improve/awesome'
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
'non merged branch'
do
subject
{
repository
.
merged_to_root_ref?
(
'fix'
)
}
it
{
is_expected
.
to
be_falsey
}
end
context
'non existent branch'
do
subject
{
repository
.
merged_to_root_ref?
(
'non_existent_branch'
)
}
it
{
is_expected
.
to
be_nil
}
end
end
describe
"search_files"
do
describe
"search_files"
do
let
(
:results
)
{
repository
.
search_files
(
'feature'
,
'master'
)
}
let
(
:results
)
{
repository
.
search_files
(
'feature'
,
'master'
)
}
subject
{
results
}
subject
{
results
}
...
...
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