Skip to content

Commit 7f38700

Browse files
fix: which links ends up in linear preview [DEVOP-665] (#105)
1 parent 8d34e4e commit 7f38700

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

lib/actions/amplify.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,22 @@ exports.getAmplifyURIs = async function getAmplifyURI() {
2323
(label) => label.startsWith("packages/") || label.startsWith("configs/")
2424
);
2525

26-
if (hasAtLeastOnePackageOrConfig) {
26+
const allLinks = Object.entries(amplifyUris).map(([label, url]) => {
27+
const hasLabel = labels.some((l) => label.includes(l));
2728
return {
28-
links: Object.entries(amplifyUris).map(([label, url]) => {
29-
return { label, url };
30-
}),
29+
label,
30+
url,
31+
isVisibleInComment: hasAtLeastOnePackageOrConfig || hasLabel,
32+
hasPreview: hasLabel,
3133
};
32-
}
33-
34-
const links = [];
35-
const hiddenLinks = [];
36-
for (const label of labels) {
37-
if (amplifyUris[label]) {
38-
links.push({ label, url: amplifyUris[label] });
39-
}
40-
}
41-
for (const [key, url] of Object.entries(amplifyUris)) {
42-
if (!labels.includes(key)) {
43-
hiddenLinks.push(url);
44-
}
45-
}
46-
return { links, hiddenLinks };
34+
});
35+
return {
36+
links: allLinks.filter((l) => l.isVisibleInComment),
37+
hiddenLinks: allLinks.filter((l) => !l.isVisibleInComment),
38+
};
4739
} else if (!amplifyUri) {
4840
return {};
4941
} else {
50-
return { links: [amplifyUri] };
42+
return { links: [{ url: amplifyUri, hasPreview: true }] };
5143
}
5244
};

lib/actions/pullRequest.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,15 @@ exports.validatePR = async function validatePR({ pullRequest, issue }) {
9898
"AWS Amplify live test URI:\n" +
9999
"- " +
100100
amplifyUris
101-
.map((elt) => `[${elt.label?.split("/")?.pop()} preview](${elt.url})`)
101+
.map(
102+
(elt) =>
103+
`[${[
104+
elt.label?.split("/")?.pop(),
105+
elt.hasPreview ? " preview" : undefined, // any link with "preview" in the label will be displayed in the linked linear issue
106+
]
107+
.filter(Boolean)
108+
.join(" ")}](${elt.url})`
109+
)
102110
.join("\n- ") +
103111
hiddenAmplifyText;
104112
const previousComments = comments.filter(({ body }) =>

0 commit comments

Comments
 (0)