Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
code: 0,
// Redirect to local project page
redirect: details.redirecter(params.target.repoRef),
// local SDM uses this to print instructions
generatedRepositoryUrl: params.target.repoRef.url,
} as any;
} catch (err) {
if (err instanceof CommandListenerExecutionInterruptError) {
// We're continuing
return Success as any;
}
await ctx.messageClient.respond(
slackErrorMessage(
`Create Project`,
`Project creation for ${bold(`${params.target.repoRef.owner}/${params.target.repoRef.repo}`)} failed:
${codeBlock(err.message)}`,
ctx));
}
}
codeTransformName,
{
// reuse the other parameters, but set the dryRun flag to false and pin to one repo
...params,
"dry-run": false,
"dry-run.msgId": msgId,
"targets.sha": params.targets.sha,
"targets.owner": id.owner,
"targets.repo": id.repo,
}),
],
};
await ctx.messageClient.respond(
slackInfoMessage(
`Code Transform (dry run)`,
`Code transform ${italic(codeTransformName)} would make the following changes to ${bold(slug(id))}:
${codeBlock(diff)}
`, applyAction), { id: msgId });
}
public handle(e: EventFired, ctx: HandlerContext): Promise {
const push = e.data.GitLabPush[0];
const text = `${push.commits.length} new ${(push.commits.length > 1 ? "commits" : "commit")} ` +
`to ${bold(url(push.repository.git_http_url, `${push.user_username}/${push.repository.name}/master`))}`;
const msg: SlackMessage = {
text,
attachments: [{
fallback: text,
author_name: `@${push.user_username}`,
author_icon: push.user_avatar,
text: push.commits.map(c => `\`${url(c.url, c.id.slice(0, 7))}\` ${c.message.slice(0, 49)}`).join("\n"),
mrkdwn_in: ["text"],
color: "#00a5ff",
},
],
};
return ctx.messageClient.send(msg, addressSlackChannels("FIXME", "gitlab"))
.then(() => Success, failure);
}
}
owner: cli.parameters.targets.repoRef.owner,
repo: cli.parameters.targets.repoRef.repo,
});
} catch (e) {
const text = `Repository ${bold(slug)} not found`;
return cli.context.messageClient.respond(slackWarningMessage("Set Goal State", text, cli.context));
}
const branch = cli.parameters.targets.repoRef.branch || repoData.defaultBranch;
let sha;
try {
sha = cli.parameters.targets.repoRef.sha || tipOfBranch(repoData, branch);
} catch (e) {
return cli.context.messageClient.respond(
slackWarningMessage(
"Set Goal State",
`Branch ${bold(branch)} not found on ${bold(slug)}`,
cli.context));
}
const id = GitHubRepoRef.from({
owner: cli.parameters.targets.repoRef.owner,
repo: cli.parameters.targets.repoRef.repo,
sha,
branch,
});
const push = await fetchPushForCommit(cli.context, id, cli.parameters.providerId);
const goals = await chooseAndSetGoals(rules, {
context: cli.context,
credentials: cli.credentials,
push,
export function reportDeployEnablement(params: SetDeployEnablementParameters,
enabled: boolean,
msgId: string): SlackMessage {
const text = `Deploy is currently ${enabled ? "enabled" : "disabled"} on ${bold(`${params.owner}/${params.repo}`)}`;
const actions =
[buttonForCommand({ text: enabled ? "Disable" : "Enable" },
enabled ? "DisableDeploy" : "EnableDeploy",
{ ...params, msgId })];
const msg: SlackMessage = {
attachments: [{
author_icon: `https://images.atomist.com/rug/check-circle.gif?gif=${guid()}`,
author_name: "Deploy Enablement",
text,
fallback: text,
color: enabled ? "#37A745" : "#B5B5B5",
mrkdwn_in: ["text"],
actions,
footer: `${params.name}:${params.version}`,
}],
};
}
if (result && result.SdmGoalSet && result.SdmGoalSet.length === 1) {
const gs = result.SdmGoalSet[0];
const newGoalSet: any = {
...gs,
state: SdmGoalState.canceled,
};
await storeGoalSet(ctx, newGoalSet);
}
await ctx.messageClient.respond(
slackInfoMessage(
"Cancel Goal Set",
`Canceled goal set ${italic(goalSet.goalSet)} ${codeLine(goalSetId.slice(0, 7))} on ${
codeLine(goalSet.sha.slice(0, 7))} of ${bold(`${goalSet.repo.owner}/${goalSet.repo.name}/${goalSet.branch}`)}`),
{ id });
}
credentials: cli.credentials,
push,
});
const slugBranch = `${id.owner}/${id.repo}/${push.branch}`;
if (goals) {
await cli.addressChannels(slackSuccessMessage(
"Plan Goals",
`Successfully planned goals on ${codeLine(push.after.sha.slice(0, 7))} of ${bold(slugBranch)} to ${italic(goals.name)}`,
{
footer: `${cli.parameters.name}:${cli.parameters.version}`,
}));
} else {
await cli.addressChannels(slackWarningMessage(
"Plan Goals",
`No goals found for ${codeLine(push.after.sha.slice(0, 7))} of ${bold(slugBranch)}`,
cli.context,
{
footer: `${cli.parameters.name}:${cli.parameters.version}`,
}));
}
return Success;
};
}
name: repo.name,
branch: repo.defaultBranch || "master",
};
}),
};
const prefs: PreferenceStore = configurationValue("sdm.preferenceStoreFactory")(ctx);
const analyzed = await prefs.get(preferenceKey(org.owner), { scope: PreferenceScope.Sdm, defaultValue: false });
if (!analyzed) {
try {
await createJob({
command: calculateFingerprintTask([], []),
parameters: repos.tasks,
name: `OrganizationAnalysis/${provider.providerId}/${org.owner}`,
description: `Analyzing repositories in ${bold(org.owner)}`,
concurrentTasks: 1,
},
ctx);
await prefs.put(preferenceKey(org.owner), true, { scope: PreferenceScope.Sdm });
} catch (e) {
logger.warn("Failed to create job for org '%s': %s", org.owner, e.message);
}
}
}
};
}),
};
});
const prefs: PreferenceStore = configurationValue("sdm.preferenceStoreFactory")(ctx);
for (const org of orgs) {
const analyzed = await prefs.get(preferenceKey(org.name), { scope: PreferenceScope.Sdm, defaultValue: false });
if (!analyzed || rerun) {
try {
await createJob({
command: calculateFingerprintTask([], []),
parameters: org.tasks,
name: `OrganizationAnalysis/${org.providerId}/${org.name}`,
description: `Analyzing repositories in ${bold(org.name)}`,
},
ctx);
await prefs.put(preferenceKey(org.name), true, { scope: PreferenceScope.Sdm });
} catch (e) {
logger.warn("Failed to create job for org '%s': %s", org.name, e.message);
}
}
}
}