Skip to content

Commit

Permalink
Auto merge pull request #559 from atomist/sdm
Browse files Browse the repository at this point in the history
* Add fetchGoalsFromPush method to read goals from subscription

* Autofix: TypeScript header

[atomist:generated] [atomist:autofix=typescript header]

* Use every
  • Loading branch information
cdupuis authored and atomist-bot committed Oct 25, 2018
1 parent 0b2867c commit 76f3e24
Show file tree
Hide file tree
Showing 3 changed files with 2,052 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/api-helper/goal/fetchGoalsOnCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ import {
import { goalKeyString } from "./sdmGoal";
import { goalCorrespondsToSdmGoal } from "./storeGoals";

export function fetchGoalsFromPush(sdmGoal: SdmGoalEvent): SdmGoalEvent[] {
const goals = sumSdmGoalEvents((sdmGoal.push as any).goals.filter(g => g.goalSetId === sdmGoal.goalSetId));
const push = _.cloneDeep(sdmGoal.push);
delete (push as any).goals;
goals.forEach(g => g.push = push);
return goals;
}

export async function findSdmGoalOnCommit(ctx: HandlerContext, id: RemoteRepoRef, providerId: string, goal: Goal): Promise<SdmGoalEvent> {
const sdmGoals = await fetchGoalsForCommit(ctx, id, providerId);
const matches = sdmGoals.filter(g => goalCorrespondsToSdmGoal(goal, g));
Expand Down
Loading

0 comments on commit 76f3e24

Please sign in to comment.