mirror of
https://github.com/docker/metadata-action.git
synced 2026-01-22 06:28:56 +08:00
Tests
This commit is contained in:
parent
19618bde61
commit
b171e9c8ea
5 changed files with 252 additions and 46 deletions
21
src/meta.ts
21
src/meta.ts
|
|
@ -58,7 +58,13 @@ export class Meta {
|
|||
break;
|
||||
}
|
||||
case tcl.Type.Ref: {
|
||||
version = this.procRef(version, tag);
|
||||
if (tag.attrs['event'] == tcl.RefEvent.Branch) {
|
||||
version = this.procRefBranch(version, tag);
|
||||
} else if (tag.attrs['event'] == tcl.RefEvent.Tag) {
|
||||
version = this.procRefTag(version, tag);
|
||||
} else if (tag.attrs['event'] == tcl.RefEvent.PR) {
|
||||
version = this.procRefPr(version, tag);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case tcl.Type.Edge: {
|
||||
|
|
@ -176,17 +182,6 @@ export class Meta {
|
|||
return version;
|
||||
}
|
||||
|
||||
private procRef(version: Version, tag: tcl.Tag): Version {
|
||||
if (tag.attrs['event'] == tcl.RefEvent.Branch) {
|
||||
return this.procRefBranch(version, tag);
|
||||
} else if (tag.attrs['event'] == tcl.RefEvent.Tag) {
|
||||
return this.procRefTag(version, tag);
|
||||
} else if (tag.attrs['event'] == tcl.RefEvent.PR) {
|
||||
return this.procRefPr(version, tag);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
private procRefBranch(version: Version, tag: tcl.Tag): Version {
|
||||
if (!/^refs\/heads\//.test(this.context.ref)) {
|
||||
return version;
|
||||
|
|
@ -308,7 +303,7 @@ export class Meta {
|
|||
if (tag.attrs['suffix'].length > 0) {
|
||||
val = `${val}${tag.attrs['suffix']}`;
|
||||
} else if (this.flavor.suffix.length > 0) {
|
||||
val = `${this.flavor.suffix}${val}`;
|
||||
val = `${val}${this.flavor.suffix}`;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export function Parse(s: string): Tag {
|
|||
const parts = field.toString().split('=', 2);
|
||||
if (parts.length == 1) {
|
||||
tag.attrs['value'] = parts[0].trim();
|
||||
} else if (parts.length == 2) {
|
||||
} else {
|
||||
const key = parts[0].trim().toLowerCase();
|
||||
const value = parts[1].trim();
|
||||
switch (key) {
|
||||
|
|
@ -86,8 +86,6 @@ export function Parse(s: string): Tag {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Invalid entry: ${field}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue