@@ -260,27 +260,33 @@ pub(crate) struct RelabelConfig {
260260
261261impl RelabelConfig {
262262 pub ( crate ) fn retrieve_command_from_alias ( & self , input : RelabelCommand ) -> RelabelCommand {
263+ let mut deltas = vec ! [ ] ;
263264 match & self . configs {
264265 Some ( configs) => {
265- dbg ! ( & configs) ;
266- // get only the first token from the command
267- // extract the "alias" from the RelabelCommand
266+ // parse all tokens: if one matches an alias, extract the labels
267+ // else, it will assumed to be a valid label
268268 if input. 0 . len ( ) > 0 {
269- let name = input. 0 . get ( 0 ) . unwrap ( ) ;
270- let name = name. label ( ) . as_str ( ) ;
271- // check if this alias matches any RelabelRuleConfig key in our config
272- // extract the labels and build a new command
273- if configs. contains_key ( name) {
274- let ( _alias, cfg) = configs. get_key_value ( name) . unwrap ( ) ;
275- return cfg. to_command ( ) ;
269+ for tk in input. 0 . iter ( ) {
270+ let name = tk. label ( ) . as_str ( ) ;
271+ if configs. contains_key ( name) {
272+ if let Some ( ( _, cfg) ) = configs. get_key_value ( name) {
273+ let cmd = cfg. to_command ( ) ;
274+ for d in cmd. 0 {
275+ deltas. push ( d) ;
276+ }
277+ }
278+ } else {
279+ deltas. push ( tk. clone ( ) ) ;
280+ }
276281 }
277282 }
278283 }
279284 None => {
285+ // nothing to do, return the original command
280286 return input;
281287 }
282288 } ;
283- input
289+ RelabelCommand ( deltas )
284290 }
285291}
286292
@@ -807,11 +813,11 @@ mod tests {
807813
808814 [mentions."src/"]
809815 cc = ["@someone"]
810-
816+
811817 [mentions."target/"]
812818 message = "This is a message."
813819 cc = ["@someone"]
814-
820+
815821 [mentions."#[rustc_attr]"]
816822 type = "content"
817823 message = "This is a message."
@@ -1080,6 +1086,35 @@ mod tests {
10801086 ) ;
10811087 }
10821088
1089+ #[ test]
1090+ fn relabel_alias_config ( ) {
1091+ let config = r#"
1092+ [relabel.to-stable]
1093+ add-labels = ["regression-from-stable-to-stable"]
1094+ rem-labels = ["regression-from-stable-to-beta", "regression-from-stable-to-nightly"]
1095+ "# ;
1096+ let config = toml:: from_str :: < Config > ( & config) . unwrap ( ) ;
1097+
1098+ let mut relabel_configs = HashMap :: new ( ) ;
1099+ relabel_configs. insert (
1100+ "to-stable" . into ( ) ,
1101+ RelabelRuleConfig {
1102+ add_labels : vec ! [ "regression-from-stable-to-stable" . to_string( ) ] ,
1103+ rem_labels : vec ! [
1104+ "regression-from-stable-to-beta" . to_string( ) ,
1105+ "regression-from-stable-to-nightly" . to_string( ) ,
1106+ ] ,
1107+ } ,
1108+ ) ;
1109+
1110+ let expected_cfg = RelabelConfig {
1111+ allow_unauthenticated : vec ! [ ] ,
1112+ configs : Some ( relabel_configs) ,
1113+ } ;
1114+
1115+ assert_eq ! ( config. relabel, Some ( expected_cfg) ) ;
1116+ }
1117+
10831118 #[ test]
10841119 fn issue_links_uncanonicalized ( ) {
10851120 let config = r#"
0 commit comments