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
Boxiang Sun
gitlab-ce
Commits
228007df
Commit
228007df
authored
Feb 12, 2016
by
Zeger-Jan van de Weg
Committed by
Zeger-Jan van de Weg
Mar 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new-branch-button
parent
bc590ce6
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
81 additions
and
4 deletions
+81
-4
CHANGELOG
CHANGELOG
+2
-0
app/assets/stylesheets/pages/issues.scss
app/assets/stylesheets/pages/issues.scss
+5
-0
app/controllers/projects/branches_controller.rb
app/controllers/projects/branches_controller.rb
+13
-3
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-0
app/models/issue.rb
app/models/issue.rb
+14
-0
app/services/merge_requests/build_service.rb
app/services/merge_requests/build_service.rb
+11
-0
app/views/projects/issues/_merge_requests.html.haml
app/views/projects/issues/_merge_requests.html.haml
+1
-1
app/views/projects/issues/_new_branch.html.haml
app/views/projects/issues/_new_branch.html.haml
+5
-0
app/views/projects/issues/_related_branches.html.haml
app/views/projects/issues/_related_branches.html.haml
+15
-0
app/views/projects/issues/show.html.haml
app/views/projects/issues/show.html.haml
+2
-0
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+12
-0
No files found.
CHANGELOG
View file @
228007df
...
@@ -175,6 +175,8 @@ v 8.5.0
...
@@ -175,6 +175,8 @@ v 8.5.0
- Add label description (Nuttanart Pornprasitsakul)
- Add label description (Nuttanart Pornprasitsakul)
- Show label row when filtering issues or merge requests by label (Nuttanart Pornprasitsakul)
- Show label row when filtering issues or merge requests by label (Nuttanart Pornprasitsakul)
- Add Todos
- Add Todos
- User project limit is reached notice is hidden if the projects limit is zero
- New branch button appears on issues where applicable (Zeger-Jan van de Weg)
v 8.4.5
v 8.4.5
- No CE-specific changes
- No CE-specific changes
...
...
app/assets/stylesheets/pages/issues.scss
View file @
228007df
...
@@ -49,6 +49,11 @@ form.edit-issue {
...
@@ -49,6 +49,11 @@ form.edit-issue {
margin
:
0
;
margin
:
0
;
}
}
.related-branches-title
{
font-size
:
16px
;
font-weight
:
600
;
}
.merge-requests-title
{
.merge-requests-title
{
font-size
:
16px
;
font-size
:
16px
;
font-weight
:
600
;
font-weight
:
600
;
...
...
app/controllers/projects/branches_controller.rb
View file @
228007df
...
@@ -9,7 +9,7 @@ class Projects::BranchesController < Projects::ApplicationController
...
@@ -9,7 +9,7 @@ class Projects::BranchesController < Projects::ApplicationController
@sort
=
params
[
:sort
]
||
'name'
@sort
=
params
[
:sort
]
||
'name'
@branches
=
@repository
.
branches_sorted_by
(
@sort
)
@branches
=
@repository
.
branches_sorted_by
(
@sort
)
@branches
=
Kaminari
.
paginate_array
(
@branches
).
page
(
params
[
:page
]).
per
(
PER_PAGE
)
@branches
=
Kaminari
.
paginate_array
(
@branches
).
page
(
params
[
:page
]).
per
(
PER_PAGE
)
@max_commits
=
@branches
.
reduce
(
0
)
do
|
memo
,
branch
|
@max_commits
=
@branches
.
reduce
(
0
)
do
|
memo
,
branch
|
diverging_commit_counts
=
repository
.
diverging_commit_counts
(
branch
)
diverging_commit_counts
=
repository
.
diverging_commit_counts
(
branch
)
[
memo
,
diverging_commit_counts
[
:behind
],
diverging_commit_counts
[
:ahead
]].
max
[
memo
,
diverging_commit_counts
[
:behind
],
diverging_commit_counts
[
:ahead
]].
max
...
@@ -23,8 +23,7 @@ class Projects::BranchesController < Projects::ApplicationController
...
@@ -23,8 +23,7 @@ class Projects::BranchesController < Projects::ApplicationController
def
create
def
create
branch_name
=
sanitize
(
strip_tags
(
params
[
:branch_name
]))
branch_name
=
sanitize
(
strip_tags
(
params
[
:branch_name
]))
branch_name
=
Addressable
::
URI
.
unescape
(
branch_name
)
branch_name
=
Addressable
::
URI
.
unescape
(
branch_name
)
ref
=
sanitize
(
strip_tags
(
params
[
:ref
]))
ref
=
Addressable
::
URI
.
unescape
(
ref
)
result
=
CreateBranchService
.
new
(
project
,
current_user
).
result
=
CreateBranchService
.
new
(
project
,
current_user
).
execute
(
branch_name
,
ref
)
execute
(
branch_name
,
ref
)
...
@@ -49,4 +48,15 @@ class Projects::BranchesController < Projects::ApplicationController
...
@@ -49,4 +48,15 @@ class Projects::BranchesController < Projects::ApplicationController
format
.
js
{
render
status:
status
[
:return_code
]
}
format
.
js
{
render
status:
status
[
:return_code
]
}
end
end
end
end
private
def
ref
if
params
[
:ref
]
ref_escaped
=
sanitize
(
strip_tags
(
params
[
:ref
]))
Addressable
::
URI
.
unescape
(
ref_escaped
)
else
@project
.
default_branch
end
end
end
end
app/controllers/projects/issues_controller.rb
View file @
228007df
...
@@ -65,6 +65,7 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -65,6 +65,7 @@ class Projects::IssuesController < Projects::ApplicationController
@notes
=
@issue
.
notes
.
nonawards
.
with_associations
.
fresh
@notes
=
@issue
.
notes
.
nonawards
.
with_associations
.
fresh
@noteable
=
@issue
@noteable
=
@issue
@merge_requests
=
@issue
.
referenced_merge_requests
(
current_user
)
@merge_requests
=
@issue
.
referenced_merge_requests
(
current_user
)
@related_branches
=
@issue
.
related_branches
-
@merge_requests
.
map
(
&
:source_branch
)
respond_with
(
@issue
)
respond_with
(
@issue
)
end
end
...
...
app/models/issue.rb
View file @
228007df
...
@@ -94,6 +94,10 @@ class Issue < ActiveRecord::Base
...
@@ -94,6 +94,10 @@ class Issue < ActiveRecord::Base
end
.
sort_by
(
&
:iid
)
end
.
sort_by
(
&
:iid
)
end
end
def
related_branches
self
.
project
.
repository
.
branch_names
.
select
{
|
branch
|
/\A
#{
iid
}
-/
=~
branch
}
end
# Reset issue events cache
# Reset issue events cache
#
#
# Since we do cache @event we need to reset cache in special cases:
# Since we do cache @event we need to reset cache in special cases:
...
@@ -120,4 +124,14 @@ class Issue < ActiveRecord::Base
...
@@ -120,4 +124,14 @@ class Issue < ActiveRecord::Base
note
.
all_references
(
current_user
).
merge_requests
note
.
all_references
(
current_user
).
merge_requests
end
.
uniq
.
select
{
|
mr
|
mr
.
open?
&&
mr
.
closes_issue?
(
self
)
}
end
.
uniq
.
select
{
|
mr
|
mr
.
open?
&&
mr
.
closes_issue?
(
self
)
}
end
end
def
to_branch_name
"
#{
iid
}
-
#{
title
.
parameterize
}
"
[
0
,
25
]
end
def
new_branch_button?
(
current_user
)
!
self
.
closed?
&&
referenced_merge_requests
(
current_user
).
empty?
&&
related_branches
.
empty?
end
end
end
app/services/merge_requests/build_service.rb
View file @
228007df
...
@@ -47,6 +47,17 @@ module MergeRequests
...
@@ -47,6 +47,17 @@ module MergeRequests
merge_request
.
title
=
merge_request
.
source_branch
.
titleize
.
humanize
merge_request
.
title
=
merge_request
.
source_branch
.
titleize
.
humanize
end
end
# When your branch name starts with an iid followed by a dash this pattern will
# be interpreted as the use wants to close that issue on this project
# Pattern example: 112-fix-mep-mep
# Will lead to appending `Closes #112` to the description
if
merge_request
.
source_branch
=~
/\A\d+-/
closes_issue
=
"Closes #
#{
Regexp
.
last_match
(
0
)[
0
...-
1
]
}
"
closes_issue
.
prepend
(
"
\n
"
)
if
merge_request
.
description
.
present?
merge_request
.
description
<<
closes_issue
end
merge_request
merge_request
end
end
...
...
app/views/projects/issues/_merge_requests.html.haml
View file @
228007df
-
if
@merge_requests
.
any?
-
if
@merge_requests
.
any?
%h2
.merge-requests-title
%h2
.merge-requests-title
=
pluralize
(
@merge_requests
.
count
,
'Related Merge Request'
)
=
pluralize
(
@merge_requests
.
count
,
'Related Merge Request'
)
%ul
.unstyled-list
%ul
.unstyled-list
...
...
app/views/projects/issues/_new_branch.html.haml
0 → 100644
View file @
228007df
-
if
current_user
&&
can?
(
current_user
,
:push_code
,
@project
)
&&
@issue
.
new_branch_button?
(
current_user
)
.pull-right
=
link_to
namespace_project_branches_path
(
@project
.
namespace
,
@project
,
branch_name:
@issue
.
to_branch_name
),
method: :post
,
class:
'btn'
do
=
icon
(
'code-fork'
)
New Branch
app/views/projects/issues/_related_branches.html.haml
0 → 100644
View file @
228007df
-
if
@related_branches
.
any?
%h2
.related-branches-title
=
pluralize
(
@related_branches
.
count
,
'Related Branch'
)
%ul
.unstyled-list
-
@related_branches
.
each
do
|
branch
|
%li
-
sha
=
@project
.
repository
.
find_branch
(
branch
).
target
-
ci_commit
=
@project
.
ci_commit
(
sha
)
if
sha
-
if
ci_commit
%span
.related-branch-ci-status
=
render_ci_status
(
ci_commit
)
%span
.related-branch-info
%strong
=
link_to
namespace_project_compare_path
(
@project
.
namespace
,
@project
,
from:
@project
.
default_branch
,
to:
branch
)
do
=
branch
app/views/projects/issues/show.html.haml
View file @
228007df
...
@@ -70,8 +70,10 @@
...
@@ -70,8 +70,10 @@
.merge-requests
.merge-requests
=
render
'merge_requests'
=
render
'merge_requests'
=
render
'related_branches'
.content-block.content-block-small
.content-block.content-block-small
=
render
'new_branch'
=
render
'votes/votes_block'
,
votable:
@issue
=
render
'votes/votes_block'
,
votable:
@issue
.row
.row
...
...
spec/models/issue_spec.rb
View file @
228007df
...
@@ -140,4 +140,16 @@ describe Issue, models: true do
...
@@ -140,4 +140,16 @@ describe Issue, models: true do
it_behaves_like
'a Taskable'
do
it_behaves_like
'a Taskable'
do
let
(
:subject
)
{
create
:issue
}
let
(
:subject
)
{
create
:issue
}
end
end
describe
"#to_branch_name"
do
let
(
:issue
)
{
build
(
:issue
,
title:
'a'
*
30
)
}
it
"is expected not to exceed 25 chars"
do
expect
(
issue
.
to_branch_name
.
length
).
to
eq
25
end
it
"starts with the issue iid"
do
expect
(
issue
.
to_branch_name
).
to
match
/\A
#{
issue
.
iid
}
-a+\z/
end
end
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