mirror of
https://github.com/jimeh/update-tags-action.git
synced 2026-02-19 09:36:41 +00:00
feat(tags): support per-tag annotation overrides (#81)
This commit is contained in:
26
dist/index.js
generated
vendored
26
dist/index.js
generated
vendored
@@ -45373,16 +45373,16 @@ function createLogger(prefix = '') {
|
||||
async function planTagOperations(inputs, octokit) {
|
||||
const uniqueRefs = new Set();
|
||||
const tagRefs = {};
|
||||
const tagAnnotations = {};
|
||||
for (const tag of inputs.tags) {
|
||||
const parts = tag.split(':').map((s) => s.trim());
|
||||
if (parts.length > 2) {
|
||||
throw new Error(`Invalid tag specification '${tag}': too many colons. ` +
|
||||
`Format should be 'tag' or 'tag:ref'.`);
|
||||
}
|
||||
const [tagName, tagRef] = parts;
|
||||
const parts = tag.split(':');
|
||||
const tagName = (parts[0] || '').trim();
|
||||
const tagRef = (parts[1] || '').trim();
|
||||
// Join remaining parts back with colons to preserve annotation content
|
||||
const tagAnnotation = parts.slice(2).join(':').trim();
|
||||
if (!tagName) {
|
||||
// Skip completely empty tags, but fail on invalid ones like ":main"
|
||||
if (tagRef) {
|
||||
if (tagRef || tagAnnotation) {
|
||||
throw new Error(`Invalid tag: '${tag}'`);
|
||||
}
|
||||
continue;
|
||||
@@ -45397,6 +45397,9 @@ async function planTagOperations(inputs, octokit) {
|
||||
`'${tagRefs[tagName]}' and '${ref}'`);
|
||||
}
|
||||
tagRefs[tagName] = ref;
|
||||
if (tagAnnotation) {
|
||||
tagAnnotations[tagName] = tagAnnotation;
|
||||
}
|
||||
uniqueRefs.add(ref);
|
||||
}
|
||||
// Pre-resolve all unique refs in parallel.
|
||||
@@ -45410,6 +45413,7 @@ async function planTagOperations(inputs, octokit) {
|
||||
const result = await Promise.all(tagNames.map(async (tagName) => {
|
||||
const tagRef = tagRefs[tagName];
|
||||
const sha = refSHAs[tagRef];
|
||||
const annotation = tagAnnotations[tagName] || inputs.annotation;
|
||||
// Check if tag already exists
|
||||
let existing;
|
||||
try {
|
||||
@@ -45445,7 +45449,7 @@ async function planTagOperations(inputs, octokit) {
|
||||
return {
|
||||
...baseOp,
|
||||
operation: 'create',
|
||||
annotation: inputs.annotation
|
||||
annotation
|
||||
};
|
||||
}
|
||||
// Tag exists - determine operation based on mode and state
|
||||
@@ -45458,7 +45462,7 @@ async function planTagOperations(inputs, octokit) {
|
||||
};
|
||||
}
|
||||
// whenExists === 'update' - check if update is needed
|
||||
const { commitMatches, annotationMatches } = compareTagState(sha, inputs.annotation, existing);
|
||||
const { commitMatches, annotationMatches } = compareTagState(sha, annotation, existing);
|
||||
if (commitMatches && annotationMatches) {
|
||||
return {
|
||||
...baseOp,
|
||||
@@ -45468,11 +45472,11 @@ async function planTagOperations(inputs, octokit) {
|
||||
};
|
||||
}
|
||||
// Plan update with reasons
|
||||
const reasons = getUpdateReasons(sha, inputs.annotation, existing);
|
||||
const reasons = getUpdateReasons(sha, annotation, existing);
|
||||
return {
|
||||
...baseOp,
|
||||
operation: 'update',
|
||||
annotation: inputs.annotation,
|
||||
annotation,
|
||||
existingSHA: existing.commitSHA,
|
||||
existingIsAnnotated: existing.isAnnotated,
|
||||
reasons
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user