Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/actionpins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Resolution supports two modes:
|----------|-----------|-------------|
| `GetActionPins` | `func() []ActionPin` | Returns all loaded pins |
| `GetActionPinsByRepo` | `func(repo string) []ActionPin` | Returns all pins for a repository (version-descending) |
| `GetActionPinByRepo` | `func(repo string) (ActionPin, bool)` | Returns the latest pin for a repository |
| `GetLatestActionPinByRepo` | `func(repo string) (ActionPin, bool)` | Returns the latest pin for a repository |
| `FormatReference` | `func(repo, sha, version string) string` | Formats a pinned reference (`repo@sha # version`) |
| `FormatCacheKey` | `func(repo, version string) string` | Formats a cache key (`repo@version`) |
| `ExtractRepo` | `func(uses string) string` | Extracts the repository from a `uses` reference |
Expand Down
14 changes: 7 additions & 7 deletions pkg/actionpins/actionpins.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ func GetActionPinsByRepo(repo string) []ActionPin {
return cachedActionPinsByRepo[repo]
}

// GetActionPinByRepo returns the latest ActionPin for a given repository, if any.
func GetActionPinByRepo(repo string) (ActionPin, bool) {
// GetLatestActionPinByRepo returns the latest ActionPin for a given repository, if any.
func GetLatestActionPinByRepo(repo string) (ActionPin, bool) {
pins := GetActionPinsByRepo(repo)
if len(pins) == 0 {
return ActionPin{}, false
}
return pins[0], true
}

// getActionPin returns the pinned reference for the latest version of the repo.
// getLatestActionPinReference returns the pinned reference for the latest version of the repo.
// Returns an empty string if no pin is found.
func getActionPin(repo string) string {
func getLatestActionPinReference(repo string) string {
pins := GetActionPinsByRepo(repo)
if len(pins) == 0 {
return ""
Expand Down Expand Up @@ -320,18 +320,18 @@ func ResolveActionPin(actionRepo, version string, ctx *PinContext) (string, erro
// If ctx is nil, only embedded pins are consulted.
func GetCachedActionPin(repo string, ctx *PinContext) string {
if ctx == nil {
return getActionPin(repo)
return getLatestActionPinReference(repo)
}

pins := GetActionPinsByRepo(repo)
if len(pins) == 0 {
return getActionPin(repo)
return getLatestActionPinReference(repo)
}

latestVersion := pins[0].Version
pinnedRef, err := ResolveActionPin(repo, latestVersion, ctx)
if err != nil || pinnedRef == "" {
return getActionPin(repo)
return getLatestActionPinReference(repo)
}
return pinnedRef
}
2 changes: 1 addition & 1 deletion pkg/workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ The package is intentionally large (~320 source files) because it encodes all Gi
| Function | Signature | Description |
|----------|-----------|-------------|
| `GetActionPin` | `func(actionRepo string) string` | Returns the pinned SHA for an action |
| `GetActionPinByRepo` | `func(string) (ActionPin, bool)` | Looks up a pin by repo |
| `GetLatestActionPinByRepo` | `func(string) (ActionPin, bool)` | Looks up the latest pin by repo |
| `DetectActionMode` | `func(version string) ActionMode` | Detects the action reference mode |
| `ParseTagRefTSV` | `func(line string) (sha, objType string, err error)` | Parses tab-separated tag ref output into SHA and object type |
| `ExtractActionsFromLockFile` | `func(lockFilePath string) ([]ActionUsage, error)` | Extracts action usages from a lock file |
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflow/action_pins.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func getCachedActionPinFromResolver(repo string, resolver ActionSHAResolver) str

// getActionPinByRepo returns the latest ActionPin for a given repository, if any.
func getActionPinByRepo(repo string) (ActionPin, bool) {
return actionpins.GetActionPinByRepo(repo)
return actionpins.GetLatestActionPinByRepo(repo)
}

// getActionPinWithData returns the pinned action reference for a given action@version,
Expand Down
Loading