diff options
| author | Xe Iaso <me@xeiaso.net> | 2024-02-18 13:34:51 -0500 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2024-02-18 13:34:51 -0500 |
| commit | 8d63fd1b351cf9ffd99555b21017cc503dd1d0fe (patch) | |
| tree | e642b17c4a445006dc0e92025725ebf430f932b0 /internal | |
| parent | 5a4d6d92e9d3c1483104f2adcc9085b64bd1871f (diff) | |
| download | xesite-8d63fd1b351cf9ffd99555b21017cc503dd1d0fe.tar.xz xesite-8d63fd1b351cf9ffd99555b21017cc503dd1d0fe.zip | |
add an external API
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/lume/lume.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/lume/lume.go b/internal/lume/lume.go index d4139c0..dd12cf1 100644 --- a/internal/lume/lume.go +++ b/internal/lume/lume.go @@ -69,6 +69,8 @@ type FS struct { fs fs.FS lock sync.Mutex + + lastBuildTime time.Time } func (f *FS) Close() error { @@ -86,6 +88,27 @@ func (f *FS) Close() error { return nil } +func (f *FS) Commit() (string, error) { + f.lock.Lock() + defer f.lock.Unlock() + + commit, err := f.repo.Head() + if err != nil { + return "", fmt.Errorf("lume: can't get head: %w", err) + } + + result := commit.Hash().String() + + return result, nil +} + +func (f *FS) BuildTime() time.Time { + f.lock.Lock() + defer f.lock.Unlock() + + return f.lastBuildTime +} + func (f *FS) Open(name string) (fs.File, error) { fin, err := f.fs.Open(name) if err != nil { @@ -205,6 +228,7 @@ func New(ctx context.Context, o *Options) (*FS, error) { } }() } + fs.lastBuildTime = time.Now() return fs, nil } |
