Skip to content

Commit bfa45dc

Browse files
committedApr 16, 2024·
maintenance: running maintenance should not stop on errors
In microsoft#623, it was reported that maintenance stops on a missing repository, omitting the remaining repositories that were scheduled for maintenance. This is undesirable, as it should be a best effort type of operation. It should still fail due to the missing repository, of course, but not leave the non-missing repositories in unmaintained shapes. Let's use `for-each-repo`'s shiny new `--keep-going` option that we just introduced for that very purpose. This change will be picked up when running `git maintenance start`, which is run implicitly by `scalar reconfigure`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 26c3f33 commit bfa45dc

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed
 

‎builtin/gc.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit
19171917
"<string>--exec-path=%s</string>\n"
19181918
"%s" /* For extra config parameters. */
19191919
"<string>for-each-repo</string>\n"
1920+
"<string>--keep-going</string>\n"
19201921
"<string>--config=maintenance.repo</string>\n"
19211922
"<string>maintenance</string>\n"
19221923
"<string>run</string>\n"
@@ -2160,7 +2161,7 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
21602161
"<Actions Context=\"Author\">\n"
21612162
"<Exec>\n"
21622163
"<Command>\"%s\\headless-git.exe\"</Command>\n"
2163-
"<Arguments>--exec-path=\"%s\" %s for-each-repo --config=maintenance.repo maintenance run --schedule=%s</Arguments>\n"
2164+
"<Arguments>--exec-path=\"%s\" %s for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%s</Arguments>\n"
21642165
"</Exec>\n"
21652166
"</Actions>\n"
21662167
"</Task>\n";
@@ -2306,7 +2307,7 @@ static int crontab_update_schedule(int run_maintenance, int fd)
23062307
"# replaced in the future by a Git command.\n\n");
23072308

23082309
strbuf_addf(&line_format,
2309-
"%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" %s for-each-repo --config=maintenance.repo maintenance run --schedule=%%s\n",
2310+
"%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" %s for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%%s\n",
23102311
exec_path, exec_path, get_extra_config_parameters());
23112312
fprintf(cron_in, line_format.buf, minute, "1-23", "*", "hourly");
23122313
fprintf(cron_in, line_format.buf, minute, "0", "1-6", "daily");
@@ -2507,7 +2508,7 @@ static int systemd_timer_write_service_template(const char *exec_path)
25072508
"\n"
25082509
"[Service]\n"
25092510
"Type=oneshot\n"
2510-
"ExecStart=\"%s/git\" --exec-path=\"%s\" %s for-each-repo --config=maintenance.repo maintenance run --schedule=%%i\n"
2511+
"ExecStart=\"%s/git\" --exec-path=\"%s\" %s for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%%i\n"
25112512
"LockPersonality=yes\n"
25122513
"MemoryDenyWriteExecute=yes\n"
25132514
"NoNewPrivileges=yes\n"

‎t/t7900-maintenance.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,9 @@ test_expect_success 'start from empty cron table' '
639639
# start registers the repo
640640
git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
641641
642-
grep "for-each-repo --config=maintenance.repo maintenance run --schedule=daily" cron.txt &&
643-
grep "for-each-repo --config=maintenance.repo maintenance run --schedule=hourly" cron.txt &&
644-
grep "for-each-repo --config=maintenance.repo maintenance run --schedule=weekly" cron.txt
642+
grep "for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=daily" cron.txt &&
643+
grep "for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=hourly" cron.txt &&
644+
grep "for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=weekly" cron.txt
645645
'
646646

647647
test_expect_success 'stop from existing schedule' '

0 commit comments

Comments
 (0)