Skip to content

Commit

Permalink
Merge branch 'master' into new-header
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik authored Feb 11, 2025
2 parents 57e67af + c9ce210 commit ddc968a
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 107 deletions.
4 changes: 2 additions & 2 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ THE SOFTWARE.
<commons-fileupload2.version>2.0.0-M2</commons-fileupload2.version>
<groovy.version>2.4.21</groovy.version>
<jelly.version>1.1-jenkins-20250108</jelly.version>
<stapler.version>1942.v708e07325402</stapler.version>
<stapler.version>1948.v0f99403fe86a_</stapler.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -337,7 +337,7 @@ THE SOFTWARE.
<!-- provided by jcl-over-slf4j -->
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/java/hudson/scheduler/CronTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ public Calendar ceil(long t) {
* (e.g. Jun 31) date, or at least a date too rare to be useful. This addresses JENKINS-41864 and was added in 2.49
*/
public Calendar ceil(Calendar cal) {
if (cal.get(Calendar.SECOND) > 0 || cal.get(Calendar.MILLISECOND) > 0) {
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.MINUTE, 1);
}
Calendar twoYearsFuture = (Calendar) cal.clone();
twoYearsFuture.add(Calendar.YEAR, 2);
OUTER:
Expand Down Expand Up @@ -440,6 +445,8 @@ public Calendar floor(long t) {
* (e.g. Jun 31) date, or at least a date too rare to be useful. This addresses JENKINS-41864 and was added in 2.49
*/
public Calendar floor(Calendar cal) {
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Calendar twoYearsAgo = (Calendar) cal.clone();
twoYearsAgo.add(Calendar.YEAR, -2);

Expand Down
10 changes: 8 additions & 2 deletions core/src/main/resources/lib/hudson/widget-refresh.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/**
* Use the `widget-refresh-reference` class on an element with `data-id` and `data-url` attributes.
* The content from the URL will be used to replace the element with the specified ID.
* Usually the URL content is an element with the same ID as specified here, to allow continuous updates.
* This is primarily used for sidepanel widgets, but not exclusively.
*/
Behaviour.specify(
".widget-refresh-reference",
"widget-refresh",
0,
function (e) {
var id = e.getAttribute("data-id");
var url = e.getAttribute("data-url");
let id = e.getAttribute("data-id");
let url = e.getAttribute("data-url");
refreshPart(id, url);
},
);
22 changes: 22 additions & 0 deletions core/src/test/java/hudson/scheduler/CronTabTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,22 @@
import static java.util.Calendar.MONDAY;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;

import antlr.ANTLRException;
import java.text.DateFormat;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.function.Function;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;

Expand Down Expand Up @@ -340,6 +344,24 @@ public int next(int n) {
assertEquals("[35, 56]", times.toString());
}

@Test public void floorCeilMinuteGranularity() throws Exception {
var tab = new CronTab("*/5 * * * *");
assertFloorCeil(tab, new GregorianCalendar(2025, 2, 4, 14, 15, 23), "2025-03-04T14:15:00", "2025-03-04T14:20:00");
assertFloorCeil(tab, new GregorianCalendar(2025, 2, 4, 14, 19, 23), "2025-03-04T14:15:00", "2025-03-04T14:20:00");
assertFloorCeil(tab, new GregorianCalendar(2025, 2, 4, 14, 16, 0), "2025-03-04T14:15:00", "2025-03-04T14:20:00");
assertFloorCeil(tab, new GregorianCalendar(2025, 2, 4, 14, 19, 0), "2025-03-04T14:15:00", "2025-03-04T14:20:00");
assertFloorCeil(tab, new GregorianCalendar(2025, 2, 4, 14, 15, 0), "2025-03-04T14:15:00", "2025-03-04T14:15:00");
}

private static void assertFloorCeil(CronTab tab, Calendar now, String expectedFloor, String expectedCeil) {
Function<Calendar, String> fmt = c -> ZonedDateTime.ofInstant(c.toInstant(), c.getTimeZone().toZoneId()).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
var nowFormatted = fmt.apply(now);
var nowClone = (Calendar) now.clone();
assertThat("floor of " + nowFormatted, fmt.apply(tab.floor(nowClone)), is(expectedFloor));
nowClone = (Calendar) now.clone();
assertThat("ceil of " + nowFormatted, fmt.apply(tab.ceil(nowClone)), is(expectedCeil));
}

@Issue("SECURITY-790")
@Test(timeout = 1000L) public void testLongMonths() throws Exception {
Calendar cal = Calendar.getInstance();
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
},
"devDependencies": {
"@babel/cli": "7.26.4",
"@babel/core": "7.26.7",
"@babel/preset-env": "7.26.7",
"@eslint/js": "9.19.0",
"@babel/core": "7.26.8",
"@babel/preset-env": "7.26.8",
"@eslint/js": "9.20.0",
"babel-loader": "9.2.1",
"clean-webpack-plugin": "4.0.0",
"css-loader": "7.1.2",
"css-minimizer-webpack-plugin": "7.0.0",
"eslint": "9.19.0",
"eslint": "9.20.0",
"eslint-config-prettier": "10.0.1",
"eslint-formatter-checkstyle": "8.40.0",
"globals": "15.14.0",
Expand All @@ -42,7 +42,7 @@
"postcss-preset-env": "10.1.3",
"postcss-scss": "4.0.9",
"prettier": "3.4.2",
"sass": "1.83.4",
"sass": "1.84.0",
"sass-loader": "16.0.4",
"style-loader": "4.0.0",
"stylelint": "16.14.1",
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ THE SOFTWARE.
</issueManagement>

<properties>
<revision>2.497</revision>
<revision>2.498</revision>
<changelist>-SNAPSHOT</changelist>
<project.build.outputTimestamp>2025-02-04T13:38:06Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2025-02-11T14:10:23Z</project.build.outputTimestamp>

<!-- configuration for patch tracker plugin -->
<project.patchManagement.system>github</project.patchManagement.system>
Expand Down
4 changes: 2 additions & 2 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ THE SOFTWARE.
<!-- requireUpperBoundDeps via matrix-project and junit -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1369.v9b_98a_4e95b_2d</version>
<version>1373.vb_b_4a_a_c26fa_00</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -230,7 +230,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1312.v1a_235a_b_94a_31</version>
<version>1314.vd966e9a_88895</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,14 @@ THE SOFTWARE.
<!-- dependency of command-launcher, junit, matrix-project, and workflow-support -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1369.v9b_98a_4e95b_2d</version>
<version>1373.vb_b_4a_a_c26fa_00</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- detached after 1.577 -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1312.v1a_235a_b_94a_31</version>
<version>1314.vd966e9a_88895</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
Expand Down Expand Up @@ -462,7 +462,7 @@ THE SOFTWARE.
<!-- detached after 2.281 -->
<groupId>org.jenkins-ci.modules</groupId>
<artifactId>sshd</artifactId>
<version>3.350.v1080103a_10fd</version>
<version>3.353.v2b_d33c46e970</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
Expand Down
Loading

0 comments on commit ddc968a

Please sign in to comment.