Skip to content

Commit

Permalink
fix: handle undefined reference caused by no tags on `commerce-data-e…
Browse files Browse the repository at this point in the history
…xport` (#165)
  • Loading branch information
rhoerr authored Jul 11, 2024
1 parent 92e89ad commit cc6f23a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/release-branch-build-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ async function getPackagesForBuildInstruction(instructions) {


// use the latest tag in branch ref
const baseVersionsOnRef = await getLatestTag(repoUrl);
console.log(`Basing ${repoUrl} package versions on those from tag ${baseVersionsOnRef}`);
const baseVersionsOnRef = await getLatestTag(repoUrl) || instructions.ref || 'HEAD';
console.log(`Basing ${repoUrl} package versions on those from reference ${baseVersionsOnRef}`);

for (const packageDir of (instructions.packageDirs || [])) {
const {label, dir, excludes} = Object.assign({excludes: []}, packageDir);
Expand Down
4 changes: 2 additions & 2 deletions src/repository/shell-git.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ function trimDir(dir) {
* @param {String} ref
*/
function validateRefIsSecure(ref) {
if (ref.substring(0, 1) === '-' || ref.includes(' ') || ref.includes('`') || ref.includes('$')) {
if (!ref || ref.substring(0, 1) === '-' || ref.includes(' ') || ref.includes('`') || ref.includes('$')) {
throw new Error(`Rejecting the ref "${ref}" as potentially insecure`)
}
return ref;
}

function validateBranchIsSecure(branch) {
if (branch.substring(0, 1) === '-' || branch.includes(' ') || branch.includes('`') || branch.includes('$')) {
if (!branch || branch.substring(0, 1) === '-' || branch.includes(' ') || branch.includes('`') || branch.includes('$')) {
throw new Error(`Rejecting the branch "${branch}" as potentially insecure`)
}
return branch;
Expand Down

0 comments on commit cc6f23a

Please sign in to comment.