File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
use anyhow:: anyhow;
2
2
use octocrab:: models:: StatusState ;
3
-
4
- use std :: sync:: Arc ;
3
+ use std :: sync :: { Arc , OnceLock } ;
4
+ use tokio :: sync:: Mutex ;
5
5
6
6
use crate :: {
7
7
BorsContext ,
@@ -26,6 +26,8 @@ pub(super) const AUTO_MERGE_BRANCH_NAME: &str = "automation/bors/auto-merge";
26
26
/// This branch should run CI checks.
27
27
pub ( super ) const AUTO_BRANCH_NAME : & str = "automation/bors/auto" ;
28
28
29
+ static MERGE_QUEUE_LOCK : OnceLock < Mutex < ( ) > > = OnceLock :: new ( ) ;
30
+
29
31
pub type MergeQueueEvent = ( ) ;
30
32
31
33
enum MergeResult {
@@ -34,6 +36,10 @@ enum MergeResult {
34
36
}
35
37
36
38
pub async fn handle_merge_queue ( ctx : Arc < BorsContext > ) -> anyhow:: Result < ( ) > {
39
+ // Prevent concurrent merge queue processing.
40
+ let lock = MERGE_QUEUE_LOCK . get_or_init ( || Mutex :: new ( ( ) ) ) ;
41
+ let _guard = lock. lock ( ) . await ;
42
+
37
43
let repos: Vec < Arc < RepositoryState > > =
38
44
ctx. repositories . read ( ) . unwrap ( ) . values ( ) . cloned ( ) . collect ( ) ;
39
45
You can’t perform that action at this time.
0 commit comments