Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit c50fed5

Browse files
committed
Clean up left overs from dry run to build aware rename
1 parent 7ca6bf6 commit c50fed5

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

src/pack/build-aware-transform/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { metadata } from "../../api-helper/misc/extensionPack";
1818
import { GitHubIssueRouter } from "../../api-helper/misc/git/GitHubIssueRouter";
1919
import { ExtensionPack } from "../../api/machine/ExtensionPack";
2020
import { IssueCreationOptions } from "../../spi/issue/IssueCreationOptions";
21-
import { dryRunBuildListener } from "./support/dryRunBuildListener";
21+
import { buildAwareBuildListener } from "./support/buildAwareBuildListener";
2222

2323
export { makeBuildAware } from "./support/makeBuildAware";
2424

@@ -31,14 +31,14 @@ export { makeBuildAware } from "./support/makeBuildAware";
3131
*/
3232
export function buildAwareCodeTransforms(opts: Partial<IssueCreationOptions> = {}): ExtensionPack {
3333
const optsToUse: IssueCreationOptions = {
34-
...opts,
3534
issueRouter: new GitHubIssueRouter(),
35+
...opts,
3636
};
3737

3838
return {
3939
...metadata("build-aware-code-transforms"),
4040
configure: sdm => {
41-
sdm.addBuildListener(dryRunBuildListener(optsToUse));
41+
sdm.addBuildListener(buildAwareBuildListener(optsToUse));
4242
},
4343
};
4444
}

src/pack/build-aware-transform/support/dryRunBuildListener.ts renamed to src/pack/build-aware-transform/support/buildAwareBuildListener.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,41 @@ import { IssueCreationOptions } from "../../../spi/issue/IssueCreationOptions";
2020
import { DryRunMessage } from "./makeBuildAware";
2121

2222
/**
23-
* React to result of a dry run build to raise a PR or issue
23+
* React to result of a build-aware build to raise a PR or issue.
2424
*/
25-
export function dryRunBuildListener(opts: IssueCreationOptions): BuildListener {
25+
export function buildAwareBuildListener(opts: IssueCreationOptions): BuildListener {
2626
return async bu => {
2727
const build = bu.build;
2828
const branch = build.push.branch;
2929

30-
logger.debug("Assessing dry run for %j: Commit message=%s", bu.id, bu.build.commit.message);
30+
logger.debug("Assessing build aware build for '%j': '%s'", bu.id, bu.build.commit.message);
3131
if (!bu.build.commit.message.includes(DryRunMessage)) {
32-
logger.info("Not a dry run commit: %j: Commit message=%s", bu.id, bu.build.commit.message);
32+
logger.info("Not a build aware build: '%j': '%s'", bu.id, bu.build.commit.message);
3333
return;
3434
}
3535

3636
const body = bu.build.commit.message.replace(DryRunMessage, "").trim() + "\n\n[atomist:generated]";
3737
const description = body.split("\n")[0];
3838
switch (build.status) {
3939
case "started" :
40-
logger.info("Tracking dry run build on %j on branch %s,", bu.id, branch);
40+
logger.info("Tracking build aware build on '%j' on branch '%s'", bu.id, branch);
4141
// Wait for conclusion
4242
break;
4343

4444
case "passed":
45-
logger.info("Raising PR for successful dry run build on %j", bu.id);
45+
logger.info("Raising PR for successful build aware build on '%j'", bu.id);
4646
const title = description;
4747
await bu.id.raisePullRequest(
4848
bu.credentials,
4949
title,
50-
body,
50+
body.replace(description, "").trim(),
5151
branch,
5252
"master");
5353
break;
5454

5555
case "failed" :
5656
case "broken":
57-
logger.info("Raising issue for failed dry run build on %j on branch %s,", bu.id, branch);
57+
logger.info("Raising issue for failed build aware build on '%j' on branch '%s',", bu.id, branch);
5858
let issueBody = "Details:\n\n";
5959
issueBody += !!build.buildUrl ? `[Build log](${build.buildUrl})` : "No build log available";
6060
issueBody += `\n\n[Branch with failure](${bu.id.url}/tree/${branch} "Failing branch ${branch}")`;
@@ -65,7 +65,8 @@ export function dryRunBuildListener(opts: IssueCreationOptions): BuildListener {
6565
break;
6666

6767
default :
68-
logger.info("Unexpected build status [%s] issue for failed dry run on %j on branch %s,", bu.build.status, bu.id, branch);
68+
logger.info("Unexpected build status [%s] issue for failed build aware build on '%j' on branch '%s'",
69+
bu.build.status, bu.id, branch);
6970
break;
7071
}
7172
};

src/pack/build-aware-transform/support/makeBuildAware.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { EditMode, isPullRequest } from "@atomist/automation-client/operations/edit/editModes";
17+
import {
18+
EditMode,
19+
isPullRequest,
20+
} from "@atomist/automation-client/operations/edit/editModes";
1821
import { TransformModeSuggestion } from "../../../api/command/target/TransformModeSuggestion";
19-
import { CodeTransformRegistration, CodeTransformRegistrationDecorator } from "../../../api/registration/CodeTransformRegistration";
22+
import {
23+
CodeTransformRegistration,
24+
CodeTransformRegistrationDecorator,
25+
} from "../../../api/registration/CodeTransformRegistration";
2026

21-
export const DryRunMessage = "[atomist:dry-run]";
27+
export const DryRunMessage = "[atomist:build-aware]";
2228

2329
/**
2430
* Return a function wrapping a CodeTransform registration to make
@@ -38,7 +44,7 @@ export const makeBuildAware: CodeTransformRegistrationDecorator<any> =
3844
} else {
3945
// No edit mode was set explicitly. We need to set one that sets a branch:
4046
// No PR for now
41-
const branch = (ci.parameters as TransformModeSuggestion).desiredBranchName || `${ctr.name}-${new Date().getTime()}`;
47+
const branch = (ci.parameters as TransformModeSuggestion).desiredBranchName || `${ctr.name}-${Date.now()}`;
4248
const desiredCommitMessage = (ci.parameters as TransformModeSuggestion).desiredCommitMessage
4349
|| dryRunMessage(ctr.description || ctr.name);
4450
return {

0 commit comments

Comments
 (0)