Skip to content

Commit abb8b72

Browse files
roryabrahamOSBotify
authored andcommitted
Merge pull request #59739 from Expensify/andrew-git-prod
[No QA] Update `CIGitLogicTest.ts` for cherry pick to production (cherry picked from commit d2de56f) (CP triggered by AndrewGable)
1 parent 4a838ec commit abb8b72

File tree

5 files changed

+210
-160
lines changed

5 files changed

+210
-160
lines changed

.github/actions/javascript/createOrUpdateStagingDeploy/index.js

+11-29
Original file line numberDiff line numberDiff line change
@@ -11643,37 +11643,14 @@ exports["default"] = CONST;
1164311643

1164411644
"use strict";
1164511645

11646-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11647-
if (k2 === undefined) k2 = k;
11648-
var desc = Object.getOwnPropertyDescriptor(m, k);
11649-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11650-
desc = { enumerable: true, get: function() { return m[k]; } };
11651-
}
11652-
Object.defineProperty(o, k2, desc);
11653-
}) : (function(o, m, k, k2) {
11654-
if (k2 === undefined) k2 = k;
11655-
o[k2] = m[k];
11656-
}));
11657-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
11658-
Object.defineProperty(o, "default", { enumerable: true, value: v });
11659-
}) : function(o, v) {
11660-
o["default"] = v;
11661-
});
11662-
var __importStar = (this && this.__importStar) || function (mod) {
11663-
if (mod && mod.__esModule) return mod;
11664-
var result = {};
11665-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
11666-
__setModuleDefault(result, mod);
11667-
return result;
11668-
};
1166911646
var __importDefault = (this && this.__importDefault) || function (mod) {
1167011647
return (mod && mod.__esModule) ? mod : { "default": mod };
1167111648
};
1167211649
Object.defineProperty(exports, "__esModule", ({ value: true }));
1167311650
const child_process_1 = __nccwpck_require__(2081);
1167411651
const CONST_1 = __importDefault(__nccwpck_require__(9873));
1167511652
const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(3902));
11676-
const VersionUpdater = __importStar(__nccwpck_require__(8982));
11653+
const versionUpdater_1 = __nccwpck_require__(8982);
1167711654
/**
1167811655
* Check if a tag exists locally or in the remote.
1167911656
*/
@@ -11721,15 +11698,20 @@ function tagExists(tag) {
1172111698
* @param level the Semver level to step backward by
1172211699
*/
1172311700
function getPreviousExistingTag(tag, level) {
11724-
let previousVersion = VersionUpdater.getPreviousVersion(tag, level);
11701+
let previousVersion = (0, versionUpdater_1.getPreviousVersion)(tag.replace('-staging', ''), level);
1172511702
let tagExistsForPreviousVersion = false;
1172611703
while (!tagExistsForPreviousVersion) {
1172711704
if (tagExists(previousVersion)) {
1172811705
tagExistsForPreviousVersion = true;
1172911706
break;
1173011707
}
11708+
if (tagExists(`${previousVersion}-staging`)) {
11709+
tagExistsForPreviousVersion = true;
11710+
previousVersion = `${previousVersion}-staging`;
11711+
break;
11712+
}
1173111713
console.log(`Tag for previous version ${previousVersion} does not exist. Checking for an older version...`);
11732-
previousVersion = VersionUpdater.getPreviousVersion(previousVersion, level);
11714+
previousVersion = (0, versionUpdater_1.getPreviousVersion)(previousVersion, level);
1173311715
}
1173411716
return previousVersion;
1173511717
}
@@ -11775,8 +11757,8 @@ function fetchTag(tag, shallowExcludeTag = '') {
1177511757
* Get merge logs between two tags (inclusive) as a JavaScript object.
1177611758
*/
1177711759
function getCommitHistoryAsJSON(fromTag, toTag) {
11778-
// Fetch tags, excluding commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
11779-
const previousPatchVersion = getPreviousExistingTag(fromTag, VersionUpdater.SEMANTIC_VERSION_LEVELS.PATCH);
11760+
// Fetch tags, excluding commits reachable from the previous patch version (or minor for prod) (i.e: previous checklist), so that we don't have to fetch the full history
11761+
const previousPatchVersion = getPreviousExistingTag(fromTag.replace('-staging', ''), fromTag.endsWith('-staging') ? versionUpdater_1.SEMANTIC_VERSION_LEVELS.PATCH : versionUpdater_1.SEMANTIC_VERSION_LEVELS.MINOR);
1178011762
fetchTag(fromTag, previousPatchVersion);
1178111763
fetchTag(toTag, previousPatchVersion);
1178211764
console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
@@ -11821,7 +11803,7 @@ function getValidMergedPRs(commits) {
1182111803
if (author === CONST_1.default.OS_BOTIFY) {
1182211804
return;
1182311805
}
11824-
const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/);
11806+
const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-(staging|production))/);
1182511807
if (!Array.isArray(match) || match.length < 2) {
1182611808
return;
1182711809
}

.github/actions/javascript/getDeployPullRequestList/index.js

+11-29
Original file line numberDiff line numberDiff line change
@@ -11684,37 +11684,14 @@ exports["default"] = CONST;
1168411684

1168511685
"use strict";
1168611686

11687-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11688-
if (k2 === undefined) k2 = k;
11689-
var desc = Object.getOwnPropertyDescriptor(m, k);
11690-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11691-
desc = { enumerable: true, get: function() { return m[k]; } };
11692-
}
11693-
Object.defineProperty(o, k2, desc);
11694-
}) : (function(o, m, k, k2) {
11695-
if (k2 === undefined) k2 = k;
11696-
o[k2] = m[k];
11697-
}));
11698-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
11699-
Object.defineProperty(o, "default", { enumerable: true, value: v });
11700-
}) : function(o, v) {
11701-
o["default"] = v;
11702-
});
11703-
var __importStar = (this && this.__importStar) || function (mod) {
11704-
if (mod && mod.__esModule) return mod;
11705-
var result = {};
11706-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
11707-
__setModuleDefault(result, mod);
11708-
return result;
11709-
};
1171011687
var __importDefault = (this && this.__importDefault) || function (mod) {
1171111688
return (mod && mod.__esModule) ? mod : { "default": mod };
1171211689
};
1171311690
Object.defineProperty(exports, "__esModule", ({ value: true }));
1171411691
const child_process_1 = __nccwpck_require__(2081);
1171511692
const CONST_1 = __importDefault(__nccwpck_require__(9873));
1171611693
const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(3902));
11717-
const VersionUpdater = __importStar(__nccwpck_require__(8982));
11694+
const versionUpdater_1 = __nccwpck_require__(8982);
1171811695
/**
1171911696
* Check if a tag exists locally or in the remote.
1172011697
*/
@@ -11762,15 +11739,20 @@ function tagExists(tag) {
1176211739
* @param level the Semver level to step backward by
1176311740
*/
1176411741
function getPreviousExistingTag(tag, level) {
11765-
let previousVersion = VersionUpdater.getPreviousVersion(tag, level);
11742+
let previousVersion = (0, versionUpdater_1.getPreviousVersion)(tag.replace('-staging', ''), level);
1176611743
let tagExistsForPreviousVersion = false;
1176711744
while (!tagExistsForPreviousVersion) {
1176811745
if (tagExists(previousVersion)) {
1176911746
tagExistsForPreviousVersion = true;
1177011747
break;
1177111748
}
11749+
if (tagExists(`${previousVersion}-staging`)) {
11750+
tagExistsForPreviousVersion = true;
11751+
previousVersion = `${previousVersion}-staging`;
11752+
break;
11753+
}
1177211754
console.log(`Tag for previous version ${previousVersion} does not exist. Checking for an older version...`);
11773-
previousVersion = VersionUpdater.getPreviousVersion(previousVersion, level);
11755+
previousVersion = (0, versionUpdater_1.getPreviousVersion)(previousVersion, level);
1177411756
}
1177511757
return previousVersion;
1177611758
}
@@ -11816,8 +11798,8 @@ function fetchTag(tag, shallowExcludeTag = '') {
1181611798
* Get merge logs between two tags (inclusive) as a JavaScript object.
1181711799
*/
1181811800
function getCommitHistoryAsJSON(fromTag, toTag) {
11819-
// Fetch tags, excluding commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
11820-
const previousPatchVersion = getPreviousExistingTag(fromTag, VersionUpdater.SEMANTIC_VERSION_LEVELS.PATCH);
11801+
// Fetch tags, excluding commits reachable from the previous patch version (or minor for prod) (i.e: previous checklist), so that we don't have to fetch the full history
11802+
const previousPatchVersion = getPreviousExistingTag(fromTag.replace('-staging', ''), fromTag.endsWith('-staging') ? versionUpdater_1.SEMANTIC_VERSION_LEVELS.PATCH : versionUpdater_1.SEMANTIC_VERSION_LEVELS.MINOR);
1182111803
fetchTag(fromTag, previousPatchVersion);
1182211804
fetchTag(toTag, previousPatchVersion);
1182311805
console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
@@ -11862,7 +11844,7 @@ function getValidMergedPRs(commits) {
1186211844
if (author === CONST_1.default.OS_BOTIFY) {
1186311845
return;
1186411846
}
11865-
const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/);
11847+
const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-(staging|production))/);
1186611848
if (!Array.isArray(match) || match.length < 2) {
1186711849
return;
1186811850
}

.github/actions/javascript/getPreviousVersion/index.js

+11-29
Original file line numberDiff line numberDiff line change
@@ -2808,37 +2808,14 @@ exports["default"] = CONST;
28082808

28092809
"use strict";
28102810

2811-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2812-
if (k2 === undefined) k2 = k;
2813-
var desc = Object.getOwnPropertyDescriptor(m, k);
2814-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2815-
desc = { enumerable: true, get: function() { return m[k]; } };
2816-
}
2817-
Object.defineProperty(o, k2, desc);
2818-
}) : (function(o, m, k, k2) {
2819-
if (k2 === undefined) k2 = k;
2820-
o[k2] = m[k];
2821-
}));
2822-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
2823-
Object.defineProperty(o, "default", { enumerable: true, value: v });
2824-
}) : function(o, v) {
2825-
o["default"] = v;
2826-
});
2827-
var __importStar = (this && this.__importStar) || function (mod) {
2828-
if (mod && mod.__esModule) return mod;
2829-
var result = {};
2830-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2831-
__setModuleDefault(result, mod);
2832-
return result;
2833-
};
28342811
var __importDefault = (this && this.__importDefault) || function (mod) {
28352812
return (mod && mod.__esModule) ? mod : { "default": mod };
28362813
};
28372814
Object.defineProperty(exports, "__esModule", ({ value: true }));
28382815
const child_process_1 = __nccwpck_require__(81);
28392816
const CONST_1 = __importDefault(__nccwpck_require__(873));
28402817
const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(902));
2841-
const VersionUpdater = __importStar(__nccwpck_require__(982));
2818+
const versionUpdater_1 = __nccwpck_require__(982);
28422819
/**
28432820
* Check if a tag exists locally or in the remote.
28442821
*/
@@ -2886,15 +2863,20 @@ function tagExists(tag) {
28862863
* @param level the Semver level to step backward by
28872864
*/
28882865
function getPreviousExistingTag(tag, level) {
2889-
let previousVersion = VersionUpdater.getPreviousVersion(tag, level);
2866+
let previousVersion = (0, versionUpdater_1.getPreviousVersion)(tag.replace('-staging', ''), level);
28902867
let tagExistsForPreviousVersion = false;
28912868
while (!tagExistsForPreviousVersion) {
28922869
if (tagExists(previousVersion)) {
28932870
tagExistsForPreviousVersion = true;
28942871
break;
28952872
}
2873+
if (tagExists(`${previousVersion}-staging`)) {
2874+
tagExistsForPreviousVersion = true;
2875+
previousVersion = `${previousVersion}-staging`;
2876+
break;
2877+
}
28962878
console.log(`Tag for previous version ${previousVersion} does not exist. Checking for an older version...`);
2897-
previousVersion = VersionUpdater.getPreviousVersion(previousVersion, level);
2879+
previousVersion = (0, versionUpdater_1.getPreviousVersion)(previousVersion, level);
28982880
}
28992881
return previousVersion;
29002882
}
@@ -2940,8 +2922,8 @@ function fetchTag(tag, shallowExcludeTag = '') {
29402922
* Get merge logs between two tags (inclusive) as a JavaScript object.
29412923
*/
29422924
function getCommitHistoryAsJSON(fromTag, toTag) {
2943-
// Fetch tags, excluding commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
2944-
const previousPatchVersion = getPreviousExistingTag(fromTag, VersionUpdater.SEMANTIC_VERSION_LEVELS.PATCH);
2925+
// Fetch tags, excluding commits reachable from the previous patch version (or minor for prod) (i.e: previous checklist), so that we don't have to fetch the full history
2926+
const previousPatchVersion = getPreviousExistingTag(fromTag.replace('-staging', ''), fromTag.endsWith('-staging') ? versionUpdater_1.SEMANTIC_VERSION_LEVELS.PATCH : versionUpdater_1.SEMANTIC_VERSION_LEVELS.MINOR);
29452927
fetchTag(fromTag, previousPatchVersion);
29462928
fetchTag(toTag, previousPatchVersion);
29472929
console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
@@ -2986,7 +2968,7 @@ function getValidMergedPRs(commits) {
29862968
if (author === CONST_1.default.OS_BOTIFY) {
29872969
return;
29882970
}
2989-
const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/);
2971+
const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-(staging|production))/);
29902972
if (!Array.isArray(match) || match.length < 2) {
29912973
return;
29922974
}

.github/libs/GitUtils.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {execSync, spawn} from 'child_process';
22
import CONST from './CONST';
33
import sanitizeStringForJSONParse from './sanitizeStringForJSONParse';
4-
import * as VersionUpdater from './versionUpdater';
4+
import {getPreviousVersion, SEMANTIC_VERSION_LEVELS} from './versionUpdater';
55
import type {SemverLevel} from './versionUpdater';
66

77
type CommitType = {
@@ -55,15 +55,20 @@ function tagExists(tag: string) {
5555
* @param level the Semver level to step backward by
5656
*/
5757
function getPreviousExistingTag(tag: string, level: SemverLevel) {
58-
let previousVersion = VersionUpdater.getPreviousVersion(tag, level);
58+
let previousVersion = getPreviousVersion(tag.replace('-staging', ''), level);
5959
let tagExistsForPreviousVersion = false;
6060
while (!tagExistsForPreviousVersion) {
6161
if (tagExists(previousVersion)) {
6262
tagExistsForPreviousVersion = true;
6363
break;
6464
}
65+
if (tagExists(`${previousVersion}-staging`)) {
66+
tagExistsForPreviousVersion = true;
67+
previousVersion = `${previousVersion}-staging`;
68+
break;
69+
}
6570
console.log(`Tag for previous version ${previousVersion} does not exist. Checking for an older version...`);
66-
previousVersion = VersionUpdater.getPreviousVersion(previousVersion, level);
71+
previousVersion = getPreviousVersion(previousVersion, level);
6772
}
6873
return previousVersion;
6974
}
@@ -112,8 +117,8 @@ function fetchTag(tag: string, shallowExcludeTag = '') {
112117
* Get merge logs between two tags (inclusive) as a JavaScript object.
113118
*/
114119
function getCommitHistoryAsJSON(fromTag: string, toTag: string): Promise<CommitType[]> {
115-
// Fetch tags, excluding commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
116-
const previousPatchVersion = getPreviousExistingTag(fromTag, VersionUpdater.SEMANTIC_VERSION_LEVELS.PATCH);
120+
// Fetch tags, excluding commits reachable from the previous patch version (or minor for prod) (i.e: previous checklist), so that we don't have to fetch the full history
121+
const previousPatchVersion = getPreviousExistingTag(fromTag.replace('-staging', ''), fromTag.endsWith('-staging') ? SEMANTIC_VERSION_LEVELS.PATCH : SEMANTIC_VERSION_LEVELS.MINOR);
117122
fetchTag(fromTag, previousPatchVersion);
118123
fetchTag(toTag, previousPatchVersion);
119124

@@ -164,7 +169,7 @@ function getValidMergedPRs(commits: CommitType[]): number[] {
164169
return;
165170
}
166171

167-
const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/);
172+
const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-(staging|production))/);
168173
if (!Array.isArray(match) || match.length < 2) {
169174
return;
170175
}

0 commit comments

Comments
 (0)