From 874ba7e406a24446be11f528692d1eab56d13767 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 4 Feb 2024 09:15:54 -0800 Subject: display flake information in a more readable format --- pkg/flake/lock/main.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pkg') diff --git a/pkg/flake/lock/main.go b/pkg/flake/lock/main.go index 0fa21f4..7edf61f 100644 --- a/pkg/flake/lock/main.go +++ b/pkg/flake/lock/main.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "os" + "time" ) type FlakeLock struct { @@ -91,3 +92,18 @@ func New(flakeLockPath string) (*FlakeLock, error) { return &flakeLock, nil } + +func (l repoLocked) LastModifiedRFC3339() string { + date := time.Unix(l.LastModified, 0) + unitTimeInRFC3339 := date.Format(time.RFC3339) + return unitTimeInRFC3339 +} + +func (l repoLocked) Repository() string { + switch l.Type { + case "github": + return fmt.Sprintf("https://github.com/%s/%s", l.Owner, l.Repo) + default: + return fmt.Sprintf("%s/%s", l.Repo, l.Owner) + } +} -- cgit 1.4.1