Skip to content

Commit

Permalink
minor touch-up and documentation
Browse files Browse the repository at this point in the history
as I was playing with it to understand what those logics mean.
  • Loading branch information
kohsuke committed Mar 25, 2013
1 parent 4335d96 commit 17e7d7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/src/main/java/hudson/scheduler/CronTab.java
Expand Up @@ -443,13 +443,15 @@ private String toString(String key, long bit) {
* @since XXX
*/
public static @CheckForNull String hashify(String spec) {
if (spec.startsWith("*/")) {
if (spec.contains("H")) {
// if someone is already using H, presumably he knows what it is, so a warning is likely false positive
return null;
} else if (spec.startsWith("*/")) {// "*/15 ...." (every N minutes) to hash
return "H" + spec.substring(1);
} else if (spec.matches("\\d+ .+")) {
} else if (spec.matches("\\d+ .+")) {// "0 ..." (certain minute) to hash
return "H " + spec.substring(spec.indexOf(' ') + 1);
} else {
return null;
}
}

}
2 changes: 2 additions & 0 deletions core/src/test/java/hudson/scheduler/CronTabTest.java
Expand Up @@ -187,6 +187,8 @@ public void testFloor4() throws Exception {
assertEquals(Messages.CronTab_spread_load_evenly_by_using_rather_than_("H * * * *", "0 * * * *"), new CronTab("0 * * * *").checkSanity());
// if the user specifically asked for 3:00 AM, probably we should stick to 3:00–3:59
assertEquals(Messages.CronTab_spread_load_evenly_by_using_rather_than_("H 3 * * *", "0 3 * * *"), new CronTab("0 3 * * *").checkSanity());

assertEquals(null, new CronTab("H/15 * 1 1 *").checkSanity());
}

/**
Expand Down

0 comments on commit 17e7d7a

Please sign in to comment.