1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-06-23 00:40:06 +02:00

refactor: gio.Chtimes (#4191)

we're repeating this quite a bit

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2023-07-15 16:33:40 -03:00
committed by GitHub
parent 3c7fca7504
commit b9a08c4dc9
4 changed files with 84 additions and 27 deletions

View File

@ -7,12 +7,11 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"time"
"github.com/caarlos0/go-shellwords"
"github.com/caarlos0/log"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/gio"
"github.com/goreleaser/goreleaser/internal/ids"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/semerrgroup"
@ -226,15 +225,8 @@ func makeUniversalBinary(ctx *context.Context, opts *build.Options, unibin confi
return fmt.Errorf("failed to close file: %w", err)
}
if unibin.ModTimestamp != "" {
modUnix, err := strconv.ParseInt(unibin.ModTimestamp, 10, 64)
if err != nil {
return err
}
modTime := time.Unix(modUnix, 0)
if err := os.Chtimes(path, modTime, modTime); err != nil {
return fmt.Errorf("failed to change times for %s: %w", path, err)
}
if err := gio.Chtimes(path, unibin.ModTimestamp); err != nil {
return err
}
extra := map[string]interface{}{}