fix: Adjust sorting for new pull requests
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import { IGlobalVariable, ITriggerOutput } from '@automatisch/types';
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
import getRepoOwnerAndRepo from '../../common/get-repo-owner-and-repo';
|
import getRepoOwnerAndRepo from '../../common/get-repo-owner-and-repo';
|
||||||
import parseLinkHeader from '../../../../helpers/parse-header-link';
|
import parseLinkHeader from '../../../../helpers/parse-header-link';
|
||||||
|
|
||||||
const fetchPullRequests = async ($: IGlobalVariable) => {
|
const newPullRequests = async ($: IGlobalVariable) => {
|
||||||
const repoParameter = $.step.parameters.repo as string;
|
const repoParameter = $.step.parameters.repo as string;
|
||||||
|
|
||||||
if (!repoParameter) throw new Error('A repo must be set!');
|
if (!repoParameter) throw new Error('A repo must be set!');
|
||||||
@@ -17,10 +17,6 @@ const fetchPullRequests = async ($: IGlobalVariable) => {
|
|||||||
per_page: 100,
|
per_page: 100,
|
||||||
};
|
};
|
||||||
|
|
||||||
const pullRequests: ITriggerOutput = {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
let links;
|
let links;
|
||||||
do {
|
do {
|
||||||
const response = await $.http.get(pathname, { params });
|
const response = await $.http.get(pathname, { params });
|
||||||
@@ -34,7 +30,7 @@ const fetchPullRequests = async ($: IGlobalVariable) => {
|
|||||||
pullRequestId <= Number($.flow.lastInternalId) &&
|
pullRequestId <= Number($.flow.lastInternalId) &&
|
||||||
!$.execution.testRun
|
!$.execution.testRun
|
||||||
)
|
)
|
||||||
return pullRequests;
|
return;
|
||||||
|
|
||||||
const dataItem = {
|
const dataItem = {
|
||||||
raw: pullRequest,
|
raw: pullRequest,
|
||||||
@@ -43,20 +39,10 @@ const fetchPullRequests = async ($: IGlobalVariable) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pullRequests.data.push(dataItem);
|
$.pushTriggerItem(dataItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (links.next && !$.execution.testRun);
|
} while (links.next && !$.execution.testRun);
|
||||||
|
|
||||||
return pullRequests;
|
|
||||||
};
|
|
||||||
|
|
||||||
const newPullRequests = async ($: IGlobalVariable) => {
|
|
||||||
const pullRequests = await fetchPullRequests($);
|
|
||||||
|
|
||||||
pullRequests.data.reverse();
|
|
||||||
|
|
||||||
return pullRequests;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default newPullRequests;
|
export default newPullRequests;
|
||||||
|
Reference in New Issue
Block a user