From 456e228a58071aa712b72aad4c1fb785ab442c15 Mon Sep 17 00:00:00 2001 From: Aline Abler Date: Thu, 27 Jun 2024 15:26:48 +0200 Subject: [PATCH] Add documentation --- README.md | 19 +++++++++++++++++++ task/task.go | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c1bd644..fdd3d0d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,25 @@ You'll need a GitLab access token with read-write access to all the repositories ./gitlab-scheduled-merge -t [GITLAB_TOKEN] --gitlab-base-url [BASE_URL] ``` +Your repositories need to be configured for scheduled automerge by adding a config file to the tree, which defines the time windows during which scheduled MRs can be merged. +By default, this file is called `.merge-schedule.yml`. + +`merge-schedule.yml`: +``` +mergeWindows: +- schedule: + cron: '0 2 * * *' # cron schedule which specifies the start of each merge window + isoWeek: '@even' # optional, can be @even or @odd to restrict the cron schedule to even/odd week numbers, or an integer to restrict it to one specific week of the year + location: 'Europe/Zurich' # optional, specify the time zone to interpret the cron schedule + maxDelay: '1h' # duration for which the merge window remains active +``` + +The config file is taken from the source branch of the merge request that is to be scheduled. + +If multiple schedules are specified, merge requests are merged if at least one of them is active. + +Whenever a merge request is labeled with the correct label (by default `scheduled`), the application will find it and merge it if a merge window is currently active, or post a comment indicating when the next merge window takes place. + ## License BSD 3-Clause License diff --git a/task/task.go b/task/task.go index 940d95e..2ed1d04 100644 --- a/task/task.go +++ b/task/task.go @@ -155,7 +155,7 @@ func (w MergeWindow) getNextActiveWindowStartTime(t time.Time) (time.Time, error if w.Schedule.Location != "" { l, err := time.LoadLocation(w.Schedule.Location) if err != nil { - return time.Time{}, fmt.Errorf("Failed to load location for merge window: %w", err) + return time.Time{}, fmt.Errorf("failed to load location for merge window: %w", err) } location = l } @@ -164,7 +164,7 @@ func (w MergeWindow) getNextActiveWindowStartTime(t time.Time) (time.Time, error sched, err := cron.ParseStandard(w.Schedule.Cron) if err != nil { - return time.Time{}, fmt.Errorf("Failed to parse cron schedule: %w", err) + return time.Time{}, fmt.Errorf("failed to parse cron schedule: %w", err) } nextRun := sched.Next(earliestTime)