Skip to content

Commit

Permalink
feat: factor git tag into freight ids (#1850)
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
  • Loading branch information
krancour authored Apr 16, 2024
1 parent 06bf714 commit 5287d0e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions api/v1alpha1/freight_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,24 @@ func (f *Freight) GenerateID() string {
size := len(f.Commits) + len(f.Images) + len(f.Charts)
artifacts := make([]string, 0, size)
for _, commit := range f.Commits {
artifacts = append(
artifacts,
fmt.Sprintf("%s:%s", commit.RepoURL, commit.ID),
)
if commit.Tag != "" {
// If we have a tag, incorporate it into the canonical representation of a
// commit used when calculating Freight ID. This is necessary because one
// commit could have multiple tags. Suppose we have already detected a
// commit with a tag v1.0.0-rc.1 and produced the corresponding Freight.
// Later, that same commit is tagged as v1.0.0. If we don't incorporate
// the tag into the ID, we will never produce a new/distinct piece of
// Freight for the new tag.
artifacts = append(
artifacts,
fmt.Sprintf("%s:%s:%s", commit.RepoURL, commit.Tag, commit.ID),
)
} else {
artifacts = append(
artifacts,
fmt.Sprintf("%s:%s", commit.RepoURL, commit.ID),
)
}
}
for _, image := range f.Images {
artifacts = append(
Expand Down

0 comments on commit 5287d0e

Please sign in to comment.