Skip to content

Commit

Permalink
Use the same base tag for shallow-exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Nov 17, 2023
1 parent 490dd4f commit 647d0ae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
18 changes: 9 additions & 9 deletions .github/actions/javascript/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007);

/**
* @param {String} tag
* @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster)
*/
function fetchTag(tag) {
const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH);
function fetchTag(tag, shallowExcludeTag = '') {
let shouldRetry = true;
let needsRepack = false;
while (shouldRetry) {
Expand All @@ -208,11 +208,9 @@ function fetchTag(tag) {

command = `git fetch origin tag ${tag} --no-tags`;

// Exclude commits reachable from the previous patch version (i.e: previous checklist),
// so that we don't have to fetch the full history
// Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case
if (previousPatchVersion !== tag) {
command += ` --shallow-exclude=${previousPatchVersion}`;
// Note that this condition is only ever NOT true in the 1.0.0-0 edge case
if (shallowExcludeTag && shallowExcludeTag !== tag) {
command += ` --shallow-exclude=${shallowExcludeTag}`;
}

console.log(`Running command: ${command}`);
Expand All @@ -239,8 +237,10 @@ function fetchTag(tag) {
* @returns {Promise<Array<Object<{commit: String, subject: String, authorName: String}>>>}
*/
function getCommitHistoryAsJSON(fromTag, toTag) {
fetchTag(fromTag);
fetchTag(toTag);
// Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH);
fetchTag(fromTag, previousPatchVersion);
fetchTag(toTag, previousPatchVersion);

console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
return new Promise((resolve, reject) => {
Expand Down
18 changes: 9 additions & 9 deletions .github/actions/javascript/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007);

/**
* @param {String} tag
* @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster)
*/
function fetchTag(tag) {
const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH);
function fetchTag(tag, shallowExcludeTag = '') {
let shouldRetry = true;
let needsRepack = false;
while (shouldRetry) {
Expand All @@ -151,11 +151,9 @@ function fetchTag(tag) {

command = `git fetch origin tag ${tag} --no-tags`;

// Exclude commits reachable from the previous patch version (i.e: previous checklist),
// so that we don't have to fetch the full history
// Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case
if (previousPatchVersion !== tag) {
command += ` --shallow-exclude=${previousPatchVersion}`;
// Note that this condition is only ever NOT true in the 1.0.0-0 edge case
if (shallowExcludeTag && shallowExcludeTag !== tag) {
command += ` --shallow-exclude=${shallowExcludeTag}`;
}

console.log(`Running command: ${command}`);
Expand All @@ -182,8 +180,10 @@ function fetchTag(tag) {
* @returns {Promise<Array<Object<{commit: String, subject: String, authorName: String}>>>}
*/
function getCommitHistoryAsJSON(fromTag, toTag) {
fetchTag(fromTag);
fetchTag(toTag);
// Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH);
fetchTag(fromTag, previousPatchVersion);
fetchTag(toTag, previousPatchVersion);

console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
return new Promise((resolve, reject) => {
Expand Down
18 changes: 9 additions & 9 deletions .github/libs/GitUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = require('../libs/versionUp

/**
* @param {String} tag
* @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster)
*/
function fetchTag(tag) {
const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH);
function fetchTag(tag, shallowExcludeTag = '') {
let shouldRetry = true;
let needsRepack = false;
while (shouldRetry) {
Expand All @@ -24,11 +24,9 @@ function fetchTag(tag) {

command = `git fetch origin tag ${tag} --no-tags`;

// Exclude commits reachable from the previous patch version (i.e: previous checklist),
// so that we don't have to fetch the full history
// Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case
if (previousPatchVersion !== tag) {
command += ` --shallow-exclude=${previousPatchVersion}`;
// Note that this condition is only ever NOT true in the 1.0.0-0 edge case
if (shallowExcludeTag && shallowExcludeTag !== tag) {
command += ` --shallow-exclude=${shallowExcludeTag}`;
}

console.log(`Running command: ${command}`);
Expand All @@ -55,8 +53,10 @@ function fetchTag(tag) {
* @returns {Promise<Array<Object<{commit: String, subject: String, authorName: String}>>>}
*/
function getCommitHistoryAsJSON(fromTag, toTag) {
fetchTag(fromTag);
fetchTag(toTag);
// Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH);
fetchTag(fromTag, previousPatchVersion);
fetchTag(toTag, previousPatchVersion);

console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit 647d0ae

Please sign in to comment.