Documentation
¶
Index ¶
- Variables
- func AtomicWriteFile(outputPath string, writeFn func(*os.File) error) error
- func Coalesce(values ...string) string
- func CoalesceBlank(values ...string) string
- func ContainsAny(text string, substrings ...string) bool
- func ContainsAnyIgnoreCase(text string, substrings ...string) bool
- func ContainsIgnoreCase(text, substr string) bool
- func DaysBetween(a, b time.Time) int
- func DetectTrunkBranch(repoPath string) string
- func DirExists(path string) bool
- func EndOfDay(t time.Time) time.Time
- func EqualFold(a, b string) bool
- func FileExists(path string) bool
- func FirstNonEmpty(strings ...string) string
- func FormatDate(t time.Time) string
- func FormatDateTime(t time.Time) string
- func FormatDateTimeShort(t time.Time) string
- func FormatDuration(d time.Duration) string
- func FormatDurationLong(d time.Duration) string
- func FormatTimeAgo(t time.Time) string
- func GetSnippet(text, query string, maxLen int) string
- func HasPrefixFold(s, prefix string) bool
- func HasSuffixFold(s, suffix string) bool
- func IsBlank(s string) bool
- func IsJSONFile(filename string) bool
- func IsNotBlank(s string) bool
- func IsThisWeek(t time.Time) bool
- func IsToday(t time.Time) bool
- func IsTrunkBranch(branch string) bool
- func IsYAMLFile(filename string) bool
- func IsYesterday(t time.Time) bool
- func JoinNonEmpty(sep string, parts ...string) string
- func ParseDuration(s string) (time.Duration, error)
- func ParseMetadataFlags(pairs []string) map[string]interface{}
- func PathExists(path string) bool
- func ShouldSkipFogitFile(path string) bool
- func SplitKeyValue(s, sep string) (key, value string)
- func SplitKeyValueEquals(s string) (key, value string)
- func StartOfDay(t time.Time) time.Time
- func TruncateWithEllipsis(text string, maxLen int) string
- func ValidateOutputPath(outputPath string) error
Constants ¶
This section is empty.
Variables ¶
var TrunkBranchCandidates = []string{"main", "master", "trunk"}
TrunkBranchCandidates is the list of common trunk branch names in priority order.
Functions ¶
func AtomicWriteFile ¶
AtomicWriteFile writes data to a file atomically using a temp file + rename pattern. This ensures that on failure, no partial/corrupted file is left behind. The writeFn is called with the temp file to perform the actual write.
func CoalesceBlank ¶
CoalesceBlank returns the first non-blank string from the arguments
func ContainsAny ¶
ContainsAny returns true if text contains any of the substrings
func ContainsAnyIgnoreCase ¶
ContainsAnyIgnoreCase returns true if text contains any of the substrings (case-insensitive)
func ContainsIgnoreCase ¶
ContainsIgnoreCase checks if text contains substr (case-insensitive)
func DaysBetween ¶
DaysBetween returns the number of days between two times
func DetectTrunkBranch ¶ added in v1.4.1
DetectTrunkBranch detects the trunk/main branch using Git's native methods. Priority order: 1. Remote HEAD reference (refs/remotes/origin/HEAD) - most reliable for cloned repos 2. Current branch via symbolic-ref (works even before first commit) 3. Current branch via rev-parse (works after first commit) 4. Git's configured default branch (init.defaultBranch) 5. Check if main or master branch exists locally Falls back to "main" if nothing found.
func DirExists ¶
DirExists checks if a directory exists at the given path. Returns false if the path doesn't exist or is not a directory.
func FileExists ¶
FileExists checks if a file exists at the given path. Returns false if the path doesn't exist or is a directory.
func FirstNonEmpty ¶
FirstNonEmpty returns the first non-empty string, or empty if all are empty
func FormatDate ¶
FormatDate formats a time as a date string (YYYY-MM-DD)
func FormatDateTime ¶
FormatDateTime formats a time as a datetime string (YYYY-MM-DD HH:MM:SS)
func FormatDateTimeShort ¶
FormatDateTimeShort formats a time as a short datetime string (MM-DD HH:MM)
func FormatDuration ¶
FormatDuration formats a duration as a short human-readable string
func FormatDurationLong ¶
FormatDurationLong formats a duration as a long human-readable string (e.g., "2 days, 3 hours")
func FormatTimeAgo ¶
FormatTimeAgo formats a time as a human-readable "time ago" string
func GetSnippet ¶
GetSnippet extracts a snippet around the query match
func HasPrefixFold ¶
HasPrefix checks if s has the given prefix (case-insensitive)
func HasSuffixFold ¶
HasSuffix checks if s has the given suffix (case-insensitive)
func IsJSONFile ¶
IsJSONFile checks if a filename has a .json extension.
func IsNotBlank ¶
IsNotBlank returns true if string has non-whitespace content
func IsThisWeek ¶
IsThisWeek returns true if the given time is in the current week
func IsTrunkBranch ¶ added in v1.4.1
IsTrunkBranch checks if the given branch name is a trunk/main branch.
func IsYAMLFile ¶
IsYAMLFile checks if a filename has a .yml or .yaml extension.
func IsYesterday ¶
IsYesterday returns true if the given time is yesterday
func JoinNonEmpty ¶
JoinNonEmpty joins non-empty strings with the given separator
func ParseDuration ¶
ParseDuration parses a duration string with common shortcuts Supports: "1h", "30m", "2d" (days), "1w" (weeks)
func ParseMetadataFlags ¶
ParseMetadataFlags parses key=value pairs into a metadata map. Empty values are ignored.
func PathExists ¶
PathExists checks if a path (file or directory) exists.
func ShouldSkipFogitFile ¶
ShouldSkipFogitFile returns true if the given path is inside the .fogit directory and should be excluded from auto-linking or other file operations.
func SplitKeyValue ¶
SplitKeyValue splits a string on the first occurrence of separator
func SplitKeyValueEquals ¶
SplitKeyValueEquals is a convenience function that splits on "="
func StartOfDay ¶
StartOfDay returns the start of the day for the given time
func TruncateWithEllipsis ¶
TruncateWithEllipsis truncates text to maxLen and adds ellipsis
func ValidateOutputPath ¶
ValidateOutputPath validates that an output path is safe to write to. It prevents path traversal attacks by ensuring: 1. The path doesn't contain traversal sequences (..) 2. The resolved absolute path is within the current working directory
Returns an error if the path is unsafe, nil if safe.
Types ¶
This section is empty.