Skip to content

Commit 1ae1155

Browse files
committed
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 <[email protected]>
1 parent abd7968 commit 1ae1155

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Diff for: builtin/gc.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit
18581858
"<string>%s/git</string>\n"
18591859
"<string>--exec-path=%s</string>\n"
18601860
"<string>for-each-repo</string>\n"
1861+
"<string>--keep-going</string>\n"
18611862
"<string>--config=maintenance.repo</string>\n"
18621863
"<string>maintenance</string>\n"
18631864
"<string>run</string>\n"
@@ -2100,7 +2101,7 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
21002101
"<Actions Context=\"Author\">\n"
21012102
"<Exec>\n"
21022103
"<Command>\"%s\\headless-git.exe\"</Command>\n"
2103-
"<Arguments>--exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%s</Arguments>\n"
2104+
"<Arguments>--exec-path=\"%s\" for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%s</Arguments>\n"
21042105
"</Exec>\n"
21052106
"</Actions>\n"
21062107
"</Task>\n";
@@ -2245,7 +2246,7 @@ static int crontab_update_schedule(int run_maintenance, int fd)
22452246
"# replaced in the future by a Git command.\n\n");
22462247

22472248
strbuf_addf(&line_format,
2248-
"%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%%s\n",
2249+
"%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%%s\n",
22492250
exec_path, exec_path);
22502251
fprintf(cron_in, line_format.buf, minute, "1-23", "*", "hourly");
22512252
fprintf(cron_in, line_format.buf, minute, "0", "1-6", "daily");
@@ -2446,7 +2447,7 @@ static int systemd_timer_write_service_template(const char *exec_path)
24462447
"\n"
24472448
"[Service]\n"
24482449
"Type=oneshot\n"
2449-
"ExecStart=\"%s/git\" --exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%%i\n"
2450+
"ExecStart=\"%s/git\" --exec-path=\"%s\" for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%%i\n"
24502451
"LockPersonality=yes\n"
24512452
"MemoryDenyWriteExecute=yes\n"
24522453
"NoNewPrivileges=yes\n"

Diff for: 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)