Skip to content

Integrate sprig library - #184

Merged
BagToad merged 2 commits into
cli:trunkfrom
iamazeem:integrate-sprig-library
Mar 7, 2025
Merged

BagToad merged 2 commits into
cli:trunkfrom
iamazeem:integrate-sprig-library

Conversation

@iamazeem

Copy link
Copy Markdown
Contributor

Fixes cli/cli#6370.

Import following sprig string functions:

  • contains
  • hasPrefix
  • hasSuffix
  • regexMatch

Online playground for sprig: https://repeatit.io/

@BagToad BagToad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your patience while I got to reviewing this @iamazeem 🙇

This works well! 👍

 bin/gh pr list --repo cli/cli --json createdAt,title --template '
{{- range . -}}
    {{- if or (hasPrefix "feat" .title) (hasPrefix "bug" .title) -}}
        {{- printf "%s | %s\n" .createdAt .title -}}
    {{- end -}}
{{- end -}}
'
2024-08-04T20:45:55Z | feat(ghinstance): allow port in host
2024-03-17T03:43:29Z | feat: implement gh `pr revert`
2024-02-19T19:50:25Z | feat: add `gh deployment` commands
2023-04-17T04:55:21Z | feat(pr): Add cleanup subcommand to delete merged local branches

I left one very minor comment that we can resolve, then I think this is good to merge ✨

Comment thread pkg/template/template.go Resolved
@BagToad
BagToad merged commit 7a6e554 into cli:trunk Mar 7, 2025
@iamazeem
iamazeem deleted the integrate-sprig-library branch March 7, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add string matching helper functions to Go templates

2 participants