Repository: release-drafter/release-drafter
Pull request #251 (2019-07-01 18:50:11)

Filter PRs from forks
This hasn't been tested yet. Will add tests asap.

Fixes: https://github.com/toolmantim/release-drafter/issues/221


Patch:
diff --git a/bin/generate-fixtures.js b/bin/generate-fixtures.js
index ff92cb4..d52c1b1 100755
--- a/bin/generate-fixtures.js
+++ b/bin/generate-fixtures.js
@@ -5,7 +5,6 @@ const path = require('path')
 const fetch = require('node-fetch')
 const { findCommitsWithAssociatedPullRequestsQuery } = require('../lib/commits')
 
-const REPO_OWNER = 'TimonVS'
 const REPO_NAME = 'release-drafter-test-repo'
 const GITHUB_GRAPHQL_API_ENDPOINT = 'https://api.github.com/graphql'
 const GITHUB_TOKEN = process.env.GITHUB_TOKEN
@@ -16,14 +15,30 @@ if (!GITHUB_TOKEN) {
   )
 }
 
-const branches = [
-  'merge-commit',
-  'rebase-merging',
-  'squash-merging',
-  'overlapping-label',
+const repos = [
+  {
+    owner: 'TimonVS',
+    branch: 'merge-commit',
+  },
+  {
+    owner: 'TimonVS',
+    branch: 'rebase-merging',
+  },
+  {
+    owner: 'TimonVS',
+    branch: 'squash-merging',
+  },
+  {
+    owner: 'TimonVS',
+    branch: 'overlapping-label',
+  },
+  {
+    owner: 'jetersen',
+    branch: 'forking',
+  },
 ]
 
-branches.forEach((branch) => {
+repos.forEach((repo) => {
   const options = {
     method: 'POST',
     headers: {
@@ -33,10 +48,10 @@ branches.forEach((branch) => {
     body: JSON.stringify({
       query: findCommitsWithAssociatedPullRequestsQuery,
       variables: {
-        owner: REPO_OWNER,
+        owner: repo.owner,
         name: REPO_NAME,
-        branch,
-        withPullRequestBody: true
+        branch: repo.branch,
+        withPullRequestBody: true,
       },
     }),
   }
@@ -44,13 +59,19 @@ branches.forEach((branch) => {
   fetch(GITHUB_GRAPHQL_API_ENDPOINT, options)
     .then((response) => response.json())
     .then((data) => {
+      // hack the generated to reduce massive rewrite inside the tests
+      // basically duplicating the possible configs 🤯
+      let string = JSON.stringify(data, null, 2).replace(
+        /TimonVS\/release-drafter-test-repo/g,
+        'toolmantim/release-drafter-test-project'
+      )
       fs.writeFileSync(
         path.resolve(
           __dirname,
           '../test/fixtures/__generated__',
-          `graphql-commits-${branch}.json`
+          `graphql-commits-${repo.branch}.json`
         ),
-        JSON.stringify(data, null, 2) + '\n'
+        string + '\n'
       )
     })
     .catch(console.error)
diff --git a/lib/commits.js b/lib/commits.js
index 3ea8e3b..51507bf 100644
--- a/lib/commits.js
+++ b/lib/commits.js
@@ -38,6 +38,9 @@ module.exports.findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ `
                     author {
                       login
                     }
+                    baseRepository {
+                      nameWithOwner
+                    }
                     mergedAt
                     isCrossRepository
                     labels(first: 10) {
@@ -71,6 +74,7 @@ module.exports.findCommitsWithAssociatedPullRequests = async ({
     withPullRequestBody: config['change-template'].includes('$BODY'),
   }
   const dataPath = ['repository', 'ref', 'target', 'history']
+  const repoNameWithOwner = `${owner}/${repo}`
 
   let data
   if (lastRelease) {
@@ -101,7 +105,7 @@ module.exports.findCommitsWithAssociatedPullRequests = async ({
   const pullRequests = _.uniqBy(
     _.flatten(commits.map((commit) => commit.associatedPullRequests.nodes)),
     'number'
-  )
+  ).filter((pr) => pr.baseRepository.nameWithOwner === repoNameWithOwner)
 
   return { commits, pullRequests }
 }


Test patch:
diff --git a/test/fixtures/__generated__/graphql-commits-forking.json b/test/fixtures/__generated__/graphql-commits-forking.json
new file mode 100644
index 0000000..cf82d0d
--- /dev/null
+++ b/test/fixtures/__generated__/graphql-commits-forking.json
@@ -0,0 +1,527 @@
+{
+  "data": {
+    "repository": {
+      "ref": {
+        "target": {
+          "history": {
+            "totalCount": 14,
+            "pageInfo": {
+              "hasNextPage": false,
+              "endCursor": "96cf76bb3470913a449d505f2011544b661652f4 13"
+            },
+            "nodes": [
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOjk2Y2Y3NmJiMzQ3MDkxM2E0NDlkNTA1ZjIwMTE1NDRiNjYxNjUyZjQ=",
+                "message": "Merge pull request #1 from TimonVS/forking",
+                "author": {
+                  "name": "Joseph Petersen",
+                  "user": {
+                    "login": "jetersen"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "🙅‍♂️ Forking PR 🙅‍♂️",
+                      "number": 1,
+                      "body": "No thanks to forking PRs",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "jetersen/release-drafter-test-repo"
+                      },
+                      "mergedAt": "2020-05-26T20:33:01Z",
+                      "isCrossRepository": true,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOjlhZjJlZWMyYjY4NDA0MWY5ZDE3YmFlM2IwNTAwMjYwNGU5NGE4MzM=",
+                "message": "Merge pull request #28 from TimonVS/add-documentation",
+                "author": {
+                  "name": "Joseph Petersen",
+                  "user": {
+                    "login": "jetersen"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Add documentation",
+                      "number": 28,
+                      "body": "✍️ writing docs all day",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2020-05-26T20:30:59Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": [
+                          {
+                            "name": "skip-changelog"
+                          }
+                        ]
+                      }
+                    },
+                    {
+                      "title": "🙅‍♂️ Forking PR 🙅‍♂️",
+                      "number": 1,
+                      "body": "No thanks to forking PRs",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "jetersen/release-drafter-test-repo"
+                      },
+                      "mergedAt": "2020-05-26T20:33:01Z",
+                      "isCrossRepository": true,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOjYxMTAwMDY2OWJmZTRlYjQ2NjUzYTQ0YjU2MGUzNjFkYjRhZDc5MjQ=",
+                "message": "Merge pull request #27 from TimonVS/chore/update-dependencies",
+                "author": {
+                  "name": "Joseph Petersen",
+                  "user": {
+                    "login": "jetersen"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Update dependencies",
+                      "number": 27,
+                      "body": "📦 Package time! 📦",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2020-05-26T20:29:54Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": []
+                      }
+                    },
+                    {
+                      "title": "🙅‍♂️ Forking PR 🙅‍♂️",
+                      "number": 1,
+                      "body": "No thanks to forking PRs",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "jetersen/release-drafter-test-repo"
+                      },
+                      "mergedAt": "2020-05-26T20:33:01Z",
+                      "isCrossRepository": true,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOjIyOWY2MWY0ODNmNDEzODFjODUwMThkNmZmMGIwZjMyYzk0NWNhMTI=",
+                "message": "Fixed another bug",
+                "author": {
+                  "name": "Timon van Spronsen",
+                  "user": {
+                    "login": "TimonVS"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Bug fixes",
+                      "number": 25,
+                      "body": "🐛 squashing",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2020-05-26T20:20:00Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": [
+                          {
+                            "name": "fix"
+                          }
+                        ]
+                      }
+                    },
+                    {
+                      "title": "🙅‍♂️ Forking PR 🙅‍♂️",
+                      "number": 1,
+                      "body": "No thanks to forking PRs",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "jetersen/release-drafter-test-repo"
+                      },
+                      "mergedAt": "2020-05-26T20:33:01Z",
+                      "isCrossRepository": true,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOmMzYThhNDY4NmFlMDkwNzdmNDk0YzcyOGJhMzc5ZTdhMDU4ZWJiYzY=",
+                "message": "Fixed a bug",
+                "author": {
+                  "name": "Timon van Spronsen",
+                  "user": {
+                    "login": "TimonVS"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Bug fixes",
+                      "number": 25,
+                      "body": "🐛 squashing",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2020-05-26T20:20:00Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": [
+                          {
+                            "name": "fix"
+                          }
+                        ]
+                      }
+                    },
+                    {
+                      "title": "🙅‍♂️ Forking PR 🙅‍♂️",
+                      "number": 1,
+                      "body": "No thanks to forking PRs",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "jetersen/release-drafter-test-repo"
+                      },
+                      "mergedAt": "2020-05-26T20:33:01Z",
+                      "isCrossRepository": true,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOmMwOWM2NmZkNWU2YjU2NTE3MzRlMTI1NGY4YjkzZTZkOWI1ZjI5ZmQ=",
+                "message": "Add big feature (#24)\n\nCo-authored-by: Timon van Spronsen <timonvanspronsen@outlook.com>",
+                "author": {
+                  "name": "Joseph Petersen",
+                  "user": {
+                    "login": "jetersen"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Add big feature",
+                      "number": 24,
+                      "body": "![I'm kind of a big deal](https://media.giphy.com/media/9LFBOD8a1Ip2M/giphy.gif)",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2020-05-26T20:18:35Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": [
+                          {
+                            "name": "feature"
+                          }
+                        ]
+                      }
+                    },
+                    {
+                      "title": "🙅‍♂️ Forking PR 🙅‍♂️",
+                      "number": 1,
+                      "body": "No thanks to forking PRs",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "jetersen/release-drafter-test-repo"
+                      },
+                      "mergedAt": "2020-05-26T20:33:01Z",
+                      "isCrossRepository": true,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOmNjNTliYjUxN2EwOGYxNDhkZThlM2JiMDIxOTkyNjQ1YTQwMGNlNzY=",
+                "message": "Merge pull request #23 from TimonVS/feature/alien-technology",
+                "author": {
+                  "name": "Joseph Petersen",
+                  "user": {
+                    "login": "jetersen"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Add alien technology",
+                      "number": 23,
+                      "body": "Space invasion 👾",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2020-05-26T20:16:44Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": []
+                      }
+                    },
+                    {
+                      "title": "🙅‍♂️ Forking PR 🙅‍♂️",
+                      "number": 1,
+                      "body": "No thanks to forking PRs",
+                      "author": {
+                        "login": "jetersen"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "jetersen/release-drafter-test-repo"
+                      },
+                      "mergedAt": "2020-05-26T20:33:01Z",
+                      "isCrossRepository": true,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOjg1ODExZmJkYmE2OTViYjk3ZDc3YTVlMmE5NjNiMzFmNTM4YTgyMjM=",
+                "message": "Fix typo",
+                "author": {
+                  "name": "Timon van Spronsen",
+                  "user": {
+                    "login": "TimonVS"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Add documentation",
+                      "number": 5,
+                      "body": "✍️ writing docs all day",
+                      "author": {
+                        "login": "TimonVS"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2019-04-27T13:12:08Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": [
+                          {
+                            "name": "skip-changelog"
+                          }
+                        ]
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOmVkM2FmY2QzNmM4MDhlZWIxNWFhZjc0Zjg3MTNiODVkZTA2ZjBhMTk=",
+                "message": "Add documentation",
+                "author": {
+                  "name": "Timon van Spronsen",
+                  "user": {
+                    "login": "TimonVS"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Add documentation",
+                      "number": 5,
+                      "body": "✍️ writing docs all day",
+                      "author": {
+                        "login": "TimonVS"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2019-04-27T13:12:08Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": [
+                          {
+                            "name": "skip-changelog"
+                          }
+                        ]
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOmQyMTM0MjNmOTBjZjU5Y2YxMmRiNmUwMTIxYjgwNzE1NTE4NGRiNmQ=",
+                "message": "Update Mongoose to 5.5.4",
+                "author": {
+                  "name": "Timon van Spronsen",
+                  "user": {
+                    "login": "TimonVS"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Update dependencies",
+                      "number": 4,
+                      "body": "📦 Package time! 📦",
+                      "author": {
+                        "login": "TimonVS"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2019-04-27T13:11:55Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOmQ5NTJjMjU1MDI5N2E4NTE1MmJlMWM4MjYwYjI1ZmI4OWYyODFkNDk=",
+                "message": "Update Express to 4.16.4",
+                "author": {
+                  "name": "Timon van Spronsen",
+                  "user": {
+                    "login": "TimonVS"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "Update dependencies",
+                      "number": 4,
+                      "body": "📦 Package time! 📦",
+                      "author": {
+                        "login": "TimonVS"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2019-04-27T13:11:55Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": []
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOjk0ZGViYjMwZTAyYjExNTc1YWQ0YzBmMDNmMWE1ZjdmOTJiMTFiMjg=",
+                "message": "Add alien technology",
+                "author": {
+                  "name": "Timon van Spronsen",
+                  "user": {
+                    "login": "TimonVS"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": [
+                    {
+                      "title": "👽 Add alien technology",
+                      "number": 1,
+                      "body": "Space invasion 👾",
+                      "author": {
+                        "login": "TimonVS"
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
+                      "mergedAt": "2019-04-27T13:11:29Z",
+                      "isCrossRepository": false,
+                      "labels": {
+                        "nodes": [
+                          {
+                            "name": "feature"
+                          }
+                        ]
+                      }
+                    }
+                  ]
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOjNhYmJhNTkxOGZmN2QxMmZhYjMyMjA1N2ZiZGMyM2I1MzVlNzZkMDE=",
+                "message": "Add project description to README",
+                "author": {
+                  "name": "Ada Lovelace",
+                  "user": null
+                },
+                "associatedPullRequests": {
+                  "nodes": []
+                }
+              },
+              {
+                "id": "MDY6Q29tbWl0MjY3MTQyMTYxOmI5YWI2MGVlNGI4ZjNmYTg0Mjg2NDQ0NjViZGI1YTg4ZDcyZTY1M2E=",
+                "message": "Initial commit",
+                "author": {
+                  "name": "Timon van Spronsen",
+                  "user": {
+                    "login": "TimonVS"
+                  }
+                },
+                "associatedPullRequests": {
+                  "nodes": []
+                }
+              }
+            ]
+          }
+        }
+      }
+    }
+  }
+}
diff --git a/test/fixtures/__generated__/graphql-commits-merge-commit.json b/test/fixtures/__generated__/graphql-commits-merge-commit.json
index 208ee8e..803e177 100644
--- a/test/fixtures/__generated__/graphql-commits-merge-commit.json
+++ b/test/fixtures/__generated__/graphql-commits-merge-commit.json
@@ -24,10 +24,13 @@
                     {
                       "title": "Add documentation",
                       "number": 5,
-                      "body": "✍️ writing docs all",
+                      "body": "✍️ writing docs all day",
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:12:08Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -59,6 +62,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:55Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -86,6 +92,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:47Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -117,6 +126,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:39Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -148,6 +160,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:29Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -175,10 +190,13 @@
                     {
                       "title": "Add documentation",
                       "number": 5,
-                      "body": "✍️ writing docs all",
+                      "body": "✍️ writing docs all day",
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:12:08Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -206,10 +224,13 @@
                     {
                       "title": "Add documentation",
                       "number": 5,
-                      "body": "✍️ writing docs all",
+                      "body": "✍️ writing docs all day",
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:12:08Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -241,6 +262,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:55Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -268,6 +292,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:55Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -295,6 +322,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:47Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -326,6 +356,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:47Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -357,6 +390,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:39Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -388,6 +424,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:39Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -419,6 +458,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:11:29Z",
                       "isCrossRepository": false,
                       "labels": {
diff --git a/test/fixtures/__generated__/graphql-commits-overlapping-label.json b/test/fixtures/__generated__/graphql-commits-overlapping-label.json
index e0b30ef..95dc99b 100644
--- a/test/fixtures/__generated__/graphql-commits-overlapping-label.json
+++ b/test/fixtures/__generated__/graphql-commits-overlapping-label.json
@@ -24,10 +24,13 @@
                     {
                       "title": "Add documentation",
                       "number": 22,
-                      "body": "✍️ writing docs all",
+                      "body": "✍️ writing docs all day",
                       "author": {
                         "login": "jetersen"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2020-02-02T13:55:50Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -59,6 +62,9 @@
                       "author": {
                         "login": "jetersen"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2020-02-02T13:55:28Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -86,6 +92,9 @@
                       "author": {
                         "login": "jetersen"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2020-02-02T13:55:11Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -120,6 +129,9 @@
                       "author": {
                         "login": "jetersen"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2020-02-02T13:54:54Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -151,6 +163,9 @@
                       "author": {
                         "login": "jetersen"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2020-02-02T13:54:23Z",
                       "isCrossRepository": false,
                       "labels": {
diff --git a/test/fixtures/__generated__/graphql-commits-rebase-merging.json b/test/fixtures/__generated__/graphql-commits-rebase-merging.json
index ac70f0c..552dc83 100644
--- a/test/fixtures/__generated__/graphql-commits-rebase-merging.json
+++ b/test/fixtures/__generated__/graphql-commits-rebase-merging.json
@@ -24,10 +24,13 @@
                     {
                       "title": "Add documentation",
                       "number": 10,
-                      "body": "✍️ writing docs all",
+                      "body": "✍️ writing docs all day",
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:32Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -55,10 +58,13 @@
                     {
                       "title": "Add documentation",
                       "number": 10,
-                      "body": "✍️ writing docs all",
+                      "body": "✍️ writing docs all day",
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:32Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -90,6 +96,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:26Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -117,6 +126,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:26Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -144,6 +156,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:20Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -175,6 +190,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:20Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -206,6 +224,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:13Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -237,6 +258,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:13Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -268,6 +292,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:37:59Z",
                       "isCrossRepository": false,
                       "labels": {
diff --git a/test/fixtures/__generated__/graphql-commits-squash-merging.json b/test/fixtures/__generated__/graphql-commits-squash-merging.json
index c5ca9b8..47d708f 100644
--- a/test/fixtures/__generated__/graphql-commits-squash-merging.json
+++ b/test/fixtures/__generated__/graphql-commits-squash-merging.json
@@ -24,10 +24,13 @@
                     {
                       "title": "Add documentation",
                       "number": 15,
-                      "body": "✍️ writing docs all",
+                      "body": "✍️ writing docs all day",
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:39:24Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -59,6 +62,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:39:17Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -86,6 +92,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:39:11Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -117,6 +126,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:39:03Z",
                       "isCrossRepository": false,
                       "labels": {
@@ -148,6 +160,9 @@
                       "author": {
                         "login": "TimonVS"
                       },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
+                      },
                       "mergedAt": "2019-04-27T13:38:47Z",
                       "isCrossRepository": false,
                       "labels": {
diff --git a/test/fixtures/graphql-commits-paginated-1.json b/test/fixtures/graphql-commits-paginated-1.json
index 206b1c9..33f77ac 100644
--- a/test/fixtures/graphql-commits-paginated-1.json
+++ b/test/fixtures/graphql-commits-paginated-1.json
@@ -329,6 +329,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -354,6 +357,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -379,6 +385,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -404,6 +413,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -429,6 +441,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -467,6 +482,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -492,6 +510,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -725,6 +746,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -750,6 +774,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -775,6 +802,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -800,6 +830,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -916,6 +949,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -941,6 +977,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -966,6 +1005,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -991,6 +1033,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1042,6 +1087,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1067,6 +1115,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1105,6 +1156,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1130,6 +1184,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1155,6 +1212,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1180,6 +1240,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1205,6 +1268,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1230,6 +1296,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1255,6 +1324,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1280,6 +1352,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1305,6 +1380,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1330,6 +1408,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1355,6 +1436,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1497,6 +1581,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1522,6 +1609,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -1547,6 +1637,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
diff --git a/test/fixtures/graphql-commits-paginated-2.json b/test/fixtures/graphql-commits-paginated-2.json
index d6dd404..59db1e6 100644
--- a/test/fixtures/graphql-commits-paginated-2.json
+++ b/test/fixtures/graphql-commits-paginated-2.json
@@ -251,6 +251,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
@@ -276,6 +279,9 @@
                       },
                       "labels": {
                         "nodes": []
+                      },
+                      "baseRepository": {
+                        "nameWithOwner": "toolmantim/release-drafter-test-project"
                       }
                     }
                   ]
diff --git a/test/index.test.js b/test/index.test.js
index 9d65c01..10913dd 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -409,7 +409,7 @@ Previous tag: ''
               '/repos/toolmantim/release-drafter-test-project/releases',
               (body) => {
                 expect(body).toMatchObject({
-                  body: `* Change: #5 'Add documentation' ✍️ writing docs all
+                  body: `* Change: #5 'Add documentation' ✍️ writing docs all day
 * Change: #4 'Update dependencies' 📦 Package time! 📦
 * Change: #3 'Bug fixes' 🐛 squashing
 * Change: #2 'Add big feature' ![I'm kind of a big deal](https://media.giphy.com/media/9LFBOD8a1Ip2M/giphy.gif)
@@ -894,7 +894,7 @@ Previous tag: ''
           .reply(200, [require('./fixtures/release')])
 
         nock('https://api.github.com')
-          .post('/graphql', body =>
+          .post('/graphql', (body) =>
             body.query.includes('query findCommitsWithAssociatedPullRequests')
           )
           .reply(
@@ -905,7 +905,7 @@ Previous tag: ''
         nock('https://api.github.com')
           .post(
             '/repos/toolmantim/release-drafter-test-project/releases',
-            body => {
+            (body) => {
               expect(body).toMatchObject({
                 body: `# What's Changed
 
@@ -915,7 +915,7 @@ Previous tag: ''
 * 👽 Add alien technology (#1) @TimonVS
 `,
                 draft: true,
-                tag_name: ''
+                tag_name: '',
               })
               return true
             }
@@ -924,7 +924,7 @@ Previous tag: ''
 
         await probot.receive({
           name: 'push',
-          payload: require('./fixtures/push')
+          payload: require('./fixtures/push'),
         })
 
         expect.assertions(1)
@@ -1206,6 +1206,60 @@ Previous tag: ''
           expect.assertions(1)
         })
       })
+
+      describe('with forked pull request', () => {
+        it('exclude forked pull requests', async () => {
+          getConfigMock()
+
+          nock('https://api.github.com')
+            .get('/repos/toolmantim/release-drafter-test-project/releases')
+            .query(true)
+            .reply(200, [require('./fixtures/release')])
+
+          nock('https://api.github.com')
+            .post('/graphql', (body) =>
+              body.query.includes('query findCommitsWithAssociatedPullRequests')
+            )
+            .reply(
+              200,
+              require('./fixtures/__generated__/graphql-commits-forking.json')
+            )
+
+          nock('https://api.github.com')
+            .post(
+              '/repos/toolmantim/release-drafter-test-project/releases',
+              (body) => {
+                expect(body).toMatchInlineSnapshot(`
+                  Object {
+                    "body": "# What's Changed
+
+                  * Add documentation (#28) @jetersen
+                  * Update dependencies (#27) @jetersen
+                  * Bug fixes (#25) @jetersen
+                  * Add big feature (#24) @jetersen
+                  * Add alien technology (#23) @jetersen
+                  * Add documentation (#5) @TimonVS
+                  * Update dependencies (#4) @TimonVS
+                  ",
+                    "draft": true,
+                    "name": "",
+                    "prerelease": false,
+                    "tag_name": "",
+                  }
+                `)
+                return true
+              }
+            )
+            .reply(200, require('./fixtures/release'))
+
+          await probot.receive({
+            name: 'push',
+            payload: require('./fixtures/push'),
+          })
+
+          expect.assertions(1)
+        })
+      })
     })
 
     describe('pagination', () => {