Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
c7854cd0
Commit
c7854cd0
authored
5 years ago
by
Christian Franke
Committed by
Rhys Arkins
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(schedule): Support month (M) in schedules (#4832)
Fixes: #4831
parent
473b7e1f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/workers/branch/schedule.ts
+12
-2
12 additions, 2 deletions
lib/workers/branch/schedule.ts
test/workers/branch/schedule.spec.js
+12
-0
12 additions, 0 deletions
test/workers/branch/schedule.spec.js
with
24 additions
and
2 deletions
lib/workers/branch/schedule.ts
+
12
−
2
View file @
c7854cd0
...
...
@@ -49,10 +49,10 @@ export function hasValidSchedule(
}
if
(
!
parsedSchedule
.
schedules
.
some
(
s
=>
s
.
d
!==
undefined
||
s
.
D
||
s
.
t_a
!==
undefined
||
s
.
t_b
s
=>
s
.
M
||
s
.
d
!==
undefined
||
s
.
D
||
s
.
t_a
!==
undefined
||
s
.
t_b
)
)
{
message
=
`Schedule "
${
scheduleText
}
" has no days of week or time of day`
;
message
=
`Schedule "
${
scheduleText
}
" has no
months,
days of week or time of day`
;
return
true
;
}
// It must be OK
...
...
@@ -119,6 +119,16 @@ export function isScheduledNow(config) {
logger
.
debug
({
parsedSchedule
},
`Checking schedule "
${
scheduleText
}
"`
);
// Later library returns array of schedules
return
parsedSchedule
.
schedules
.
some
(
schedule
=>
{
// Check if months are defined
if
(
schedule
.
M
)
{
const
currentMonth
=
parseInt
(
now
.
format
(
'
M
'
),
10
);
if
(
!
schedule
.
M
.
includes
(
currentMonth
))
{
logger
.
debug
(
`Does not match schedule because
${
currentMonth
}
is not in
${
schedule
.
M
}
`
);
return
false
;
}
}
// Check if days are defined
if
(
schedule
.
d
)
{
// We need to compare text instead of numbers because
...
...
This diff is collapsed.
Click to expand it.
test/workers/branch/schedule.spec.js
+
12
−
0
View file @
c7854cd0
...
...
@@ -215,5 +215,17 @@ describe('workers/branch/schedule', () => {
const
res
=
schedule
.
isScheduledNow
(
config
);
expect
(
res
).
toBe
(
false
);
});
it
(
'
approves on months of year
'
,
()
=>
{
config
.
schedule
=
[
'
of January
'
];
mockDate
.
set
(
'
2017-01-02T06:00:00.000
'
);
// Locally Monday, 2 January 2017 6am
const
res
=
schedule
.
isScheduledNow
(
config
);
expect
(
res
).
toBe
(
true
);
});
it
(
'
rejects on months of year
'
,
()
=>
{
config
.
schedule
=
[
'
of January
'
];
mockDate
.
set
(
'
2017-02-02T06:00:00.000
'
);
// Locally Thursday, 2 February 2017 6am
const
res
=
schedule
.
isScheduledNow
(
config
);
expect
(
res
).
toBe
(
false
);
});
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment