volunteer-contributions-fetch 2.3.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/github.js +5 -3
- package/lib/github.test.js +77 -7
- package/package.json +1 -1
package/lib/github.js
CHANGED
|
@@ -184,7 +184,7 @@ async function processReviews(github, latestCreationDate) {
|
|
|
184
184
|
// Now that we have all the PRs, we need to fetch the reviews
|
|
185
185
|
const allReviews = [];
|
|
186
186
|
|
|
187
|
-
const prReviewsList = getPRReviews(allPRs.flat(), github.delayMsPerRequest);
|
|
187
|
+
const prReviewsList = getPRReviews(allPRs.flat(), github.username, github.delayMsPerRequest);
|
|
188
188
|
for await (const prReviews of prReviewsList) {
|
|
189
189
|
allReviews.push(prReviews);
|
|
190
190
|
}
|
|
@@ -379,7 +379,7 @@ async function getPRPage(github, reviewPeriod, page) {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
async function* getPRReviews(prList, delay) {
|
|
382
|
+
async function* getPRReviews(prList, reviewerUsername, delay) {
|
|
383
383
|
debug('Getting PR reviews');
|
|
384
384
|
for await (const pr of prList) {
|
|
385
385
|
try {
|
|
@@ -393,7 +393,9 @@ async function* getPRReviews(prList, delay) {
|
|
|
393
393
|
pull_number: pr.number,
|
|
394
394
|
});
|
|
395
395
|
|
|
396
|
-
|
|
396
|
+
const onlyMyReviews = items.filter((review) => review.user.login === reviewerUsername);
|
|
397
|
+
|
|
398
|
+
yield onlyMyReviews;
|
|
397
399
|
} catch (error) {
|
|
398
400
|
debug('Error fetching reviews', error);
|
|
399
401
|
return [];
|
package/lib/github.test.js
CHANGED
|
@@ -70,11 +70,6 @@ test.serial('should validate config - missing stopDate', (t) => {
|
|
|
70
70
|
t.throws(() => github.validate(failConfig));
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
// test.serial('should fetch', async (t) => {
|
|
74
|
-
// const contributions = await github.gather(config);
|
|
75
|
-
// t.is(contributions.length, 0);
|
|
76
|
-
// });
|
|
77
|
-
|
|
78
73
|
test.serial('should not fetch if disabled - by enable property', async (t) => {
|
|
79
74
|
const specificTypeConfig = {
|
|
80
75
|
github: {
|
|
@@ -594,7 +589,12 @@ test.serial('should fetch reviews until stop date', async (t) => {
|
|
|
594
589
|
})));
|
|
595
590
|
|
|
596
591
|
fetcher.listReviews.resolves([]);
|
|
597
|
-
fetcher.listReviews.onCall(0).resolves([{
|
|
592
|
+
fetcher.listReviews.onCall(0).resolves([{
|
|
593
|
+
createdAt: new Date('2022-03-01'),
|
|
594
|
+
user: {
|
|
595
|
+
login: commitConfig.github.username,
|
|
596
|
+
},
|
|
597
|
+
}]);
|
|
598
598
|
|
|
599
599
|
await github.gather(commitConfig);
|
|
600
600
|
t.deepEqual(fetcher.searchIssues.getCall(0).args[0], {
|
|
@@ -668,16 +668,25 @@ test.serial('should format reviews', async (t) => {
|
|
|
668
668
|
pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
|
|
669
669
|
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
670
670
|
state: 'CHANGES_REQUESTED',
|
|
671
|
+
user: {
|
|
672
|
+
login: commitConfig.github.username,
|
|
673
|
+
},
|
|
671
674
|
}, {
|
|
672
675
|
submitted_at: new Date('2022-03-02'),
|
|
673
676
|
pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
|
|
674
677
|
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
675
678
|
state: 'COMMENTED',
|
|
679
|
+
user: {
|
|
680
|
+
login: commitConfig.github.username,
|
|
681
|
+
},
|
|
676
682
|
}, {
|
|
677
683
|
submitted_at: new Date('2022-03-02'),
|
|
678
684
|
pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
|
|
679
685
|
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
680
686
|
state: 'APPROVED',
|
|
687
|
+
user: {
|
|
688
|
+
login: commitConfig.github.username,
|
|
689
|
+
},
|
|
681
690
|
}]);
|
|
682
691
|
|
|
683
692
|
const result = await github.gather(commitConfig);
|
|
@@ -737,16 +746,25 @@ test.serial('should custom format reviews', async (t) => {
|
|
|
737
746
|
pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
|
|
738
747
|
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
739
748
|
state: 'CHANGES_REQUESTED',
|
|
749
|
+
user: {
|
|
750
|
+
login: commitConfig.github.username,
|
|
751
|
+
},
|
|
740
752
|
}, {
|
|
741
753
|
submitted_at: new Date('2022-03-02'),
|
|
742
754
|
pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
|
|
743
755
|
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
744
756
|
state: 'COMMENTED',
|
|
757
|
+
user: {
|
|
758
|
+
login: commitConfig.github.username,
|
|
759
|
+
},
|
|
745
760
|
}, {
|
|
746
761
|
submitted_at: new Date('2022-03-02'),
|
|
747
762
|
pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
|
|
748
763
|
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
749
764
|
state: 'APPROVED',
|
|
765
|
+
user: {
|
|
766
|
+
login: commitConfig.github.username,
|
|
767
|
+
},
|
|
750
768
|
}]);
|
|
751
769
|
|
|
752
770
|
const result = await github.gather(commitConfig);
|
|
@@ -812,7 +830,7 @@ test.serial('should ignore reviews not matching filter', async (t) => {
|
|
|
812
830
|
}]);
|
|
813
831
|
|
|
814
832
|
fetcher.listReviews.onCall(0).resolves([{
|
|
815
|
-
submitted_at: new Date('
|
|
833
|
+
submitted_at: new Date('2022-03-01'),
|
|
816
834
|
pull_request_url: 'https://github.com/not-matching-filter/foo/pulls/1',
|
|
817
835
|
html_url: 'https://github.com/not-matching-filter/foo/pulls/1',
|
|
818
836
|
state: 'CHANGES_REQUESTED',
|
|
@@ -822,6 +840,58 @@ test.serial('should ignore reviews not matching filter', async (t) => {
|
|
|
822
840
|
t.is(result.length, 0);
|
|
823
841
|
});
|
|
824
842
|
|
|
843
|
+
test.serial('should ignore reviews not by user', async (t) => {
|
|
844
|
+
const commitConfig = {
|
|
845
|
+
github: {
|
|
846
|
+
...config.github,
|
|
847
|
+
issuesEnabled: false,
|
|
848
|
+
commitsEnabled: false,
|
|
849
|
+
filter: 'contribution-test',
|
|
850
|
+
stopDate: new Date('2022-01-01'),
|
|
851
|
+
},
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
fetcher.searchIssues.onCall(0).resolves([{
|
|
855
|
+
createdAt: new Date('2022-03-02'),
|
|
856
|
+
repository_url: 'https://api.github.com/repos/contribution-test/foo',
|
|
857
|
+
html_url: 'https://api.github.com/repos/contribution-test/foo',
|
|
858
|
+
title: 'Some PR',
|
|
859
|
+
number: 1111,
|
|
860
|
+
pull_request: {
|
|
861
|
+
url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
862
|
+
},
|
|
863
|
+
}]);
|
|
864
|
+
|
|
865
|
+
fetcher.listReviews.onCall(0).resolves([{
|
|
866
|
+
submitted_at: new Date('2022-03-01'),
|
|
867
|
+
pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
868
|
+
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
869
|
+
state: 'CHANGES_REQUESTED',
|
|
870
|
+
user: {
|
|
871
|
+
login: 'not-the-right-user',
|
|
872
|
+
},
|
|
873
|
+
}, {
|
|
874
|
+
submitted_at: new Date('2022-03-01'),
|
|
875
|
+
pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
876
|
+
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
877
|
+
state: 'COMMENTED',
|
|
878
|
+
user: {
|
|
879
|
+
login: 'not-the-right-user',
|
|
880
|
+
},
|
|
881
|
+
}, {
|
|
882
|
+
submitted_at: new Date('2022-03-01'),
|
|
883
|
+
pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
884
|
+
html_url: 'https://github.com/contribution-test/foo/pulls/1',
|
|
885
|
+
state: 'CHANGES_REQUESTED',
|
|
886
|
+
user: {
|
|
887
|
+
login: commitConfig.github.username,
|
|
888
|
+
},
|
|
889
|
+
}]);
|
|
890
|
+
|
|
891
|
+
const result = await github.gather(commitConfig);
|
|
892
|
+
t.is(result.length, 1);
|
|
893
|
+
});
|
|
894
|
+
|
|
825
895
|
test.serial('should fetch comments until stop date', async (t) => {
|
|
826
896
|
const commitConfig = {
|
|
827
897
|
github: {
|