Skip to content

Commit

Permalink
Exclude merge commits
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Nov 3, 2023
1 parent 4affb79 commit d17d24e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion plugins/github-enricher/sponsorFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ const getUserContributionsNoCache = async (org, project, inPath) => {
edges{
node{
... on Commit{
parents(first: 1) {
totalCount
}
author {
user {
login
Expand All @@ -121,7 +125,11 @@ const getUserContributionsNoCache = async (org, project, inPath) => {
const history = body?.data?.repository?.defaultBranchRef?.target?.history?.edges

if (history && Array.isArray(history)) {
let users = history.map(o => o?.node?.author?.user)

// Filter out merge commits
const historyWithoutMerges = history.filter(o => o?.node?.parents?.totalCount === 1)

let users = historyWithoutMerges.map(o => o?.node?.author?.user)

// Some commits have an author who doesn't have a github mapping, so filter those out
users = users.filter(user => user !== null && user !== undefined)
Expand Down
8 changes: 5 additions & 3 deletions src/templates/extension-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ const ExtensionDetailTemplate = ({

{metadata?.sourceControl?.contributors && metadata?.sourceControl?.contributors.length > 0 && (
<TabPanel>
<DocumentationHeading>Recent Contributors</DocumentationHeading>
<DocumentationSection>
<DocumentationHeading>Recent Contributors</DocumentationHeading>

{!extensionRootUrl && (
<p>Commits to this extension's repository in the past six months (including merge commits).</p>)}
<p>Commits to this extension's repository in the past six months (excluding merge commits).</p>)}
{extensionRootUrl && (
<p>Commits to <a href={extensionRootUrl}>this extension's source code</a> in the past six months
(including merge commits).</p>)}
(excluding merge commits).</p>)}

<ChartHolder>
<ContributionsChart contributors={metadata.sourceControl.contributors} />
Expand All @@ -271,6 +272,7 @@ const ExtensionDetailTemplate = ({
minute: "numeric"
})}.</i></p>
)}
</DocumentationSection>
</TabPanel>)
}
</Tabs>
Expand Down

0 comments on commit d17d24e

Please sign in to comment.