File tree Expand file tree Collapse file tree 6 files changed +43
-44
lines changed
options_processor/options Expand file tree Collapse file tree 6 files changed +43
-44
lines changed Original file line number Diff line number Diff line change 1
1
CHANGELOG
2
2
=====================================
3
+ | May 12, 2023: fix: Loading teams for team option of author filter/validator `#713 <https://github.com/mergeability/mergeable/pull/713>`_
3
4
| May 11, 2023: fix: Send correct payload for changing labels `#715 <https://github.com/mergeability/mergeable/pull/715>`_
4
5
| April 25, 2023: feat: Add author validator `#710 <https://github.com/mergeability/mergeable/pull/710>`_
5
6
| March 13, 2023: fix: Replace delete with remove in changeset validator `#705 <https://github.com/mergeability/mergeable/pull/705>`_
Original file line number Diff line number Diff line change 1
1
const { Filter } = require ( './filter' )
2
-
2
+ const Teams = require ( '../validators/options_processor/teams' )
3
3
class Author extends Filter {
4
4
constructor ( ) {
5
5
super ( 'author' )
@@ -24,6 +24,15 @@ class Author extends Filter {
24
24
25
25
async filter ( context , settings ) {
26
26
const payload = this . getPayload ( context )
27
+
28
+ if ( settings . team ) {
29
+ const result = await Teams . processTeamOption ( context , settings , payload )
30
+ if ( result . status !== 'pass' ) {
31
+ return result
32
+ }
33
+ delete settings . team
34
+ }
35
+
27
36
return this . processOptions ( context , payload . user . login , settings )
28
37
}
29
38
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
const { Validator } = require ( './validator' )
2
-
2
+ const Teams = require ( './options_processor/teams' )
3
3
class Author extends Validator {
4
4
constructor ( ) {
5
5
super ( 'author' )
@@ -24,6 +24,15 @@ class Author extends Validator {
24
24
25
25
async validate ( context , settings ) {
26
26
const payload = this . getPayload ( context )
27
+
28
+ if ( settings . team ) {
29
+ const result = await Teams . processTeamOption ( context , settings , payload )
30
+ if ( result . status !== 'pass' ) {
31
+ return result
32
+ }
33
+ delete settings . team
34
+ }
35
+
27
36
return this . processOptions ( settings , payload . user . login )
28
37
}
29
38
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
const _ = require ( 'lodash' )
2
2
const GithubAPI = require ( '../../github/api' )
3
+ const constructOutput = require ( './options/lib/constructOutput' )
4
+ const consolidateResult = require ( './options/lib/consolidateResults' )
3
5
4
6
class Teams {
5
7
static async extractTeamMembers ( context , teams ) {
@@ -29,6 +31,26 @@ class Teams {
29
31
}
30
32
return _ . uniq ( teamMembers )
31
33
}
34
+
35
+ static async processTeamOption ( context , settings , payload ) {
36
+ const teamName = settings . team
37
+ const userName = payload . user . login
38
+
39
+ const teamMemberships = await Teams . extractTeamMemberships ( context , [ teamName ] , [ userName ] )
40
+ const isMember = teamMemberships . includes ( userName )
41
+ const successMessage = `'${ userName } ' is part of the '${ teamName } ' team'`
42
+ const failureMessage = `'${ userName } ' is not part of the '${ teamName } ' team'`
43
+
44
+ const output = [
45
+ constructOutput (
46
+ context , teamMemberships , settings , {
47
+ status : isMember ? 'pass' : 'fail' ,
48
+ description : isMember ? successMessage : failureMessage
49
+ } , null
50
+ )
51
+ ]
52
+ return consolidateResult ( output , context )
53
+ }
32
54
}
33
55
34
56
const getTeamMembers = async ( context , team ) => {
You can’t perform that action at this time.
0 commit comments