Skip to content

Commit

Permalink
feat(internal): use git to determine branch modification status (#6697)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
rarkins and viceice authored Jul 22, 2020
1 parent 852b340 commit 1449e83
Show file tree
Hide file tree
Showing 39 changed files with 159 additions and 2,481 deletions.
2 changes: 1 addition & 1 deletion docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ You probably have no need for this option - it is an experimental setting for th

## gitAuthor

RFC5322-compliant string if you wish to customise the git author for commits.
RFC5322-compliant string if you wish to customise the git author for commits. If you need to transition from one git author to another, put the old gitAuthor into `RENOVATE_LEGACY_GIT_AUTHOR_EMAIL` in environment. Renovate will then check against it as well as the current git author value before deciding if a branch has been modified.

## gitPrivateKey

Expand Down
4 changes: 0 additions & 4 deletions lib/platform/azure/__snapshots__/azure-helper.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Object {
"branchName": undefined,
"createdAt": undefined,
"displayNumber": "Pull Request #undefined",
"isModified": false,
"number": undefined,
"state": "merged",
"status": 3,
Expand All @@ -74,7 +73,6 @@ Object {
"branchName": undefined,
"createdAt": undefined,
"displayNumber": "Pull Request #undefined",
"isModified": false,
"number": undefined,
"state": "closed",
"status": 2,
Expand All @@ -89,7 +87,6 @@ Object {
"createdAt": undefined,
"displayNumber": "Pull Request #undefined",
"isConflicted": true,
"isModified": false,
"mergeStatus": 2,
"number": undefined,
"state": "open",
Expand All @@ -103,7 +100,6 @@ Object {
"branchName": undefined,
"createdAt": undefined,
"displayNumber": "Pull Request #undefined",
"isModified": false,
"number": undefined,
"state": "open",
"status": 1,
Expand Down
10 changes: 0 additions & 10 deletions lib/platform/azure/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,13 @@ exports[`platform/azure getBranchPr(branchName) should return the pr 1`] = `null
exports[`platform/azure getPr(prNo) should return a pr in the right format 1`] = `
Object {
"hasReviewers": false,
"isModified": false,
"labels": Array [
"renovate",
],
"number": 1234,
}
`;

exports[`platform/azure getPr(prNo) should return a pr thats been modified 1`] = `
Object {
"hasReviewers": false,
"isModified": true,
"labels": Array [],
"number": 1234,
}
`;

exports[`platform/azure getPrBody(input) returns updated pr body 1`] = `"https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)"`;

exports[`platform/azure getRepos() should return an array of repos 1`] = `
Expand Down
4 changes: 0 additions & 4 deletions lib/platform/azure/azure-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ export function getRenovatePRFormat(azurePr: GitPullRequest): AzurePr {
pr.isConflicted = true;
}

// value is updated later to be correct for
// specific pr's after filtering, for performance
pr.isModified = false;

return pr;
}

Expand Down
38 changes: 0 additions & 38 deletions lib/platform/azure/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,44 +481,6 @@ describe('platform/azure', () => {
const pr = await azure.getPr(1234);
expect(pr).toMatchSnapshot();
});
it('should return a pr thats been modified', async () => {
await initRepo({ repository: 'some/repo' });
azureApi.gitApi.mockImplementation(
() =>
({
getPullRequests: jest
.fn()
.mockReturnValue([])
.mockReturnValueOnce([
{
pullRequestId: 1234,
},
]),
getPullRequestLabels: jest.fn().mockReturnValue([]),
getPullRequestCommits: jest.fn().mockReturnValue([
{
author: {
name: 'renovate',
},
},
{
author: {
name: 'end user',
},
},
]),
} as any)
);
azureHelper.getRenovatePRFormat.mockImplementation(
() =>
({
number: 1234,
isModified: false,
} as any)
);
const pr = await azure.getPr(1234);
expect(pr).toMatchSnapshot();
});
});

describe('createPr()', () => {
Expand Down
8 changes: 0 additions & 8 deletions lib/platform/azure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,6 @@ export async function getPr(pullRequestId: number): Promise<Pr | null> {
azurePr.labels = labels
.filter((label) => label.active)
.map((label) => label.name);

const commits = await azureApiGit.getPullRequestCommits(
config.repoId,
pullRequestId
);
azurePr.isModified =
commits.length > 0 &&
commits[0].author.name !== commits[commits.length - 1].author.name;
azurePr.hasReviewers = is.nonEmptyArray(azurePr.reviewers);
return azurePr;
}
Expand Down
Loading

0 comments on commit 1449e83

Please sign in to comment.