[Danger] Add a remote for the upstream repo, and try use that for the merge base for danger (#12229)
Orta committed
Feb 15, 2018 at 07:19 UTC
e8ee1b92dc2b826f7ba9631a051e56f261b12419
1 file changed
+6
-9
dangerfile.js
+6
-9
@@ -73,14 +73,6 @@ function setBoldness(row, isBold) {
73
}
74
}
75
76
-/**
77
- * Gets the commit that represents the merge between the current branch
78
- * and master.
79
- */
80
-function getMergeBase() {
81
- return git('merge-base HEAD origin/master');
82
-}
83
-
76
/**
77
* Gets the commit that represents the merge between the current branch
78
* and master.
@@ -100,7 +92,12 @@ function git(args) {
92
(async function() {
93
// Use git locally to grab the commit which represents the place
94
// where the branches differ
103
- const mergeBaseCommit = await getMergeBase();
95
+ const upstreamRepo = danger.github.pr.base.repo.full_name;
96
+ const upstreamRef = danger.github.pr.base.ref;
97
+ await git(`remote add upstream https://github.com/${upstreamRepo}.git`);
98
+ await git('fetch upstream');
99
+ const mergeBaseCommit = await git(`merge-base HEAD upstream/${upstreamRef}`);
100
+
101
const commitURL = sha =>
102
`http://react.zpao.com/builds/master/_commits/${sha}/results.json`;
103
const response = await fetch(commitURL(mergeBaseCommit));