Make it possible to specify several merge order keys, including label
An easier version of #4 (closed) where priorities are not taken into account.
This MR implements point 2 of #4 (closed) (that is, "Let --merge-order take several sort keys") and a simplified version of point 1 disregarding scoped labels and priorities. That is:
- Add a new sorting key
label:LABELNAME
.
Intuitively, this sorts MRs on whether they have the label LABELNAME. More formally, two MRs are ordered thus bylabel:LABELNAME
:- MR1 > MR2 if only MR1 has LABELNAME
- MR2 > MR1 if only MR2 has LABELNAME
- MR1 == MR2 if both MR1 & MR2 have LABELNAME or neither has
- Let
--merge-order
take several sort keys. MRs are first sorted by the first key, then the second if they have the same value for the first, etc. For instance, by passing--merge-order label=urgent,assigned_at
MRs are first ordered on whether they have the labelurgent
. Then, for MRs with the label urgent, MRs are ordered by the time at which they were assigned to marge.
Deploying
To use this feature, suffice to pass --merge-order label=LABELNAME,created_at
, or set it through the configuration file.
For instance, setting merge-order: label=marge-urgent,assigned_at
here.
Additional testing
In addition to the unit/integration tests in the MR, i've run the following tests scenarios. I hope they are sufficiently self-explanatory:
Test MR1 created earlier than MR2: --merge-order created_at
-
Created MR1: arvidnl/margebot-sandbox!254 (merged) -
Created MR2: arvidnl/margebot-sandbox!255 (closed) -
Running marge-bot -
Waiting for 254 to merge... -
MR 254 was merged -
Test concluded!
Test MR2 updated earlier than MR1: --merge-order updated_at
-
Created MR1: arvidnl/margebot-sandbox!256 (closed) -
Created MR2: arvidnl/margebot-sandbox!257 (merged) -
Updating 257 -
Updating 256 -
Running marge-bot... -
Waiting for 257 to merge... -
MR 257 was merged -
Test concluded!
Test MR1 created earlier than MR2: --merge-order created_at,updated_at
-
Created MR1: arvidnl/margebot-sandbox!258 (merged) -
Created MR2: arvidnl/margebot-sandbox!259 (closed) -
Running marge-bot -
Waiting for 258 to merge... -
MR 258 was merged -
Test concluded!
Test MR2 updated earlier than MR1: --merge-order updated_at,created_at
-
Created MR1: arvidnl/margebot-sandbox!260 (closed) -
Created MR2: arvidnl/margebot-sandbox!261 (merged) -
Updating 261 -
Updating 260 -
Running marge-bot... -
Waiting for 261 to merge... -
MR 261 was merged -
Test concluded!
Test MR1 has no label, MR2 is labelled foobar: --merge-order label=foobar,created_at
-
Created MR1: arvidnl/margebot-sandbox!262 (closed) -
Created MR2 with label foobar: arvidnl/margebot-sandbox!263 (merged) -
Running marge-bot... -
Waiting for 263 to merge... -
MR 263 was merged -
Test concluded!
Test MR1 and MR2 are labelled foobar: --merge-order label=foobar,created_at
-
Created MR1 with label foobar: arvidnl/margebot-sandbox!264 (merged) -
Created MR2 with label foobar: arvidnl/margebot-sandbox!265 (closed) -
Running marge-bot with --merge-order label=foobar,created_at... -
Waiting for 264 to merge... -
MR 264 was merged -
Test concluded!
Edited by Arvid Jakobsson