-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"!label" and "!action"; paths instead of path
- Loading branch information
Showing
13 changed files
with
1,234 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 18 additions & 2 deletions
20
src/main/java/org/commonhaus/automation/github/rules/MatchAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
package org.commonhaus.automation.github.rules; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.commonhaus.automation.github.EventData; | ||
import org.commonhaus.automation.github.QueryHelper.QueryContext; | ||
|
||
public class MatchAction { | ||
|
||
public List<String> actions; | ||
public List<String> include = new ArrayList<>(1); | ||
public List<String> exclude = new ArrayList<>(1); | ||
|
||
public MatchAction(List<String> actions) { | ||
actions.forEach(x -> { | ||
if (x.startsWith("!")) { | ||
exclude.add(x.substring(1)); | ||
} else { | ||
include.add(x); | ||
} | ||
}); | ||
} | ||
|
||
public boolean matches(QueryContext queryContext) { | ||
EventData eventData = queryContext.getEventData(); | ||
if (eventData == null) { | ||
return false; | ||
} | ||
return actions.stream().anyMatch(x -> x.equalsIgnoreCase(eventData.getAction())); | ||
String action = eventData.getAction(); | ||
if (!exclude.isEmpty() && exclude.stream().anyMatch(x -> x.equalsIgnoreCase(action))) { | ||
return false; | ||
} | ||
return include.isEmpty() || include.stream().anyMatch(x -> x.equalsIgnoreCase(action)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.