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
d02a7171
Commit
d02a7171
authored
Jan 25, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds select field and sync time migration for mirror sync cron jobs
parent
5b49fc34
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
2 deletions
+61
-2
app/controllers/projects/mirrors_controller.rb
app/controllers/projects/mirrors_controller.rb
+3
-2
app/models/project.rb
app/models/project.rb
+5
-0
app/views/projects/mirrors/show.html.haml
app/views/projects/mirrors/show.html.haml
+3
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
db/migrate/20170125101856_add_sync_schedule_to_projects.rb
db/migrate/20170125101856_add_sync_schedule_to_projects.rb
+19
-0
db/schema.rb
db/schema.rb
+1
-0
lib/gitlab/mirror.rb
lib/gitlab/mirror.rb
+29
-0
No files found.
app/controllers/projects/mirrors_controller.rb
View file @
d02a7171
...
...
@@ -46,7 +46,8 @@ class Projects::MirrorsController < Projects::ApplicationController
end
def
mirror_params
params
.
require
(
:project
).
permit
(
:mirror
,
:import_url
,
:mirror_user_id
,
:mirror_trigger_builds
,
remote_mirrors_attributes:
[
:url
,
:id
,
:enabled
])
params
.
require
(
:project
).
permit
(
:mirror
,
:import_url
,
:mirror_user_id
,
:mirror_trigger_builds
,
:sync_time
,
remote_mirrors_attributes:
[
:url
,
:id
,
:enabled
])
end
end
app/models/project.rb
View file @
d02a7171
...
...
@@ -35,6 +35,7 @@ class Project < ActiveRecord::Base
default_value_for
:container_registry_enabled
,
gitlab_config_features
.
container_registry
default_value_for
(
:repository_storage
)
{
current_application_settings
.
pick_repository_storage
}
default_value_for
(
:shared_runners_enabled
)
{
current_application_settings
.
shared_runners_enabled
}
default_value_for
(
:sync_time
)
{
current_application_settings
.
default_mirror_sync_time
}
default_value_for
:issues_enabled
,
gitlab_config_features
.
issues
default_value_for
:merge_requests_enabled
,
gitlab_config_features
.
merge_requests
default_value_for
:builds_enabled
,
gitlab_config_features
.
builds
...
...
@@ -215,6 +216,10 @@ class Project < ActiveRecord::Base
validates
:repository_size_limit
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
,
allow_nil:
true
}
validates
:sync_time
,
presence:
true
,
inclusion:
{
in:
Gitlab
::
Mirror
.
mirror_options
.
values
}
with_options
if: :mirror?
do
|
project
|
project
.
validates
:import_url
,
presence:
true
project
.
validates
:mirror_user
,
presence:
true
...
...
app/views/projects/mirrors/show.html.haml
View file @
d02a7171
...
...
@@ -45,6 +45,9 @@
They need to have at least master access to this project.
-
if
@project
.
builds_enabled?
=
render
"shared/mirror_trigger_builds_setting"
,
f:
f
.form-group
=
f
.
label
:sync_time
,
"Mirror synchronisation time"
,
class:
"label-light append-bottom-0"
=
f
.
select
:sync_time
,
options_for_select
(
Gitlab
::
Mirror
.
mirror_options
,
@project
.
sync_time
),
{},
class:
'form-control'
.col-sm-12
%hr
.col-lg-3
...
...
config/initializers/1_settings.rb
View file @
d02a7171
...
...
@@ -223,6 +223,7 @@ Settings['issues_tracker'] ||= {}
Settings
[
'gitlab'
]
||=
Settingslogic
.
new
({})
Settings
.
gitlab
[
'default_projects_limit'
]
||=
10
Settings
.
gitlab
[
'default_branch_protection'
]
||=
2
Settings
.
gitlab
[
'default_mirror_sync_time'
]
||=
1
Settings
.
gitlab
[
'default_can_create_group'
]
=
true
if
Settings
.
gitlab
[
'default_can_create_group'
].
nil?
Settings
.
gitlab
[
'default_theme'
]
=
Gitlab
::
Themes
::
APPLICATION_DEFAULT
if
Settings
.
gitlab
[
'default_theme'
].
nil?
Settings
.
gitlab
[
'host'
]
||=
ENV
[
'GITLAB_HOST'
]
||
'localhost'
...
...
db/migrate/20170125101856_add_sync_schedule_to_projects.rb
0 → 100644
View file @
d02a7171
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddSyncScheduleToProjects
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
:projects
,
:sync_time
,
:integer
,
default:
60
end
def
down
remove_column
:projects
,
:sync_time
end
end
db/schema.rb
View file @
d02a7171
...
...
@@ -1112,6 +1112,7 @@ ActiveRecord::Schema.define(version: 20170204181513) do
t
.
text
"description_html"
t
.
boolean
"only_allow_merge_if_all_discussions_are_resolved"
t
.
integer
"repository_size_limit"
,
limit:
8
t
.
integer
"sync_time"
,
default:
60
,
null:
false
end
add_index
"projects"
,
[
"ci_id"
],
name:
"index_projects_on_ci_id"
,
using: :btree
...
...
lib/gitlab/mirror.rb
0 → 100644
View file @
d02a7171
module
Gitlab
module
Mirror
QUARTER
=
15
HOUR
=
60
DAY
=
1440
class
<<
self
def
mirror_options
{
"Update every 15 minutes"
:
QUARTER
,
"Update hourly"
:
HOUR
,
"Update every day"
:
DAY
,
}
end
def
to_cron
(
sync_time
)
case
sync_time
when
QUARTER
"*/15 * * * *"
when
HOUR
"0 * * * *"
when
DAY
"0 0 * * *"
end
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