chore: implement image template processing using git repo state (not enabled)

This commit is contained in:
Pasha Sviderski
2025-11-01 15:50:36 +10:00
parent 91bf135a4f
commit 328ace1fd1
4 changed files with 666 additions and 6 deletions
+3 -3
View File
@@ -10,14 +10,14 @@ import (
// GitState contains information about the Git repository state.
type GitState struct {
// Date is the current commit datetime.
Date time.Time
// IsDirty indicates whether there are uncommitted changes.
IsDirty bool
// IsRepo indicates whether the directory is a Git repository.
IsRepo bool
// SHA is the full SHA-1 (40 characters) of the current commit.
SHA string
// Time is the current commit datetime.
Time time.Time
}
// InspectGitState inspects the Git repo state from the specified directory.
@@ -52,7 +52,7 @@ func InspectGitState(dir string) (GitState, error) {
if err != nil {
return state, fmt.Errorf("parse current commit timestamp: %w", err)
}
state.Time = time.Unix(seconds, 0)
state.Date = time.Unix(seconds, 0).UTC()
// Check for uncommitted changes.
status, err := gitCommand(dir, "status", "--porcelain")
+3 -3
View File
@@ -22,7 +22,7 @@ func TestInspectGitState_GitNotAvailable(t *testing.T) {
assert.False(t, state.IsRepo)
assert.Empty(t, state.SHA)
assert.Empty(t, state.ShortSHA(7))
assert.True(t, state.Time.IsZero())
assert.True(t, state.Date.IsZero())
assert.False(t, state.IsDirty)
}
@@ -42,7 +42,7 @@ func TestInspectGitState_NotARepo(t *testing.T) {
assert.False(t, state.IsRepo)
assert.Empty(t, state.SHA)
assert.Empty(t, state.ShortSHA(7))
assert.True(t, state.Time.IsZero()) // Should have zero time if not a repo.
assert.True(t, state.Date.IsZero()) // Should have zero time if not a repo.
assert.False(t, state.IsDirty)
}
@@ -59,7 +59,7 @@ func TestInspectGitState_CleanRepo(t *testing.T) {
assert.True(t, state.IsRepo)
assert.Len(t, state.SHA, 40)
assert.Equal(t, state.ShortSHA(7), state.SHA[:7])
assert.False(t, state.Time.IsZero())
assert.False(t, state.Date.IsZero())
assert.False(t, state.IsDirty)
}