diff --git a/internal/pipeline/build.go b/internal/pipeline/build.go index 257438b..d1b9dbc 100644 --- a/internal/pipeline/build.go +++ b/internal/pipeline/build.go @@ -53,7 +53,7 @@ type assetResource struct { Rel string Resource erf.Resource Size int64 - ChangedAt time.Time + CreatedAt time.Time ContentID string } @@ -623,7 +623,7 @@ func fieldStringValueForScripts(value gff.Value) (string, bool) { func collectAssetResources(p *project.Project, requireContent bool, allowed map[string]struct{}) ([]assetResource, error) { var hakResources []assetResource - assetChangedAt, err := collectGitAssetChangeTimes(p) + assetCreatedAt, err := collectGitAssetCreationTimes(p) if err != nil { return nil, err } @@ -653,15 +653,15 @@ func collectAssetResources(p *project.Project, requireContent bool, allowed map[ return nil, fmt.Errorf("stat %s: %w", abs, err) } repoRel := filepath.ToSlash(filepath.Join(assetsRelPath, filepath.FromSlash(rel))) - changedAt := assetChangedAt[repoRel] - if changedAt.IsZero() { - changedAt = info.ModTime() + createdAt := assetCreatedAt[repoRel] + if createdAt.IsZero() { + createdAt = info.ModTime() } hakResources = append(hakResources, assetResource{ Rel: rel, Resource: resourceInfo.Resource, Size: erf.ArchiveSize([]erf.Resource{resourceInfo.Resource}), - ChangedAt: changedAt, + CreatedAt: createdAt, ContentID: resourceInfo.ContentID, }) } @@ -845,7 +845,7 @@ func fileSHA256(path string) (string, error) { return fmt.Sprintf("%x", sum[:]), nil } -func collectGitAssetChangeTimes(p *project.Project) (map[string]time.Time, error) { +func collectGitAssetCreationTimes(p *project.Project) (map[string]time.Time, error) { result := make(map[string]time.Time, len(p.Inventory.AssetFiles)) if len(p.Inventory.AssetFiles) == 0 { return result, nil @@ -857,7 +857,7 @@ func collectGitAssetChangeTimes(p *project.Project) (map[string]time.Time, error } assetsRelPath = filepath.ToSlash(assetsRelPath) - output, err := gitOutput(p.Root, "log", "--format=commit:%ct", "--name-only", "--", assetsRelPath) + output, err := gitOutput(p.Root, "log", "--diff-filter=A", "--format=%ct", "--name-only", "--", assetsRelPath) if err != nil { return result, nil } @@ -873,12 +873,7 @@ func collectGitAssetChangeTimes(p *project.Project) (map[string]time.Time, error if line == "" { continue } - if strings.HasPrefix(line, "commit:") { - sec, err := strconv.ParseInt(strings.TrimPrefix(line, "commit:"), 10, 64) - if err != nil { - currentCommitTime = time.Time{} - continue - } + if sec, err := strconv.ParseInt(line, 10, 64); err == nil { currentCommitTime = time.Unix(sec, 0).UTC() continue } @@ -1155,7 +1150,7 @@ func splitHAKGroup(cfg project.HAKConfig, assets []assetResource) ([]hakChunk, e } func compareAssetBuildOrder(a, b assetResource) int { - if cmp := a.ChangedAt.Compare(b.ChangedAt); cmp != 0 { + if cmp := a.CreatedAt.Compare(b.CreatedAt); cmp != 0 { return cmp } if cmp := compareResourceKeys(a.Resource, b.Resource); cmp != 0 {