Open IvanFon opened 4 years ago
We could support syntax similar to MongoDB query operators https://docs.mongodb.com/manual/reference/operator/query/ Maybe not all of them, but the appropriate subset. So eg. if an expression is defined as
{
"type": "SOME_TYPE",
"pattern": "SOME_PATTERN"
}
We could use following syntax
{
"pr": {
"bugfix": {
"requires": 1,
"conditions": {
"$and": [
{
"type": "branchMatches",
"pattern": "^bugfix"
},
{
"$or": [
{
"type": "titleMatches",
"pattern": "bugfix"
},
{
"$not": {
"type": "titleMatches",
"pattern": "feature"
}
}
]
}
]
}
}
}
}
For backwards compatibility we could support conditions
to be []
or {}
It is good to have []
option to use with more simple matches
That's a good idea! Do you have any use cases for this already? I think I'm going to backlog this one until users needs it.
I don't have a use case yet, but I didn't start using this action. We will see soon :D
Ok I thing I see a use case for that, for Not
and And
operator. In Linaria https://github.com/callstack/linaria/ we support different bundlers like webpack, rollup.
I would like to label the issues based on with which bunder it is related. But if someone type
"it works in webpack, but crashes in rollup" I cannot determine to which bundler it Is related just by checking for the presence of rollup
and webpack
words. I could use Not
and And
to ensure that I add a label only if one of there words is present.
+1 would love to have. for instance I've got the following check which I would love to override by using a simple $or
so if one of my admins confirm the bug, it gets the label, otherwise, all the other conditions are required:
{
"issue": {
"confirmed": {
"requires": 1,
"conditions": {
"$or": [
{
"$and": [
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] bug Confirmed by (@.*& .*){4,}/im"
},
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] have reproduced on my application version/im"
},
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] have reproduced on clean installation/im"
},
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] have reproduced on development build/im"
},
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] have included logs or screenshots/im"
},
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] have contacted support/im"
},
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] have asked the community/im"
},
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] have linked any related/im"
}
]
},
{
"type": "descriptionMatches",
"pattern": "/^- \\[x\\] bug Confirmed by (@.*& )*@(tgtgamer|videndum\\/.*)/im"
}
]
}
}
}
}
Finally got round to adding this to my version of the labelled. Will soon push to #24 so people can use it
Currently, when you want to match multiple conditions, you can only specify how many need to match. A different syntax could allow you to specify more complex combinations using and, or, not, etc. operators.
I'm not sure what this would look like, and I'm not sure what it would look. It may not be useful enough to warrant the complexity.