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
Léo-Paul Géneau
gitlab-ce
Commits
39d00bdd
Commit
39d00bdd
authored
Nov 03, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure the settings page renders when root of a fork is deleted
parent
5c147b6b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
9 deletions
+82
-9
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+11
-3
app/models/project.rb
app/models/project.rb
+4
-0
app/views/projects/_home_panel.html.haml
app/views/projects/_home_panel.html.haml
+4
-5
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+4
-1
changelogs/unreleased/bvl-unlink-fixes.yml
changelogs/unreleased/bvl-unlink-fixes.yml
+5
-0
spec/features/projects/settings/forked_project_settings_spec.rb
...eatures/projects/settings/forked_project_settings_spec.rb
+40
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+14
-0
No files found.
app/helpers/projects_helper.rb
View file @
39d00bdd
...
@@ -110,7 +110,15 @@ module ProjectsHelper
...
@@ -110,7 +110,15 @@ module ProjectsHelper
def
remove_fork_project_message
(
project
)
def
remove_fork_project_message
(
project
)
_
(
"You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?"
)
%
_
(
"You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?"
)
%
{
forked_from_project:
@project
.
forked_from_project
.
name_with_namespace
}
{
forked_from_project:
fork_source_name
(
project
)
}
end
def
fork_source_name
(
project
)
if
@project
.
fork_source
@project
.
fork_source
.
full_name
else
@project
.
fork_network
&
.
deleted_root_project_name
end
end
end
def
project_nav_tabs
def
project_nav_tabs
...
@@ -140,8 +148,8 @@ module ProjectsHelper
...
@@ -140,8 +148,8 @@ module ProjectsHelper
def
can_change_visibility_level?
(
project
,
current_user
)
def
can_change_visibility_level?
(
project
,
current_user
)
return
false
unless
can?
(
current_user
,
:change_visibility_level
,
project
)
return
false
unless
can?
(
current_user
,
:change_visibility_level
,
project
)
if
project
.
fork
ed?
if
project
.
fork
_source
project
.
fork
ed_from_project
.
visibility_level
>
Gitlab
::
VisibilityLevel
::
PRIVATE
project
.
fork
_source
.
visibility_level
>
Gitlab
::
VisibilityLevel
::
PRIVATE
else
else
true
true
end
end
...
...
app/models/project.rb
View file @
39d00bdd
...
@@ -1040,6 +1040,10 @@ class Project < ActiveRecord::Base
...
@@ -1040,6 +1040,10 @@ class Project < ActiveRecord::Base
!
(
forked_project_link
.
nil?
||
forked_project_link
.
forked_from_project
.
nil?
)
!
(
forked_project_link
.
nil?
||
forked_project_link
.
forked_from_project
.
nil?
)
end
end
def
fork_source
forked_from_project
||
fork_network
&
.
root_project
end
def
personal?
def
personal?
!
group
!
group
end
end
...
...
app/views/projects/_home_panel.html.haml
View file @
39d00bdd
-
empty_repo
=
@project
.
empty_repo?
-
empty_repo
=
@project
.
empty_repo?
-
fork_network
=
@project
.
fork_network
-
fork_network
=
@project
.
fork_network
-
forked_from_project
=
@project
.
forked_from_project
||
fork_network
&
.
root_project
.project-home-panel.text-center
{
class:
(
"empty-project"
if
empty_repo
)
}
.project-home-panel.text-center
{
class:
(
"empty-project"
if
empty_repo
)
}
.limit-container-width
{
class:
container_class
}
.limit-container-width
{
class:
container_class
}
.avatar-container.s70.project-avatar
.avatar-container.s70.project-avatar
...
@@ -16,13 +15,13 @@
...
@@ -16,13 +15,13 @@
-
if
@project
.
forked?
-
if
@project
.
forked?
%p
%p
-
if
forked_from_project
-
if
@project
.
fork_source
#{
s_
(
'ForkedFromProjectPath|Forked from'
)
}
#{
s_
(
'ForkedFromProjectPath|Forked from'
)
}
=
link_to
project_path
(
forked_from_project
)
do
=
link_to
project_path
(
@project
.
fork_source
)
do
=
fork
ed_from_project
.
full_name
=
fork
_source_name
(
@project
)
-
else
-
else
-
deleted_message
=
s_
(
'ForkedFromProjectPath|Forked from %{project_name} (deleted)'
)
-
deleted_message
=
s_
(
'ForkedFromProjectPath|Forked from %{project_name} (deleted)'
)
=
deleted_message
%
{
project_name:
fork_
network
.
deleted_root_project_name
}
=
deleted_message
%
{
project_name:
fork_
source_name
(
@project
)
}
.project-repo-buttons
.project-repo-buttons
.count-buttons
.count-buttons
...
...
app/views/projects/edit.html.haml
View file @
39d00bdd
...
@@ -173,7 +173,10 @@
...
@@ -173,7 +173,10 @@
%p
%p
This will remove the fork relationship to source project
This will remove the fork relationship to source project
=
succeed
"."
do
=
succeed
"."
do
=
link_to
@project
.
forked_from_project
.
name_with_namespace
,
project_path
(
@project
.
forked_from_project
)
-
if
@project
.
fork_source
=
link_to
(
fork_source_name
(
@project
),
project_path
(
@project
.
fork_source
))
-
else
=
fork_source_name
(
@project
)
=
form_for
([
@project
.
namespace
.
becomes
(
Namespace
),
@project
],
url:
remove_fork_project_path
(
@project
),
method: :delete
,
remote:
true
,
html:
{
class:
'transfer-project'
})
do
|
f
|
=
form_for
([
@project
.
namespace
.
becomes
(
Namespace
),
@project
],
url:
remove_fork_project_path
(
@project
),
method: :delete
,
remote:
true
,
html:
{
class:
'transfer-project'
})
do
|
f
|
%p
%p
%strong
Once removed, the fork relationship cannot be restored and you will no longer be able to send merge requests to the source.
%strong
Once removed, the fork relationship cannot be restored and you will no longer be able to send merge requests to the source.
...
...
changelogs/unreleased/bvl-unlink-fixes.yml
0 → 100644
View file @
39d00bdd
---
title
:
Fix issues with forked projects of which the source was deleted
merge_request
:
15150
author
:
type
:
fixed
spec/features/projects/settings/forked_project_settings_spec.rb
0 → 100644
View file @
39d00bdd
require
'spec_helper'
feature
'Settings for a forked project'
,
:js
do
include
ProjectForksHelper
let
(
:user
)
{
create
(
:user
)
}
let
(
:original_project
)
{
create
(
:project
)
}
let
(
:forked_project
)
{
fork_project
(
original_project
,
user
)
}
before
do
original_project
.
add_master
(
user
)
forked_project
.
add_master
(
user
)
sign_in
(
user
)
end
shared_examples
'project settings for a forked projects'
do
it
'allows deleting the link to the forked project'
do
visit
edit_project_path
(
forked_project
)
click_button
'Remove fork relationship'
wait_for_requests
fill_in
(
'confirm_name_input'
,
with:
forked_project
.
name
)
click_button
(
'Confirm'
)
expect
(
page
).
to
have_content
(
'The fork relationship has been removed.'
)
expect
(
forked_project
.
reload
.
forked?
).
to
be_falsy
end
end
it_behaves_like
'project settings for a forked projects'
context
'when the original project is deleted'
do
before
do
original_project
.
destroy!
end
it_behaves_like
'project settings for a forked projects'
end
end
spec/models/project_spec.rb
View file @
39d00bdd
...
@@ -1923,6 +1923,20 @@ describe Project do
...
@@ -1923,6 +1923,20 @@ describe Project do
expect
(
forked_project
.
in_fork_network_of?
(
other_project
)).
to
be_falsy
expect
(
forked_project
.
in_fork_network_of?
(
other_project
)).
to
be_falsy
end
end
end
end
describe
'#fork_source'
do
let!
(
:second_fork
)
{
fork_project
(
forked_project
)
}
it
'returns the direct source if it exists'
do
expect
(
second_fork
.
fork_source
).
to
eq
(
forked_project
)
end
it
'returns the root of the fork network when the directs source was deleted'
do
forked_project
.
destroy
expect
(
second_fork
.
fork_source
).
to
eq
(
project
)
end
end
end
end
describe
'#pushes_since_gc'
do
describe
'#pushes_since_gc'
do
...
...
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