Build with CreatedAt time instead of ChangedAt
This commit is contained in:
+10
-15
@@ -53,7 +53,7 @@ type assetResource struct {
|
|||||||
Rel string
|
Rel string
|
||||||
Resource erf.Resource
|
Resource erf.Resource
|
||||||
Size int64
|
Size int64
|
||||||
ChangedAt time.Time
|
CreatedAt time.Time
|
||||||
ContentID string
|
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) {
|
func collectAssetResources(p *project.Project, requireContent bool, allowed map[string]struct{}) ([]assetResource, error) {
|
||||||
var hakResources []assetResource
|
var hakResources []assetResource
|
||||||
assetChangedAt, err := collectGitAssetChangeTimes(p)
|
assetCreatedAt, err := collectGitAssetCreationTimes(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
return nil, fmt.Errorf("stat %s: %w", abs, err)
|
||||||
}
|
}
|
||||||
repoRel := filepath.ToSlash(filepath.Join(assetsRelPath, filepath.FromSlash(rel)))
|
repoRel := filepath.ToSlash(filepath.Join(assetsRelPath, filepath.FromSlash(rel)))
|
||||||
changedAt := assetChangedAt[repoRel]
|
createdAt := assetCreatedAt[repoRel]
|
||||||
if changedAt.IsZero() {
|
if createdAt.IsZero() {
|
||||||
changedAt = info.ModTime()
|
createdAt = info.ModTime()
|
||||||
}
|
}
|
||||||
hakResources = append(hakResources, assetResource{
|
hakResources = append(hakResources, assetResource{
|
||||||
Rel: rel,
|
Rel: rel,
|
||||||
Resource: resourceInfo.Resource,
|
Resource: resourceInfo.Resource,
|
||||||
Size: erf.ArchiveSize([]erf.Resource{resourceInfo.Resource}),
|
Size: erf.ArchiveSize([]erf.Resource{resourceInfo.Resource}),
|
||||||
ChangedAt: changedAt,
|
CreatedAt: createdAt,
|
||||||
ContentID: resourceInfo.ContentID,
|
ContentID: resourceInfo.ContentID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -845,7 +845,7 @@ func fileSHA256(path string) (string, error) {
|
|||||||
return fmt.Sprintf("%x", sum[:]), nil
|
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))
|
result := make(map[string]time.Time, len(p.Inventory.AssetFiles))
|
||||||
if len(p.Inventory.AssetFiles) == 0 {
|
if len(p.Inventory.AssetFiles) == 0 {
|
||||||
return result, nil
|
return result, nil
|
||||||
@@ -857,7 +857,7 @@ func collectGitAssetChangeTimes(p *project.Project) (map[string]time.Time, error
|
|||||||
}
|
}
|
||||||
assetsRelPath = filepath.ToSlash(assetsRelPath)
|
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 {
|
if err != nil {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@@ -873,12 +873,7 @@ func collectGitAssetChangeTimes(p *project.Project) (map[string]time.Time, error
|
|||||||
if line == "" {
|
if line == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(line, "commit:") {
|
if sec, err := strconv.ParseInt(line, 10, 64); err == nil {
|
||||||
sec, err := strconv.ParseInt(strings.TrimPrefix(line, "commit:"), 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
currentCommitTime = time.Time{}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
currentCommitTime = time.Unix(sec, 0).UTC()
|
currentCommitTime = time.Unix(sec, 0).UTC()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -1155,7 +1150,7 @@ func splitHAKGroup(cfg project.HAKConfig, assets []assetResource) ([]hakChunk, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compareAssetBuildOrder(a, b assetResource) int {
|
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
|
return cmp
|
||||||
}
|
}
|
||||||
if cmp := compareResourceKeys(a.Resource, b.Resource); cmp != 0 {
|
if cmp := compareResourceKeys(a.Resource, b.Resource); cmp != 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user