Skip to content

Commit 6aa3ce1

Browse files
authored
Revert Use team keys for authors (#88) (#96)
* Revert "Add one example to show the new feature" This reverts commit 4bc5b46. * Revert "Fix the stub to return in the expected format (#93)" This reverts commit a39c70b. * Revert "Use team keys for authors (#88)" This reverts commit bf71b47.
1 parent fec2e6a commit 6aa3ce1

File tree

7 files changed

+4
-86
lines changed

7 files changed

+4
-86
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ reviewers:
149149
designer_b:
150150
- lead_desinger # username
151151
- desinger_a # username
152-
team:engineering-managers:
153-
- engineers
154152
155153
files:
156154
# Keys are glob expressions.

dist/index.js

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,6 @@ async function assign_reviewers(reviewers) {
112112
});
113113
}
114114

115-
// https://docs.github.com/en/rest/teams/members?apiVersion=2022-11-28#list-team-members
116-
async function get_team_members(team) {
117-
const context = get_context();
118-
const octokit = get_octokit();
119-
120-
return octokit.teams.listMembersInOrg({
121-
org: context.repo.org,
122-
team_slug: team,
123-
})?.data?.map((member) => member.login);
124-
}
125-
126115
/* Private */
127116

128117
let context_cache;
@@ -169,5 +158,4 @@ module.exports = {
169158
fetch_changed_files,
170159
assign_reviewers,
171160
clear_cache,
172-
get_team_members,
173161
};

src/reviewer.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const core = require('@actions/core');
44
const minimatch = require('minimatch');
55
const sample_size = require('lodash/sampleSize');
6-
const github = require('./github'); // Don't destructure this object to stub with sinon in tests
76

87
function fetch_other_group_members({ author, config }) {
98
const DEFAULT_OPTIONS = {
@@ -78,14 +77,6 @@ function identify_reviewers_by_author({ config, 'author': specified_author }) {
7877
return true;
7978
}
8079

81-
if (author.startsWith('team:')) {
82-
const team = author.replace('team:', '');
83-
const individuals_in_team = github.get_team_members(team);
84-
if (individuals_in_team.includes(specified_author)) {
85-
return true;
86-
}
87-
}
88-
8980
const individuals_in_author_setting = replace_groups_with_individuals({ reviewers: [ author ], config });
9081

9182
if (individuals_in_author_setting.includes(specified_author)) {

test/github.test.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const {
1414
fetch_changed_files,
1515
assign_reviewers,
1616
clear_cache,
17-
get_team_members,
1817
} = require('../src/github');
1918

2019
describe('github', function() {
@@ -156,29 +155,4 @@ describe('github', function() {
156155
});
157156
});
158157
});
159-
160-
describe('get_team_members()', function() {
161-
const spy = sinon.spy();
162-
const octokit = {
163-
teams: {
164-
listMembersInOrg: spy,
165-
},
166-
};
167-
168-
beforeEach(function() {
169-
github.getOctokit.resetBehavior();
170-
github.getOctokit.returns(octokit);
171-
});
172-
173-
it('gets team members', async function() {
174-
const team = 'koopa-troop';
175-
await get_team_members(team);
176-
177-
expect(spy.calledOnce).to.be.true;
178-
expect(spy.lastCall.args[0]).to.deep.equal({
179-
org: 'necojackarc',
180-
team_slug: 'koopa-troop',
181-
});
182-
});
183-
});
184158
});

test/reviewer.test.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ const {
1010
} = require('../src/reviewer');
1111
const { expect } = require('chai');
1212

13-
const github = require('../src/github');
14-
const sinon = require('sinon');
15-
1613
describe('reviewer', function() {
1714
describe('fetch_other_group_members()', function() {
1815

@@ -72,6 +69,7 @@ describe('reviewer', function() {
7269
});
7370

7471
describe('identify_reviewers_by_changed_files()', function() {
72+
7573
const config = {
7674
reviewers: {
7775
groups: {
@@ -138,17 +136,13 @@ describe('reviewer', function() {
138136
designers: [ 'mario', 'princess-peach', 'princess-daisy' ],
139137
},
140138
per_author: {
141-
'engineers': [ 'engineers', 'dr-mario' ],
142-
'designers': [ 'designers' ],
143-
'yoshi': [ 'mario', 'luige' ],
144-
'team:koopa-troop': [ 'mario' ],
139+
engineers: [ 'engineers', 'dr-mario' ],
140+
designers: [ 'designers' ],
141+
yoshi: [ 'mario', 'luige' ],
145142
},
146143
},
147144
};
148145

149-
const stub = sinon.stub(github, 'get_team_members');
150-
stub.withArgs('koopa-troop').returns([ 'bowser', 'king-boo', 'goomboss' ]);
151-
152146
it('returns nothing when config does not have a "per-author" key', function() {
153147
const author = 'THIS DOES NOT MATTER';
154148
expect(identify_reviewers_by_author({ config: { reviewers: {} }, author })).to.deep.equal([]);
@@ -173,11 +167,6 @@ describe('reviewer', function() {
173167
const author = 'mario';
174168
expect(identify_reviewers_by_author({ config, author })).to.have.members([ 'dr-mario', 'luigi', 'wario', 'waluigi', 'princess-peach', 'princess-daisy' ]);
175169
});
176-
177-
it('works when gh team slug used for auther', function() {
178-
const author = 'bowser';
179-
expect(identify_reviewers_by_author({ config, author })).to.have.members([ 'mario' ]);
180-
});
181170
});
182171

183172
describe('should_request_review()', function() {

test/stubs/context.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class ContextStub {
2424
return {
2525
owner: 'necojackarc',
2626
repo: 'auto-request-review',
27-
org: 'necojackarc',
2827
};
2928
}
3029
}

0 commit comments

Comments
 (0)