Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions source/app/metrics/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,43 @@ export const filters = {
console.debug(`metrics/filters/repo > filter ${repo} (${include ? "included" : "excluded"})`)
return include
},
/**Organization filter (exclusion list, same semantics as repo) */
organization(organizationLogin, patterns, {debug = true} = {}) {
if (!patterns.length)
return true

const org = `${organizationLogin}`.toLocaleLowerCase()

let include = true
if (patterns[0] === "@use.patterns") {
if (debug)
console.debug(`metrics/filters/organization > ${org} > using advanced pattern matching`)
const options = {nocase: true}
for (let pattern of patterns) {
if (pattern.startsWith("#"))
continue
let action = false
if ((pattern.startsWith("+")) || (pattern.startsWith("-"))) {
action = pattern.charAt(0) === "+"
pattern = pattern.substring(1)
}
if (minimatch(org, pattern, options)) {
if (debug)
console.debug(`metrics/filters/organization > ${org} matches ${action ? "including" : "excluding"} pattern ${pattern}`)
include = action
}
}
}
else {
if (debug)
console.debug(`metrics/filters/organization > ${org} > using basic pattern matching`)
include = !patterns.includes(org)
}

if (debug)
console.debug(`metrics/filters/organization > filter ${org} (${include ? "included" : "excluded"})`)
return include
},
/**Text filter*/
text(text, patterns, {debug = true} = {}) {
//Disable filtering when no pattern is provided
Expand Down
24 changes: 24 additions & 0 deletions source/plugins/notable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ Some repositories may not be able to reported advanced stats and in the case the
<b>type:</b> <code>array</code>
<i>(newline-separated)</i>
<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_notable_organizations_skipped</code></h4></td>
<td rowspan="2"><p>Skipped organizations. Exclude contributions from these organizations in both badges and repository lists. Supports the same pattern syntax as <code>plugin_notable_skipped</code> (basic and <code>@use.patterns</code> with minimatch for wildcards, e.g. <code>org-*</code>).</p>
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap"><b>type:</b> <code>array</code>
<i>(newline-separated)</i>
<br>
<b>default:</b> ""<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_notable_from</code></h4></td>
Expand Down Expand Up @@ -159,6 +170,19 @@ with:
base: ""
plugin_notable: yes

```
```yaml
name: Contributions (excluding organizations)
uses: lowlighter/metrics@latest
with:
filename: metrics.plugin.notable.svg
token: ${{ secrets.METRICS_TOKEN }}
base: ""
plugin_notable: yes
plugin_notable_organizations_skipped: |
my-org
other-org

```
```yaml
name: Indepth analysis
Expand Down
3 changes: 2 additions & 1 deletion source/plugins/notable/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default async function({login, q, imports, rest, graphql, data, account,
return null

//Load inputs
let {filter, skipped, repositories, types, from, indepth, self} = imports.metadata.plugins.notable.inputs({data, account, q})
let {filter, skipped, "organizations.skipped": organizationsSkipped = [], repositories, types, from, indepth, self} = imports.metadata.plugins.notable.inputs({data, account, q})
skipped.push(...data.shared["repositories.skipped"])

//Iterate through contributed repositories
Expand All @@ -21,6 +21,7 @@ export default async function({login, q, imports, rest, graphql, data, account,
cursor = edges?.[edges?.length - 1]?.cursor
edges
.filter(({node}) => imports.filters.repo(node, skipped))
.filter(({node}) => !node.isInOrganization || imports.filters.organization(node.owner.login, organizationsSkipped))
.filter(({node}) => ({all: true, organization: node.isInOrganization, user: !node.isInOrganization}[from]))
.filter(({node}) => imports.filters.github(filter, {name: node.nameWithOwner, user: node.owner.login, stars: node.stargazers.totalCount, watchers: node.watchers.totalCount, forks: node.forks.totalCount}))
.map(({node}) => contributions.push({handle: node.nameWithOwner, stars: node.stargazers.totalCount, issues: node.issues.totalCount, pulls: node.pullRequests.totalCount, organization: node.isInOrganization, avatarUrl: node.owner.avatarUrl}))
Expand Down
13 changes: 13 additions & 0 deletions source/plugins/notable/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ inputs:
example: my-repo-1, my-repo-2, owner/repo-3, ...
inherits: repositories_skipped

plugin_notable_organizations_skipped:
description: |
Skipped organizations

Exclude contributions from these organizations in both badges and repository lists.
Supports the same pattern syntax as [`plugin_notable_skipped`](/source/plugins/notable/README.md#plugin_notable_skipped) (basic and `@use.patterns` with minimatch for wildcards, e.g. `org-*`).
type: array
format:
- newline-separated
- comma-separated
default: ""
example: my-org, other-org, ...

plugin_notable_from:
description: |
Repository owner account type filter
Expand Down
Loading