Comparing version 1.3.0 to 1.4.0
{ | ||
"name": "happo-e2e", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Helpers for e2e integrations with Happo", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -138,5 +138,37 @@ const { spawnSync } = require('child_process'); | ||
function resolveShaFromTagMatcher(tagMatcher) { | ||
const res = spawnSync( | ||
'git', | ||
['tag', '--list', tagMatcher, '--sort', 'refname', '--no-contains'], | ||
{ | ||
encoding: 'utf-8', | ||
}, | ||
); | ||
if (res.status !== 0) { | ||
throw new Error( | ||
`Failed to list git tags when matching against HAPPO_BEFORE_SHA_TAG_MATCHER. Error: ${res.stderr}`, | ||
); | ||
} | ||
const rawAllTags = res.stdout.trim(); | ||
if (!rawAllTags.length) { | ||
return undefined; | ||
} | ||
const allTags = rawAllTags.split('\n'); | ||
const tag = allTags[allTags.length - 1]; | ||
const commitRes = spawnSync('git', ['rev-list', '-n', '1', tag], { | ||
encoding: 'utf-8', | ||
}); | ||
if (commitRes.status !== 0) { | ||
throw new Error( | ||
`Failed to resolve commit sha from tag "${tag}". Error: ${res.stderr}`, | ||
); | ||
} | ||
return commitRes.stdout.trim(); | ||
} | ||
function resolveBeforeSha(env, afterSha) { | ||
const { | ||
HAPPO_PREVIOUS_SHA, | ||
HAPPO_BEFORE_SHA_TAG_MATCHER, | ||
PREVIOUS_SHA, | ||
@@ -160,2 +192,9 @@ HAPPO_BASE_BRANCH, | ||
if (HAPPO_BEFORE_SHA_TAG_MATCHER) { | ||
const resolvedSha = resolveShaFromTagMatcher(HAPPO_BEFORE_SHA_TAG_MATCHER); | ||
if (resolvedSha) { | ||
return resolvedSha; | ||
} | ||
} | ||
if (/^dev-/.test(afterSha)) { | ||
@@ -162,0 +201,0 @@ // The afterSha has been auto-generated. Use the special __LATEST__ sha in |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93805
2879