mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
refactor: drop pr.isStale (#6826)
This commit is contained in:
parent
d6bfaa665f
commit
eaffc19253
14 changed files with 15 additions and 186 deletions
|
@ -1423,7 +1423,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -1862,7 +1861,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -1884,7 +1882,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -1906,7 +1903,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -2029,7 +2025,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -2101,7 +2096,6 @@ Object {
|
||||||
"createdAt": undefined,
|
"createdAt": undefined,
|
||||||
"displayNumber": "Pull Request #undefined",
|
"displayNumber": "Pull Request #undefined",
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"isStale": false,
|
|
||||||
"number": undefined,
|
"number": undefined,
|
||||||
"reviewers": Array [],
|
"reviewers": Array [],
|
||||||
"state": "merged",
|
"state": "merged",
|
||||||
|
@ -5047,7 +5041,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -5486,7 +5479,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -5508,7 +5500,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -5530,7 +5521,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -5653,7 +5643,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": true,
|
"hasReviewers": true,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"reviewers": Array [
|
"reviewers": Array [
|
||||||
"userName2",
|
"userName2",
|
||||||
|
@ -5725,7 +5714,6 @@ Object {
|
||||||
"createdAt": undefined,
|
"createdAt": undefined,
|
||||||
"displayNumber": "Pull Request #undefined",
|
"displayNumber": "Pull Request #undefined",
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"isStale": false,
|
|
||||||
"number": undefined,
|
"number": undefined,
|
||||||
"reviewers": Array [],
|
"reviewers": Array [],
|
||||||
"state": "merged",
|
"state": "merged",
|
||||||
|
|
|
@ -280,10 +280,6 @@ export async function getPr(
|
||||||
pr.canMerge = !!mergeRes.body.canMerge;
|
pr.canMerge = !!mergeRes.body.canMerge;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await git.branchExists(pr.branchName)) {
|
|
||||||
pr.isStale = await git.isBranchStale(pr.branchName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pr;
|
return pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"state": "open",
|
"state": "open",
|
||||||
"targetBranch": "master",
|
"targetBranch": "master",
|
||||||
|
@ -899,7 +898,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #3",
|
"displayNumber": "Pull Request #3",
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 3,
|
"number": 3,
|
||||||
"state": "open",
|
"state": "open",
|
||||||
"targetBranch": "master",
|
"targetBranch": "master",
|
||||||
|
@ -916,7 +914,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"state": "open",
|
"state": "open",
|
||||||
"targetBranch": "master",
|
"targetBranch": "master",
|
||||||
|
@ -933,7 +930,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"state": "open",
|
"state": "open",
|
||||||
"targetBranch": "master",
|
"targetBranch": "master",
|
||||||
|
@ -1029,7 +1025,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #5",
|
"displayNumber": "Pull Request #5",
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 5,
|
"number": 5,
|
||||||
"state": "open",
|
"state": "open",
|
||||||
"targetBranch": "master",
|
"targetBranch": "master",
|
||||||
|
|
|
@ -290,10 +290,6 @@ export async function getPr(prNo: number): Promise<Pr | null> {
|
||||||
// TODO: Is that correct? Should we check getBranchStatus like gitlab?
|
// TODO: Is that correct? Should we check getBranchStatus like gitlab?
|
||||||
res.canMerge = !res.isConflicted;
|
res.canMerge = !res.isConflicted;
|
||||||
}
|
}
|
||||||
if (await git.branchExists(pr.source.branch.name)) {
|
|
||||||
res.isStale = await git.isBranchStale(pr.source.branch.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.hasReviewers = is.nonEmptyArray(pr.reviewers);
|
res.hasReviewers = is.nonEmptyArray(pr.reviewers);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -46,7 +46,6 @@ export interface Pr {
|
||||||
hasAssignees?: boolean;
|
hasAssignees?: boolean;
|
||||||
hasReviewers?: boolean;
|
hasReviewers?: boolean;
|
||||||
isConflicted?: boolean;
|
isConflicted?: boolean;
|
||||||
isStale?: boolean;
|
|
||||||
labels?: string[];
|
labels?: string[];
|
||||||
number?: number;
|
number?: number;
|
||||||
reviewers?: string[];
|
reviewers?: string[];
|
||||||
|
|
|
@ -9,7 +9,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #42",
|
"displayNumber": "Pull Request #42",
|
||||||
"hasAssignees": false,
|
"hasAssignees": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": undefined,
|
|
||||||
"number": 42,
|
"number": 42,
|
||||||
"sha": "0d9c7726c3d628b7e28af234595cfd20febdbf8e",
|
"sha": "0d9c7726c3d628b7e28af234595cfd20febdbf8e",
|
||||||
"sourceRepo": "some/repo",
|
"sourceRepo": "some/repo",
|
||||||
|
@ -28,7 +27,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #42",
|
"displayNumber": "Pull Request #42",
|
||||||
"hasAssignees": false,
|
"hasAssignees": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": undefined,
|
|
||||||
"number": 42,
|
"number": 42,
|
||||||
"sha": "0d9c7726c3d628b7e28af234595cfd20febdbf8e",
|
"sha": "0d9c7726c3d628b7e28af234595cfd20febdbf8e",
|
||||||
"sourceRepo": "some/repo",
|
"sourceRepo": "some/repo",
|
||||||
|
@ -47,7 +45,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #1",
|
"displayNumber": "Pull Request #1",
|
||||||
"hasAssignees": false,
|
"hasAssignees": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 1,
|
"number": 1,
|
||||||
"sha": "some-head-sha",
|
"sha": "some-head-sha",
|
||||||
"sourceRepo": "some/repo",
|
"sourceRepo": "some/repo",
|
||||||
|
@ -66,7 +63,6 @@ Object {
|
||||||
"displayNumber": "Pull Request #1",
|
"displayNumber": "Pull Request #1",
|
||||||
"hasAssignees": false,
|
"hasAssignees": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": false,
|
|
||||||
"number": 1,
|
"number": 1,
|
||||||
"sha": "some-head-sha",
|
"sha": "some-head-sha",
|
||||||
"sourceRepo": "some/repo",
|
"sourceRepo": "some/repo",
|
||||||
|
@ -86,7 +82,6 @@ Array [
|
||||||
"displayNumber": "Pull Request #1",
|
"displayNumber": "Pull Request #1",
|
||||||
"hasAssignees": false,
|
"hasAssignees": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": undefined,
|
|
||||||
"number": 1,
|
"number": 1,
|
||||||
"sha": "some-head-sha",
|
"sha": "some-head-sha",
|
||||||
"sourceRepo": "some/repo",
|
"sourceRepo": "some/repo",
|
||||||
|
@ -102,7 +97,6 @@ Array [
|
||||||
"displayNumber": "Pull Request #2",
|
"displayNumber": "Pull Request #2",
|
||||||
"hasAssignees": false,
|
"hasAssignees": false,
|
||||||
"isConflicted": false,
|
"isConflicted": false,
|
||||||
"isStale": undefined,
|
|
||||||
"number": 2,
|
"number": 2,
|
||||||
"sha": "other-head-sha",
|
"sha": "other-head-sha",
|
||||||
"sourceRepo": "some/repo",
|
"sourceRepo": "some/repo",
|
||||||
|
|
|
@ -103,7 +103,6 @@ function toRenovatePR(data: helper.PR): Pr | null {
|
||||||
createdAt: data.created_at,
|
createdAt: data.created_at,
|
||||||
canMerge: data.mergeable,
|
canMerge: data.mergeable,
|
||||||
isConflicted: !data.mergeable,
|
isConflicted: !data.mergeable,
|
||||||
isStale: undefined,
|
|
||||||
hasAssignees: !!(data.assignee?.login || is.nonEmptyArray(data.assignees)),
|
hasAssignees: !!(data.assignee?.login || is.nonEmptyArray(data.assignees)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -464,13 +463,6 @@ const platform: Platform = {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enrich pull request with additional information which is more expensive to fetch
|
|
||||||
if (pr.state !== 'closed') {
|
|
||||||
if (pr.isStale === undefined) {
|
|
||||||
pr.isStale = await git.isBranchStale(pr.branchName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pr;
|
return pr;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1866,7 +1866,6 @@ Object {
|
||||||
"full_name": "some/repo",
|
"full_name": "some/repo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"isStale": true,
|
|
||||||
"number": 91,
|
"number": 91,
|
||||||
"sha": undefined,
|
"sha": undefined,
|
||||||
"state": "open",
|
"state": "open",
|
||||||
|
@ -2057,17 +2056,6 @@ Array [
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"url": "https://api.github.com/repos/some/repo/pulls/91",
|
"url": "https://api.github.com/repos/some/repo/pulls/91",
|
||||||
},
|
},
|
||||||
Object {
|
|
||||||
"headers": Object {
|
|
||||||
"accept": "application/vnd.github.v3+json",
|
|
||||||
"accept-encoding": "gzip, deflate",
|
|
||||||
"authorization": "token abc123",
|
|
||||||
"host": "api.github.com",
|
|
||||||
"user-agent": "https://github.com/renovatebot/renovate",
|
|
||||||
},
|
|
||||||
"method": "GET",
|
|
||||||
"url": "https://api.github.com/repos/some/repo/git/refs/heads/master",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -2089,7 +2077,6 @@ Object {
|
||||||
"full_name": "other/repo",
|
"full_name": "other/repo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"isStale": true,
|
|
||||||
"number": 90,
|
"number": 90,
|
||||||
"sha": undefined,
|
"sha": undefined,
|
||||||
"state": "open",
|
"state": "open",
|
||||||
|
@ -2327,17 +2314,6 @@ Array [
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"url": "https://api.github.com/repos/some/repo/pulls/90",
|
"url": "https://api.github.com/repos/some/repo/pulls/90",
|
||||||
},
|
},
|
||||||
Object {
|
|
||||||
"headers": Object {
|
|
||||||
"accept": "application/vnd.github.v3+json",
|
|
||||||
"accept-encoding": "gzip, deflate",
|
|
||||||
"authorization": "token abc123",
|
|
||||||
"host": "api.github.com",
|
|
||||||
"user-agent": "https://github.com/renovatebot/renovate",
|
|
||||||
},
|
|
||||||
"method": "GET",
|
|
||||||
"url": "https://api.github.com/repos/forked/repo/git/refs/heads/master",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -3007,17 +2983,6 @@ Array [
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"url": "https://api.github.com/graphql",
|
"url": "https://api.github.com/graphql",
|
||||||
},
|
},
|
||||||
Object {
|
|
||||||
"headers": Object {
|
|
||||||
"accept": "application/vnd.github.v3+json",
|
|
||||||
"accept-encoding": "gzip, deflate",
|
|
||||||
"authorization": "token abc123",
|
|
||||||
"host": "api.github.com",
|
|
||||||
"user-agent": "https://github.com/renovatebot/renovate",
|
|
||||||
},
|
|
||||||
"method": "GET",
|
|
||||||
"url": "https://api.github.com/repos/some/repo/git/refs/heads/master",
|
|
||||||
},
|
|
||||||
Object {
|
Object {
|
||||||
"graphql": Object {
|
"graphql": Object {
|
||||||
"query": Object {
|
"query": Object {
|
||||||
|
@ -3073,7 +3038,6 @@ Object {
|
||||||
"hasAssignees": false,
|
"hasAssignees": false,
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"isConflicted": true,
|
"isConflicted": true,
|
||||||
"isStale": true,
|
|
||||||
"number": 2500,
|
"number": 2500,
|
||||||
"state": "open",
|
"state": "open",
|
||||||
"targetBranch": "master",
|
"targetBranch": "master",
|
||||||
|
@ -3200,17 +3164,6 @@ Array [
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"url": "https://api.github.com/graphql",
|
"url": "https://api.github.com/graphql",
|
||||||
},
|
},
|
||||||
Object {
|
|
||||||
"headers": Object {
|
|
||||||
"accept": "application/vnd.github.v3+json",
|
|
||||||
"accept-encoding": "gzip, deflate",
|
|
||||||
"authorization": "token abc123",
|
|
||||||
"host": "api.github.com",
|
|
||||||
"user-agent": "https://github.com/renovatebot/renovate",
|
|
||||||
},
|
|
||||||
"method": "GET",
|
|
||||||
"url": "https://api.github.com/repos/some/repo/git/refs/heads/master",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -3594,17 +3547,6 @@ Array [
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"url": "https://api.github.com/repos/some/repo/pulls/1234",
|
"url": "https://api.github.com/repos/some/repo/pulls/1234",
|
||||||
},
|
},
|
||||||
Object {
|
|
||||||
"headers": Object {
|
|
||||||
"accept": "application/vnd.github.v3+json",
|
|
||||||
"accept-encoding": "gzip, deflate",
|
|
||||||
"authorization": "token abc123",
|
|
||||||
"host": "api.github.com",
|
|
||||||
"user-agent": "https://github.com/renovatebot/renovate",
|
|
||||||
},
|
|
||||||
"method": "GET",
|
|
||||||
"url": "https://api.github.com/repos/some/repo/git/refs/heads/master",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -3617,7 +3559,6 @@ Object {
|
||||||
"canMerge": true,
|
"canMerge": true,
|
||||||
"commits": 1,
|
"commits": 1,
|
||||||
"displayNumber": "Pull Request #1",
|
"displayNumber": "Pull Request #1",
|
||||||
"isStale": true,
|
|
||||||
"mergeable": true,
|
"mergeable": true,
|
||||||
"number": 1,
|
"number": 1,
|
||||||
"sha": undefined,
|
"sha": undefined,
|
||||||
|
@ -3798,17 +3739,6 @@ Array [
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"url": "https://api.github.com/repos/some/repo/pulls/1234",
|
"url": "https://api.github.com/repos/some/repo/pulls/1234",
|
||||||
},
|
},
|
||||||
Object {
|
|
||||||
"headers": Object {
|
|
||||||
"accept": "application/vnd.github.v3+json",
|
|
||||||
"accept-encoding": "gzip, deflate",
|
|
||||||
"authorization": "token abc123",
|
|
||||||
"host": "api.github.com",
|
|
||||||
"user-agent": "https://github.com/renovatebot/renovate",
|
|
||||||
},
|
|
||||||
"method": "GET",
|
|
||||||
"url": "https://api.github.com/repos/some/repo/git/refs/heads/master",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
@ -491,9 +491,7 @@ describe('platform/github', () => {
|
||||||
},
|
},
|
||||||
head: { ref: 'somebranch', repo: { full_name: 'some/repo' } },
|
head: { ref: 'somebranch', repo: { full_name: 'some/repo' } },
|
||||||
state: 'open',
|
state: 'open',
|
||||||
})
|
});
|
||||||
.get('/repos/some/repo/git/refs/heads/master')
|
|
||||||
.reply(200, { object: { sha: '12345' } });
|
|
||||||
|
|
||||||
await github.initRepo({
|
await github.initRepo({
|
||||||
repository: 'some/repo',
|
repository: 'some/repo',
|
||||||
|
@ -534,8 +532,6 @@ describe('platform/github', () => {
|
||||||
head: { ref: 'somebranch', repo: { full_name: 'other/repo' } },
|
head: { ref: 'somebranch', repo: { full_name: 'other/repo' } },
|
||||||
state: 'open',
|
state: 'open',
|
||||||
})
|
})
|
||||||
.get('/repos/forked/repo/git/refs/heads/master')
|
|
||||||
.reply(200, { object: { sha: '12345' } })
|
|
||||||
.patch('/repos/forked/repo/git/refs/heads/master')
|
.patch('/repos/forked/repo/git/refs/heads/master')
|
||||||
.reply(200);
|
.reply(200);
|
||||||
await github.initRepo({
|
await github.initRepo({
|
||||||
|
@ -1643,15 +1639,7 @@ describe('platform/github', () => {
|
||||||
it('should return PR from graphql result', async () => {
|
it('should return PR from graphql result', async () => {
|
||||||
const scope = httpMock.scope(githubApiHost);
|
const scope = httpMock.scope(githubApiHost);
|
||||||
initRepoMock(scope, 'some/repo');
|
initRepoMock(scope, 'some/repo');
|
||||||
scope
|
scope.post('/graphql').reply(200, graphqlOpenPullRequests);
|
||||||
.post('/graphql')
|
|
||||||
.reply(200, graphqlOpenPullRequests)
|
|
||||||
.get('/repos/some/repo/git/refs/heads/master')
|
|
||||||
.reply(200, {
|
|
||||||
object: {
|
|
||||||
sha: '1234123412341234123412341234123412341234',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
global.gitAuthor = {
|
global.gitAuthor = {
|
||||||
name: 'Renovate Bot',
|
name: 'Renovate Bot',
|
||||||
email: 'renovate@whitesourcesoftware.com',
|
email: 'renovate@whitesourcesoftware.com',
|
||||||
|
@ -1672,12 +1660,7 @@ describe('platform/github', () => {
|
||||||
.reply(200, graphqlOpenPullRequests)
|
.reply(200, graphqlOpenPullRequests)
|
||||||
.post('/graphql')
|
.post('/graphql')
|
||||||
.reply(200, graphqlClosedPullRequests)
|
.reply(200, graphqlClosedPullRequests)
|
||||||
.get('/repos/some/repo/git/refs/heads/master')
|
.get('/repos/some/repo/git/refs/heads/master');
|
||||||
.reply(200, {
|
|
||||||
object: {
|
|
||||||
sha: '1234123412341234123412341234123412341234',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
await github.initRepo({
|
await github.initRepo({
|
||||||
repository: 'some/repo',
|
repository: 'some/repo',
|
||||||
} as any);
|
} as any);
|
||||||
|
@ -1735,12 +1718,6 @@ describe('platform/github', () => {
|
||||||
base: { sha: '1234' },
|
base: { sha: '1234' },
|
||||||
commits: 1,
|
commits: 1,
|
||||||
})
|
})
|
||||||
.get('/repos/some/repo/git/refs/heads/master')
|
|
||||||
.reply(200, {
|
|
||||||
object: {
|
|
||||||
sha: '1234',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.post('/graphql')
|
.post('/graphql')
|
||||||
.twice()
|
.twice()
|
||||||
.reply(404);
|
.reply(404);
|
||||||
|
@ -1764,12 +1741,6 @@ describe('platform/github', () => {
|
||||||
commits: 1,
|
commits: 1,
|
||||||
mergeable: true,
|
mergeable: true,
|
||||||
})
|
})
|
||||||
.get('/repos/some/repo/git/refs/heads/master')
|
|
||||||
.reply(200, {
|
|
||||||
object: {
|
|
||||||
sha: '1234',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.post('/graphql')
|
.post('/graphql')
|
||||||
.twice()
|
.twice()
|
||||||
.reply(404);
|
.reply(404);
|
||||||
|
|
|
@ -681,18 +681,6 @@ async function getOpenPrs(): Promise<PrList> {
|
||||||
} else {
|
} else {
|
||||||
pr.isConflicted = false;
|
pr.isConflicted = false;
|
||||||
}
|
}
|
||||||
pr.isStale = false;
|
|
||||||
if (pr.mergeStateStatus === 'BEHIND') {
|
|
||||||
pr.isStale = true;
|
|
||||||
} else {
|
|
||||||
const baseCommitSHA = await getBaseCommitSHA();
|
|
||||||
if (
|
|
||||||
pr.commits?.nodes[0]?.commit?.parents?.edges?.[0]?.node?.oid !==
|
|
||||||
baseCommitSHA
|
|
||||||
) {
|
|
||||||
pr.isStale = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pr.labels) {
|
if (pr.labels) {
|
||||||
pr.labels = pr.labels.nodes.map(
|
pr.labels = pr.labels.nodes.map(
|
||||||
(label: { name: string }) => label.name
|
(label: { name: string }) => label.name
|
||||||
|
@ -761,10 +749,6 @@ export async function getPr(prNo: number): Promise<Pr | null> {
|
||||||
logger.debug({ prNo }, 'PR state is dirty so unmergeable');
|
logger.debug({ prNo }, 'PR state is dirty so unmergeable');
|
||||||
pr.isConflicted = true;
|
pr.isConflicted = true;
|
||||||
}
|
}
|
||||||
const baseCommitSHA = await getBaseCommitSHA();
|
|
||||||
if (!pr.base || pr.base.sha !== baseCommitSHA) {
|
|
||||||
pr.isStale = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return pr;
|
return pr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -817,7 +817,6 @@ Object {
|
||||||
"hasAssignees": false,
|
"hasAssignees": false,
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"iid": 91,
|
"iid": 91,
|
||||||
"isStale": false,
|
|
||||||
"number": 91,
|
"number": 91,
|
||||||
"source_branch": "some-branch",
|
"source_branch": "some-branch",
|
||||||
"state": "open",
|
"state": "open",
|
||||||
|
@ -1147,7 +1146,6 @@ Object {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"iid": 12345,
|
"iid": 12345,
|
||||||
"isConflicted": true,
|
"isConflicted": true,
|
||||||
"isStale": true,
|
|
||||||
"merge_status": "cannot_be_merged",
|
"merge_status": "cannot_be_merged",
|
||||||
"number": 12345,
|
"number": 12345,
|
||||||
"source_branch": "some-branch",
|
"source_branch": "some-branch",
|
||||||
|
@ -1186,7 +1184,6 @@ Object {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"iid": 12345,
|
"iid": 12345,
|
||||||
"isConflicted": true,
|
"isConflicted": true,
|
||||||
"isStale": true,
|
|
||||||
"merge_status": "cannot_be_merged",
|
"merge_status": "cannot_be_merged",
|
||||||
"number": 12345,
|
"number": 12345,
|
||||||
"source_branch": "some-branch",
|
"source_branch": "some-branch",
|
||||||
|
@ -1224,7 +1221,6 @@ Object {
|
||||||
"hasReviewers": false,
|
"hasReviewers": false,
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"iid": 12345,
|
"iid": 12345,
|
||||||
"isStale": true,
|
|
||||||
"number": 12345,
|
"number": 12345,
|
||||||
"source_branch": "some-branch",
|
"source_branch": "some-branch",
|
||||||
"state": "open",
|
"state": "open",
|
||||||
|
|
|
@ -447,7 +447,6 @@ export async function getPr(iid: number): Promise<Pr> {
|
||||||
pr.number = pr.iid;
|
pr.number = pr.iid;
|
||||||
pr.displayNumber = `Merge Request #${pr.iid}`;
|
pr.displayNumber = `Merge Request #${pr.iid}`;
|
||||||
pr.body = pr.description;
|
pr.body = pr.description;
|
||||||
pr.isStale = pr.diverged_commits_count > 0;
|
|
||||||
pr.state = pr.state === 'opened' ? PR_STATE_OPEN : pr.state;
|
pr.state = pr.state === 'opened' ? PR_STATE_OPEN : pr.state;
|
||||||
pr.hasAssignees = !!(pr.assignee?.id || pr.assignees?.[0]?.id);
|
pr.hasAssignees = !!(pr.assignee?.id || pr.assignees?.[0]?.id);
|
||||||
delete pr.assignee;
|
delete pr.assignee;
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
import { mock } from 'jest-mock-extended';
|
import { RenovateConfig, defaultConfig, git } from '../../../../../test/util';
|
||||||
import {
|
|
||||||
RenovateConfig,
|
|
||||||
defaultConfig,
|
|
||||||
git,
|
|
||||||
platform,
|
|
||||||
} from '../../../../../test/util';
|
|
||||||
import { Pr } from '../../../../platform';
|
|
||||||
import { rebaseOnboardingBranch } from './rebase';
|
import { rebaseOnboardingBranch } from './rebase';
|
||||||
|
|
||||||
jest.mock('../../../../util/git');
|
jest.mock('../../../../util/git');
|
||||||
|
@ -20,9 +13,6 @@ describe('workers/repository/onboarding/branch/rebase', () => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
it('does not rebase modified branch', async () => {
|
it('does not rebase modified branch', async () => {
|
||||||
platform.getBranchPr.mockResolvedValueOnce({
|
|
||||||
...mock<Pr>(),
|
|
||||||
});
|
|
||||||
git.isBranchModified.mockResolvedValueOnce(true);
|
git.isBranchModified.mockResolvedValueOnce(true);
|
||||||
await rebaseOnboardingBranch(config);
|
await rebaseOnboardingBranch(config);
|
||||||
expect(git.commitFiles).toHaveBeenCalledTimes(0);
|
expect(git.commitFiles).toHaveBeenCalledTimes(0);
|
||||||
|
@ -33,18 +23,11 @@ describe('workers/repository/onboarding/branch/rebase', () => {
|
||||||
git.getFile
|
git.getFile
|
||||||
.mockResolvedValueOnce(contents) // package.json
|
.mockResolvedValueOnce(contents) // package.json
|
||||||
.mockResolvedValueOnce(contents); // renovate.json
|
.mockResolvedValueOnce(contents); // renovate.json
|
||||||
platform.getBranchPr.mockResolvedValueOnce({
|
|
||||||
...mock<Pr>(),
|
|
||||||
isStale: false,
|
|
||||||
});
|
|
||||||
await rebaseOnboardingBranch(config);
|
await rebaseOnboardingBranch(config);
|
||||||
expect(git.commitFiles).toHaveBeenCalledTimes(0);
|
expect(git.commitFiles).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
it('rebases onboarding branch', async () => {
|
it('rebases onboarding branch', async () => {
|
||||||
platform.getBranchPr.mockResolvedValueOnce({
|
git.isBranchStale.mockResolvedValueOnce(true);
|
||||||
...mock<Pr>(),
|
|
||||||
isStale: true,
|
|
||||||
});
|
|
||||||
await rebaseOnboardingBranch(config);
|
await rebaseOnboardingBranch(config);
|
||||||
expect(git.commitFiles).toHaveBeenCalledTimes(1);
|
expect(git.commitFiles).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
import { RenovateConfig } from '../../../../config';
|
import { RenovateConfig } from '../../../../config';
|
||||||
import { configFileNames } from '../../../../config/app-strings';
|
import { configFileNames } from '../../../../config/app-strings';
|
||||||
import { logger } from '../../../../logger';
|
import { logger } from '../../../../logger';
|
||||||
import { platform } from '../../../../platform';
|
import {
|
||||||
import { commitFiles, getFile, isBranchModified } from '../../../../util/git';
|
commitFiles,
|
||||||
|
getFile,
|
||||||
|
isBranchModified,
|
||||||
|
isBranchStale,
|
||||||
|
} from '../../../../util/git';
|
||||||
import { getOnboardingConfig } from './config';
|
import { getOnboardingConfig } from './config';
|
||||||
|
|
||||||
const defaultConfigFile = configFileNames[0];
|
const defaultConfigFile = configFileNames[0];
|
||||||
|
@ -27,7 +31,6 @@ export async function rebaseOnboardingBranch(
|
||||||
config: RenovateConfig
|
config: RenovateConfig
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
logger.debug('Checking if onboarding branch needs rebasing');
|
logger.debug('Checking if onboarding branch needs rebasing');
|
||||||
const pr = await platform.getBranchPr(config.onboardingBranch);
|
|
||||||
if (await isBranchModified(config.onboardingBranch)) {
|
if (await isBranchModified(config.onboardingBranch)) {
|
||||||
logger.debug('Onboarding branch has been edited and cannot be rebased');
|
logger.debug('Onboarding branch has been edited and cannot be rebased');
|
||||||
return null;
|
return null;
|
||||||
|
@ -37,7 +40,10 @@ export async function rebaseOnboardingBranch(
|
||||||
config.onboardingBranch
|
config.onboardingBranch
|
||||||
);
|
);
|
||||||
const contents = getOnboardingConfig(config);
|
const contents = getOnboardingConfig(config);
|
||||||
if (contents === existingContents && !pr.isStale) {
|
if (
|
||||||
|
contents === existingContents &&
|
||||||
|
!(await isBranchStale(config.onboardingBranch))
|
||||||
|
) {
|
||||||
logger.debug('Onboarding branch is up to date');
|
logger.debug('Onboarding branch is up to date');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue