parse

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package parse extracts and rewrites `uses:` references in workflow/action files while preserving the original formatting byte-for-byte.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyRewrites

func ApplyRewrites(content string, refs []UsesRef, rewrites []Rewrite) string

ApplyRewrites returns content with the given rewrites applied. Every untouched line is left exactly as-is; rewritten lines keep their prefix, quoting, and action path, changing only the ref and trailing comment.

Types

type Rewrite

type Rewrite struct {
	Line    int
	SHA     string
	Version *string
}

Rewrite pins one line's ref to SHA, labeling it with Version (nil omits the trailing comment).

type UsesRef

type UsesRef struct {
	Line    int    // zero-based line index
	Prefix  string // everything up to the value, e.g. "      - uses: "
	Quote   string // surrounding quote char, or "" if unquoted
	Action  string // owner/repo plus any subpath
	Ref     string // git ref after @ (tag, branch, or SHA)
	Comment string // trailing comment incl. leading "#", or ""
	Owner   string // first path segment
	Repo    string // second path segment
}

UsesRef is a parsed `uses:` reference found on a single line.

func Uses

func Uses(content string) []UsesRef

Uses returns every pinnable `uses:` reference in the file content.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL