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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
31b1ffd5
Commit
31b1ffd5
authored
Nov 17, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow mirror user to be set.
parent
6d928726
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
40 additions
and
10 deletions
+40
-10
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+2
-0
app/assets/javascripts/users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+2
-0
app/controllers/autocomplete_controller.rb
app/controllers/autocomplete_controller.rb
+5
-1
app/controllers/projects/imports_controller.rb
app/controllers/projects/imports_controller.rb
+1
-1
app/controllers/projects/mirrors_controller.rb
app/controllers/projects/mirrors_controller.rb
+5
-3
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-0
app/helpers/selects_helper.rb
app/helpers/selects_helper.rb
+3
-1
app/models/project.rb
app/models/project.rb
+3
-0
app/views/projects/mirrors/show.html.haml
app/views/projects/mirrors/show.html.haml
+11
-0
app/views/shared/_import_form.html.haml
app/views/shared/_import_form.html.haml
+2
-0
app/workers/repository_update_mirror_worker.rb
app/workers/repository_update_mirror_worker.rb
+1
-2
db/migrate/20151110125416_add_mirror_to_project.rb
db/migrate/20151110125416_add_mirror_to_project.rb
+1
-0
db/schema.rb
db/schema.rb
+3
-2
No files found.
app/assets/javascripts/dispatcher.js.coffee
View file @
31b1ffd5
...
...
@@ -102,6 +102,8 @@ class Dispatcher
new
Activities
()
when
'projects:group_links:index'
new
GroupsSelect
()
when
'projects:mirrors:show'
,
'projects:mirrors:update'
new
UsersSelect
()
when
'admin:emails:show'
new
AdminEmailSelect
()
...
...
app/assets/javascripts/users_select.js.coffee
View file @
31b1ffd5
...
...
@@ -8,6 +8,7 @@ class @UsersSelect
@
projectId
=
$
(
select
).
data
(
'project-id'
)
@
groupId
=
$
(
select
).
data
(
'group-id'
)
@
showCurrentUser
=
$
(
select
).
data
(
'current-user'
)
@
pushCodeToProtectedBranches
=
$
(
select
).
data
(
'push-code-to-protected-branches'
)
showNullUser
=
$
(
select
).
data
(
'null-user'
)
showAnyUser
=
$
(
select
).
data
(
'any-user'
)
showEmailUser
=
$
(
select
).
data
(
'email-user'
)
...
...
@@ -112,6 +113,7 @@ class @UsersSelect
group_id
:
@
groupId
skip_ldap
:
@
skipLdap
current_user
:
@
showCurrentUser
push_code_to_protected_branches
:
@
pushCodeToProtectedBranches
dataType
:
"json"
).
done
(
users
)
->
callback
(
users
)
...
...
app/controllers/autocomplete_controller.rb
View file @
31b1ffd5
...
...
@@ -34,7 +34,11 @@ class AutocompleteController < ApplicationController
@users
=
@users
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@users
=
@users
.
active
@users
=
@users
.
reorder
(
:name
)
@users
=
@users
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
if
params
[
:push_code_to_protected_branches
]
&&
project
@users
=
@users
.
to_a
.
select
{
|
user
|
user
.
can?
(
:push_code_to_protected_branches
,
project
)
}.
take
(
PER_PAGE
)
else
@users
=
@users
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
unless
params
[
:search
].
present?
# Include current user if available to filter by "Me"
...
...
app/controllers/projects/imports_controller.rb
View file @
31b1ffd5
...
...
@@ -48,6 +48,6 @@ class Projects::ImportsController < Projects::ApplicationController
end
def
import_params
params
.
require
(
:project
).
permit
(
:import_url
,
:mirror
)
params
.
require
(
:project
).
permit
(
:import_url
,
:mirror
,
:mirror_user_id
)
end
end
app/controllers/projects/mirrors_controller.rb
View file @
31b1ffd5
...
...
@@ -16,8 +16,10 @@ class Projects::MirrorsController < Projects::ApplicationController
@project
.
update_mirror
flash
[
:notice
]
=
"Mirroring settings were successfully updated. The project is being updated."
els
e
els
if
@project
.
mirror_changed?
flash
[
:notice
]
=
"Mirroring was successfully disabled."
else
flash
[
:notice
]
=
"Mirroring settings were successfully updated."
end
redirect_to
namespace_project_mirror_path
(
@project
.
namespace
,
@project
)
...
...
@@ -31,11 +33,11 @@ class Projects::MirrorsController < Projects::ApplicationController
flash
[
:notice
]
=
"The repository is being updated..."
redirect_back_or_default
(
default:
namespace_project_path
(
@project
.
namespace
,
@project
))
end
end
private
def
mirror_params
params
.
require
(
:project
).
permit
(
:mirror
,
:import_url
)
params
.
require
(
:project
).
permit
(
:mirror
,
:import_url
,
:mirror_user_id
)
end
end
app/controllers/projects_controller.rb
View file @
31b1ffd5
...
...
@@ -237,6 +237,7 @@ class ProjectsController < ApplicationController
:merge_requests_rebase_enabled
,
:merge_requests_template
,
:mirror
,
:mirror_user_id
,
:reset_approvals_on_push
)
end
...
...
app/helpers/selects_helper.rb
View file @
31b1ffd5
...
...
@@ -13,6 +13,7 @@ module SelectsHelper
first_user
=
opts
[
:first_user
]
&&
current_user
?
current_user
.
username
:
false
current_user
=
opts
[
:current_user
]
||
false
project
=
opts
[
:project
]
||
@project
push_code_to_protected_branches
=
opts
[
:push_code_to_protected_branches
]
html
=
{
class:
css_class
,
...
...
@@ -21,7 +22,8 @@ module SelectsHelper
'data-any-user'
=>
any_user
,
'data-email-user'
=>
email_user
,
'data-first-user'
=>
first_user
,
'data-current-user'
=>
current_user
'data-current-user'
=>
current_user
,
'data-push-code-to-protected-branches'
=>
push_code_to_protected_branches
}
unless
opts
[
:scope
]
==
:all
...
...
app/models/project.rb
View file @
31b1ffd5
...
...
@@ -76,6 +76,8 @@ class Project < ActiveRecord::Base
has_one
:git_hook
,
dependent: :destroy
has_one
:last_event
,
->
{
order
'events.created_at DESC'
},
class_name:
'Event'
,
foreign_key:
'project_id'
belongs_to
:mirror_user
,
foreign_key:
'mirror_user_id'
,
class_name:
'User'
# Project services
has_many
:services
has_one
:gitlab_ci_service
,
dependent: :destroy
...
...
@@ -162,6 +164,7 @@ class Project < ActiveRecord::Base
format:
{
with:
/\A
#{
URI
.
regexp
(
%w(ssh git http https)
)
}
\z/
,
message:
'should be a valid url'
},
if: :external_import?
validates
:import_url
,
presence:
true
,
if: :mirror?
validates
:mirror_user
,
presence:
true
,
if: :mirror?
validates
:star_count
,
numericality:
{
greater_than_or_equal_to:
0
}
validate
:check_limit
,
on: :create
validate
:avatar_type
,
...
...
app/views/projects/mirrors/show.html.haml
View file @
31b1ffd5
...
...
@@ -55,5 +55,16 @@
%li
The update action will time out after 10 minutes. For big repositories, use a clone/push combination.
.form-group
=
f
.
label
:mirror_user_id
,
class:
'control-label'
do
Mirror user
.col-sm-10
=
users_select_tag
(
"project[mirror_user_id]"
,
class:
'input-large'
,
selected:
@project
.
mirror_user_id
||
current_user
.
id
,
first_user:
true
,
current_user:
true
,
push_code_to_protected_branches:
true
)
.help-block
This user will be the author of all events in the activity feed that are the result of an update,
like new branches being created or new commits being pushed to existing branches.
They need to have at least master access to this project.
.form-actions
=
f
.
submit
"Save Changes"
,
class:
"btn btn-create"
app/views/shared/_import_form.html.haml
View file @
31b1ffd5
...
...
@@ -24,3 +24,5 @@
Mirror repository
.help-block
Automatically update this project's branches and tags from the upstream repository every hour.
=
f
.
hidden_field
:mirror_user_id
,
value:
current_user
.
id
app/workers/repository_update_mirror_worker.rb
View file @
31b1ffd5
...
...
@@ -8,8 +8,7 @@ class RepositoryUpdateMirrorWorker
def
perform
(
project_id
)
@project
=
Project
.
find
(
project_id
)
# TODO: Use actual user
@current_user
=
User
.
last
@current_user
=
@project
.
mirror_user
||
@project
.
creator
result
=
Projects
::
UpdateMirrorService
.
new
(
@project
,
@current_user
).
execute
if
result
[
:status
]
==
:error
...
...
db/migrate/20151110125416_add_mirror_to_project.rb
View file @
31b1ffd5
...
...
@@ -3,5 +3,6 @@ class AddMirrorToProject < ActiveRecord::Migration
add_column
:projects
,
:mirror
,
:boolean
,
default:
false
,
null:
false
add_column
:projects
,
:mirror_last_update_at
,
:datetime
add_column
:projects
,
:mirror_last_successful_update_at
,
:datetime
add_column
:projects
,
:mirror_user_id
,
:integer
end
end
db/schema.rb
View file @
31b1ffd5
...
...
@@ -48,9 +48,9 @@ ActiveRecord::Schema.define(version: 20151114113410) do
t
.
boolean
"twitter_sharing_enabled"
,
default:
true
t
.
text
"help_text"
t
.
text
"restricted_visibility_levels"
t
.
boolean
"version_check_enabled"
,
default:
true
t
.
integer
"max_attachment_size"
,
default:
10
,
null:
false
t
.
integer
"default_project_visibility"
t
.
boolean
"version_check_enabled"
,
default:
true
t
.
integer
"default_snippet_visibility"
t
.
text
"restricted_signup_domains"
t
.
boolean
"user_oauth_applications"
,
default:
true
...
...
@@ -725,10 +725,11 @@ ActiveRecord::Schema.define(version: 20151114113410) do
t
.
boolean
"reset_approvals_on_push"
,
default:
true
t
.
boolean
"merge_requests_ff_only_enabled"
,
default:
false
t
.
text
"issues_template"
t
.
text
"import_error"
t
.
boolean
"mirror"
,
default:
false
,
null:
false
t
.
datetime
"mirror_last_update_at"
t
.
datetime
"mirror_last_successful_update_at"
t
.
text
"import_error
"
t
.
integer
"mirror_user_id
"
end
add_index
"projects"
,
[
"created_at"
,
"id"
],
name:
"index_projects_on_created_at_and_id"
,
using: :btree
...
...
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