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
d6a6c1b0
Commit
d6a6c1b0
authored
Jan 30, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds remote sync time functionality
parent
0cd84ba4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
8 deletions
+37
-8
app/models/project.rb
app/models/project.rb
+1
-1
app/models/remote_mirror.rb
app/models/remote_mirror.rb
+4
-2
db/migrate/20170130113559_add_sync_schedule_to_projects_and_remote_projects.rb
...3559_add_sync_schedule_to_projects_and_remote_projects.rb
+17
-0
lib/gitlab/mirror.rb
lib/gitlab/mirror.rb
+15
-5
No files found.
app/models/project.rb
View file @
d6a6c1b0
...
...
@@ -35,7 +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
)
{
gitlab_config_features
.
sync_time
}
default_value_for
:sync_time
,
gitlab_config_features
.
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
...
...
app/models/remote_mirror.rb
View file @
d6a6c1b0
...
...
@@ -18,8 +18,10 @@ class RemoteMirror < ActiveRecord::Base
default_value_for
:remote_sync_time
,
gitlab_config_features
.
sync_time
validates
:url
,
presence:
true
,
url:
{
protocols:
%w(ssh git http https)
,
allow_blank:
true
}
validates
:remote_sync_time
,
presence:
true
,
inclusion:
{
in:
Gitlab
::
Mirror
.
sync_time_options
.
values
}
validates
:remote_sync_time
,
presence:
true
,
inclusion:
{
in:
Gitlab
::
Mirror
.
sync_time_options
.
values
}
validate
:url_availability
,
if:
->
(
mirror
)
{
mirror
.
url_changed?
||
mirror
.
enabled?
}
after_save
:refresh_remote
,
if: :mirror_url_changed?
...
...
db/migrate/201701
25101856_add_sync_schedule_to
_projects.rb
→
db/migrate/201701
30113559_add_sync_schedule_to_projects_and_remote
_projects.rb
View file @
d6a6c1b0
# 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
class
AddSyncScheduleToProjectsAndRemoteProjects
<
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
add_column_with_default
(
:remote_mirrors
,
:remote_sync_time
,
:integer
,
default:
60
)
add_column_with_default
(
:projects
,
:sync_time
,
:integer
,
default:
60
)
end
def
down
remove_column
:projects
,
:sync_time
remove_column
:remote_mirrors
,
:remote_sync_time
end
end
lib/gitlab/mirror.rb
View file @
d6a6c1b0
module
Gitlab
module
Mirror
FIFTEEN
=
15
HOURLY
=
60
DAYLY
=
1440
PRECRON
=
14
.
minutes
class
<<
self
def
sync_time_options
{
...
...
@@ -23,13 +24,22 @@ module Gitlab
end
def
at_beginning_of_day?
beginning_of_day
=
DateTime
.
now
.
at_beginning_of_day
DateTime
.
now
>=
beginning_of_day
&&
DateTime
.
now
<=
beginning_of_day
+
14
.
minutes
start_at
=
DateTime
.
now
.
at_beginning_of_day
end_at
=
start_at
+
PRECRON
include_with_range?
(
start_at
,
end_at
)
end
def
at_beginning_of_hour?
beginning_of_hour
=
DateTime
.
now
.
at_beginning_of_hour
DateTime
.
now
>=
beginning_of_hour
&&
DateTime
.
now
<=
beginning_of_hour
+
14
.
minutes
start_at
=
DateTime
.
now
.
at_beginning_of_hour
end_at
=
start_at
+
PRECRON
include_with_range?
(
start_at
,
end_at
)
end
def
include_with_range?
(
start_at
,
end_at
)
window
=
start_at
...
end_at
window
.
include?
(
DateTime
.
now
)
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