Skip to content

Commit 8307217

Browse files
authored
Removing FF for Draft PR (#2524)
- Removing FF for draft PR
1 parent a1c786c commit 8307217

File tree

4 files changed

+14
-39
lines changed

4 files changed

+14
-39
lines changed

src/config/feature-flags.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const launchdarklyClient = LaunchDarkly.init(envVars.LAUNCHDARKLY_KEY || "", {
1313

1414
export enum BooleanFlags {
1515
MAINTENANCE_MODE = "maintenance-mode",
16-
INNO_DRAFT_PR = "inno-draft-pr",
1716
VERBOSE_LOGGING = "verbose-logging",
1817
SEND_PR_COMMENTS_TO_JIRA = "send-pr-comments-to-jira_zy5ib",
1918
JIRA_ADMIN_CHECK = "jira-admin-check",

src/sync/pull-request.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,11 @@ const getPullRequestTaskGraphQL = async (
118118

119119
const response = await gitHubInstallationClient.getPullRequestPage(repository.owner.login, repository.name, perPage, cursor);
120120

121-
const isDraftPrFfOn = await booleanFlag(BooleanFlags.INNO_DRAFT_PR);
122-
123121
const filteredByCreatedSince = response.repository?.pullRequests?.edges
124122
.filter(pull => !createdSince || pull.node.createdAt > createdSince.toISOString());
125123
const alwaysSend = await shouldSendAll("prs-backfill", jiraHost, logger);
126124
const pullRequests = filteredByCreatedSince
127-
?.map((edge) => transformPullRequest(repository, jiraHost, edge.node, alwaysSend, logger, isDraftPrFfOn))
125+
?.map((edge) => transformPullRequest(repository, jiraHost, edge.node, alwaysSend, logger))
128126
?.filter((pr) => pr !== undefined) || [];
129127

130128
(logger.fields || {}).prNumberArray = pullRequests.map(pull => createHashWithSharedSecret(String(pull?.id)));

src/transforms/transform-pull-request.test.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import multipleReviewersWithMultipleReviews
88
import { GitHubInstallationClient } from "~/src/github/client/github-installation-client";
99
import { getInstallationId } from "~/src/github/client/installation-id";
1010
import { getLogger } from "config/logger";
11-
import { booleanFlag, BooleanFlags, shouldSendAll } from "config/feature-flags";
11+
import { shouldSendAll } from "config/feature-flags";
1212
import _, { cloneDeep } from "lodash";
1313
import { createLogger } from "bunyan";
1414
import { when } from "jest-when";
@@ -21,10 +21,6 @@ describe("pull_request transform REST", () => {
2121
beforeEach(() => {
2222
mockSystemTime(12345678);
2323
client = new GitHubInstallationClient(getInstallationId(gitHubInstallationId), gitHubCloudConfig, jiraHost, { trigger: "test" }, getLogger("test"));
24-
25-
when(booleanFlag).calledWith(
26-
BooleanFlags.INNO_DRAFT_PR
27-
).mockResolvedValue(true);
2824
});
2925

3026
it("should not contain branches on the payload if pull request status is closed.", async () => {
@@ -746,9 +742,7 @@ describe("pull_request transform GraphQL", () => {
746742

747743
const { updatedAt } = payload;
748744

749-
const isDraftPrFFOn = true;
750-
751-
const data = transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger, isDraftPrFFOn);
745+
const data = transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger);
752746

753747
expect(data).toMatchObject({
754748
author: {
@@ -788,9 +782,7 @@ describe("pull_request transform GraphQL", () => {
788782

789783
const { updatedAt } = payload;
790784

791-
const isDraftPrFFOn = true;
792-
793-
const data = transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger, isDraftPrFFOn);
785+
const data = transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger);
794786

795787
expect(data).toStrictEqual({
796788
author: {
@@ -832,9 +824,7 @@ describe("pull_request transform GraphQL", () => {
832824

833825
const { updatedAt } = payload;
834826

835-
const isDraftPrFFOn = true;
836-
837-
const data = await transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger, isDraftPrFFOn);
827+
const data = await transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger);
838828

839829
expect(data).toStrictEqual({
840830
author: {
@@ -874,9 +864,7 @@ describe("pull_request transform GraphQL", () => {
874864
const payload = { ...createPullPayload(title), author: {} };
875865
payload.reviews = createReview("APPROVED", "cool-email@emails.com");
876866

877-
const isDraftPrFFOn = true;
878-
879-
const data = await transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger, isDraftPrFFOn);
867+
const data = await transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger);
880868
const { updatedAt } = payload;
881869

882870
expect(data).toMatchObject({
@@ -915,9 +903,7 @@ describe("pull_request transform GraphQL", () => {
915903
const payload = { ...createPullPayload(title), author: {} };
916904
payload.reviews = createMultipleReviews();
917905

918-
const isDraftPrFFOn = true;
919-
920-
const data = await transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger, isDraftPrFFOn);
906+
const data = await transformPullRequest(REPO_OBJ, jiraHost, payload as any, true, logger);
921907

922908
expect({ firstReviewStatus: data?.reviewers[0] }).toEqual(expect.objectContaining({
923909
firstReviewStatus: expect.objectContaining({

src/transforms/transform-pull-request.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ import { booleanFlag, BooleanFlags, shouldSendAll } from "config/feature-flags";
1313
import { getLogger } from "config/logger";
1414
import { Repository } from "models/subscription";
1515

16-
export const mapStatus = (status: string, draft: boolean, isDraftPrFfOn: boolean, merged_at?: string) => {
16+
export const mapStatus = (status: string, draft: boolean, merged_at?: string) => {
1717
if (status.toLowerCase() === "merged") return "MERGED";
18-
if (isDraftPrFfOn) {
19-
if (status.toLowerCase() === "open" && !draft) return "OPEN";
20-
if (status.toLowerCase() === "open" && draft) return "DRAFT";
21-
} else {
22-
if (status.toLowerCase() === "open") return "OPEN";
23-
}
18+
if (status.toLowerCase() === "open" && !draft) return "OPEN";
19+
if (status.toLowerCase() === "open" && draft) return "DRAFT";
2420
if (status.toLowerCase() === "closed" && merged_at) return "MERGED";
2521
if (status.toLowerCase() === "closed" && !merged_at) return "DECLINED";
2622
if (status.toLowerCase() === "declined") return "DECLINED";
@@ -139,13 +135,11 @@ export const transformPullRequestRest = async (
139135
return undefined;
140136
}
141137

142-
const isDraftPrFfOn = await booleanFlag(BooleanFlags.INNO_DRAFT_PR);
143-
144138
const branches = await getBranches(gitHubInstallationClient, pullRequest, issueKeys, log);
145139
// Need to get full name from a REST call as `pullRequest.user.login` doesn't have it
146140
const author = getJiraAuthor(user, await getGithubUser(gitHubInstallationClient, user?.login, log));
147141
const reviewers = await mapReviewsRest(reviews, gitHubInstallationClient, log);
148-
const status = mapStatus(state, draft, isDraftPrFfOn, merged_at);
142+
const status = mapStatus(state, draft, merged_at);
149143

150144
return {
151145
...transformRepositoryDevInfoBulk(base.repo, gitHubInstallationClient.baseUrl),
@@ -177,9 +171,7 @@ export const transformPullRequestRest = async (
177171
// Reason: If "Automatically delete head branches" is enabled, the branch deleted and PR merged events might be sent out
178172
// “at the same time” and received out of order, which causes the branch being created again.
179173
const getBranches = async (gitHubInstallationClient: GitHubInstallationClient, pullRequest: Octokit.PullsGetResponse, issueKeys: string[], logger: Logger) => {
180-
const isDraftPrFfOn = await booleanFlag(BooleanFlags.INNO_DRAFT_PR);
181-
182-
if (mapStatus(pullRequest.state, pullRequest.draft, isDraftPrFfOn, pullRequest.merged_at) === "MERGED") {
174+
if (mapStatus(pullRequest.state, pullRequest.draft, pullRequest.merged_at) === "MERGED") {
183175
return [];
184176
}
185177

@@ -208,7 +200,7 @@ const getBranches = async (gitHubInstallationClient: GitHubInstallationClient, p
208200
];
209201
};
210202

211-
export const transformPullRequest = (repository: Repository, _jiraHost: string, pullRequest: pullRequestNode, alwaysSend: boolean, log: Logger, isDraftPrFfOn: boolean) => {
203+
export const transformPullRequest = (repository: Repository, _jiraHost: string, pullRequest: pullRequestNode, alwaysSend: boolean, log: Logger) => {
212204
const issueKeys = extractIssueKeysFromPr(pullRequest);
213205

214206
if (isEmpty(issueKeys) && !alwaysSend) {
@@ -219,7 +211,7 @@ export const transformPullRequest = (repository: Repository, _jiraHost: string,
219211
return undefined;
220212
}
221213

222-
const status = mapStatus(pullRequest.state, pullRequest.draft, isDraftPrFfOn, pullRequest.mergedAt);
214+
const status = mapStatus(pullRequest.state, pullRequest.draft, pullRequest.mergedAt);
223215

224216
return {
225217
author: getJiraAuthor(pullRequest.author),

0 commit comments

Comments
 (0)