Repository navigation
feat: add !git.* repository YAML functions and atmos.Resolve template func - #2558
Conversation
Add five new Git YAML functions that expose repository metadata derived from the `origin` remote (parsed generically for GitHub/GitLab/Bitbucket/ADO): `!git.repository` (the `<owner>/<repo>` slug), `!git.owner`, `!git.name`, `!git.host`, and `!git.url`. All support a fallback value and work in both stack/component processing and `atmos.yaml` config preprocessing. Add the `atmos.Resolve` template function, which evaluates any Atmos YAML function string at template-render time so its result can be composed with other strings and template variables in a single value (e.g. prefixing a `workspace_key_prefix` with the repository slug) — something a bare YAML tag cannot do, since a tag owns the entire scalar and templates run before YAML functions. Includes unit tests, per-function docs, two changelog posts, a roadmap update, and a PRD for the follow-up lazy-Stringer auto-deref enhancement. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
The PRD references the `/functions/template/atmos.Resolve` Docusaurus route as a site-absolute link. lychee resolves root-relative paths against the repo root, so it 404s on a non-existent file. Mirror the existing `file://.*/cli/` exclusion for website routes by adding `file://.*/functions/`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds five Git YAML functions (!git.repository/owner/name/host/url), integrates them into YAML preprocessing and template-time resolution via atmos.Resolve, extends tests across units/integration, and updates documentation, blog posts, a PRD, and site config. ChangesGit repository metadata functions and template evaluation
Sequence Diagram (high-level template resolution flow) sequenceDiagram
participant Template
participant AtmosFuncs
participant ProcessCustomTags
participant ProcessSimpleTags
participant GitProcessor
Template->>AtmosFuncs: atmos.Resolve(input)
AtmosFuncs->>ProcessCustomTags: resolve string
ProcessCustomTags->>ProcessSimpleTags: detect !git.* prefix
ProcessSimpleTags->>GitProcessor: call ProcessTag*
GitProcessor-->>ProcessSimpleTags: resolved value
ProcessSimpleTags-->>ProcessCustomTags: handled result
ProcessCustomTags-->>AtmosFuncs: resolved value or original
AtmosFuncs-->>Template: return for composition
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@website/docs/functions/yaml/git.repository.mdx`:
- Around line 47-48: The markdown link to atmos.Resolve is using an incorrect
path (`/functions/template/atmos.Resolve`) and failing CI; update the link
target in the line describing `workspace_key_prefix` to use the site's canonical
route/path format for that template function (replace the dotted path with the
canonical path style used elsewhere for template functions, keeping the link
text `atmos.Resolve` intact) so the link-checker resolves the
`/functions/template/...` route correctly.
In `@website/src/data/roadmap.js`:
- Around line 228-229: Two shipped roadmap entries (the objects with label
values "Git repository metadata YAML functions (`!git.repository`, `!git.owner`,
`!git.name`, `!git.host`, `!git.url`)" and "`atmos.Resolve` template function
for composing YAML functions") are missing the required pr field; add a numeric
pr: <number> property to each of those objects (e.g., pr: 1234) matching their
PR numbers, preserving the existing object formatting and trailing commas and
ensuring the pr key is included alongside
status/quarter/changelog/docs/description/benefits.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 44add66e-1a1a-482f-8911-681772d534ff
📒 Files selected for processing (21)
docs/prd/lazy-yaml-function-template-values.mdinternal/exec/template_funcs.gointernal/exec/template_funcs_test.gointernal/exec/yaml_func_utils.gointernal/exec/yaml_func_utils_context_test.gopkg/config/process_yaml.gopkg/config/process_yaml_test.gopkg/git/yaml_tags.gopkg/git/yaml_tags_test.gopkg/utils/yaml_utils.gopkg/utils/yaml_utils_test.gowebsite/blog/2026-06-02-atmos-resolve-template-function.mdxwebsite/blog/2026-06-02-git-repository-yaml-functions.mdxwebsite/docs/functions/template/atmos.Resolve.mdxwebsite/docs/functions/yaml/git.host.mdxwebsite/docs/functions/yaml/git.name.mdxwebsite/docs/functions/yaml/git.owner.mdxwebsite/docs/functions/yaml/git.repository.mdxwebsite/docs/functions/yaml/git.url.mdxwebsite/docs/functions/yaml/index.mdxwebsite/src/data/roadmap.js
Add the `pr` field to the `git-repository-yaml-functions` and `atmos-resolve-template-function` milestones now that the PR number is known. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Resolve repository metadata (`!git.repository`, `!git.owner`, `!git.name`, `!git.host`, `!git.url`) and `!git.root` from inside a real linked worktree, where `.git` is a file and the `origin` remote lives only in the shared common config. Guards GetLocalRepo's EnableDotGitCommonDir option — without it the remote is invisible from the worktree and resolution fails. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/git/yaml_tags_test.go (1)
38-99: 💤 Low valueHeads up: the local
testsslice shadows the importedtestspackage.The slice declared on Line 39 is named
tests, which shadowsgithub.com/cloudposse/atmos/tests(imported on Line 14 and used at Line 135). It works fine today since this function never touches the package, but it's an easy trap if someone later reaches fortests.RequireGitCommitConfighere. A quick rename keeps things clear.♻️ Suggested rename
- tests := []struct { + testCases := []struct { name string remoteURL string fn func(string) (string, error) input string expected string }{ @@ - for _, tt := range tests { + for _, tt := range testCases {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/git/yaml_tags_test.go` around lines 38 - 99, The local slice named "tests" in TestProcessRepositoryMetadataTags shadows the imported tests package; rename the local variable (e.g., to "cases" or "tcases") to avoid shadowing and potential future confusion—update the declaration in TestProcessRepositoryMetadataTags and all references to that slice (the loop "for _, tt := range ...") so the imported tests package (used elsewhere as tests.RequireGitCommitConfig) remains accessible.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/git/yaml_tags_test.go`:
- Around line 38-99: The local slice named "tests" in
TestProcessRepositoryMetadataTags shadows the imported tests package; rename the
local variable (e.g., to "cases" or "tcases") to avoid shadowing and potential
future confusion—update the declaration in TestProcessRepositoryMetadataTags and
all references to that slice (the loop "for _, tt := range ...") so the imported
tests package (used elsewhere as tests.RequireGitCommitConfig) remains
accessible.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 83b29eb7-500b-4352-a960-c7d5bbf11a15
📒 Files selected for processing (1)
pkg/git/yaml_tags_test.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2558 +/- ##
==========================================
+ Coverage 78.82% 78.86% +0.03%
==========================================
Files 1195 1195
Lines 114312 114427 +115
==========================================
+ Hits 90104 90240 +136
+ Misses 19253 19233 -20
+ Partials 4955 4954 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
The metadata resolution is platform-independent, but linked-worktree teardown is flaky on Windows: `git worktree remove` can fail and go-git retains a handle on the worktree's `commondir`, so t.TempDir's strict RemoveAll fails the test even though the assertions pass. Skip on Windows; Linux/macOS CI guards the behavior. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add tests covering the previously-uncovered branches introduced with the !git.repository, !git.owner, !git.name, !git.host, and !git.url YAML functions: - pkg/git: error path of processRepoInfoTag (outside a repo, no default). - pkg/config: value-returning dispatch (processScalarNodeValue) for all five tags, plus the error and empty-value branches of handleGitRepoInfo. - internal/exec: error path of the repository-metadata tags in processSimpleTags (outside any Git repository). This lifts patch coverage on the changed files from ~72% to ~100%. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pkg/config/process_yaml_test.go (2)
755-767: ⚡ Quick winNice helper — now let's retire the copy of it sitting in
TestPreprocessAtmosYamlFuncGitRepositoryTags.Lines 723-731 do the exact same repo +
originremote +t.Chdirdance thatinitConfigTestGitRepoWithRemotenow encapsulates. Reusing the helper there keeps the two paths from drifting apart.♻️ Reuse the helper in the existing test
func TestPreprocessAtmosYamlFuncGitRepositoryTags(t *testing.T) { - repoDir, _ := initConfigTestGitRepo(t, "") - repo, err := git.PlainOpen(repoDir) - require.NoError(t, err) - _, err = repo.CreateRemote(&config.RemoteConfig{ - Name: "origin", - URLs: []string{"https://github.com/cloudposse/atmos.git"}, - }) - require.NoError(t, err) - t.Chdir(repoDir) + initConfigTestGitRepoWithRemote(t) v := viper.New() yamlStr := `🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/config/process_yaml_test.go` around lines 755 - 767, The test duplicates the repo + origin remote + t.Chdir setup that initConfigTestGitRepoWithRemote(t *testing.T) encapsulates; replace the duplicated block in TestPreprocessAtmosYamlFuncGitRepositoryTags with a call to initConfigTestGitRepoWithRemote(t) (remove the manual git.PlainOpen/CreateRemote/t.Chdir steps) so the test reuses the helper and avoids drift with the initConfigTestGitRepoWithRemote function.
841-855: ⚡ Quick winThe assertion doesn't quite prove what the comment promises.
The doc says the handler "stores the empty value in Viper," but
assert.Empty(t, v.GetString("test.path"))passes whether the key was set to""or never set at all. A quickv.IsSetcheck makes the test actually verify the store happened.💚 Strengthen the empty-value assertion
require.NoError(t, err) + assert.True(t, v.IsSet("test.path"), "empty value should still be stored in Viper") assert.Empty(t, v.GetString("test.path")) assert.Equal(t, "", node.Tag) // Tag cleared to avoid re-processing.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/config/process_yaml_test.go` around lines 841 - 855, The test TestHandleGitRepoInfoEmptyValue currently only checks v.GetString("test.path") which doesn't prove the key was stored; update the test to assert that the key exists in Viper (use v.IsSet("test.path") or require.True) in addition to asserting the value is empty, so that handleGitRepoInfo is verified to have stored the empty string; reference the test function TestHandleGitRepoInfoEmptyValue and the handler handleGitRepoInfo and the viper instance v when making this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/config/process_yaml_test.go`:
- Around line 755-767: The test duplicates the repo + origin remote + t.Chdir
setup that initConfigTestGitRepoWithRemote(t *testing.T) encapsulates; replace
the duplicated block in TestPreprocessAtmosYamlFuncGitRepositoryTags with a call
to initConfigTestGitRepoWithRemote(t) (remove the manual
git.PlainOpen/CreateRemote/t.Chdir steps) so the test reuses the helper and
avoids drift with the initConfigTestGitRepoWithRemote function.
- Around line 841-855: The test TestHandleGitRepoInfoEmptyValue currently only
checks v.GetString("test.path") which doesn't prove the key was stored; update
the test to assert that the key exists in Viper (use v.IsSet("test.path") or
require.True) in addition to asserting the value is empty, so that
handleGitRepoInfo is verified to have stored the empty string; reference the
test function TestHandleGitRepoInfoEmptyValue and the handler handleGitRepoInfo
and the viper instance v when making this change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8aa418c0-bc38-47a2-a382-8e53eaab665c
📒 Files selected for processing (4)
internal/exec/yaml_func_utils_context_test.gopkg/config/process_yaml_test.gopkg/git/yaml_tags_test.gowebsite/src/data/roadmap.js
🚧 Files skipped from review as they are similar to previous changes (3)
- internal/exec/yaml_func_utils_context_test.go
- website/src/data/roadmap.js
- pkg/git/yaml_tags_test.go
The "Check Markdown Links" job failed (exit code 2) on a single transient timeout: https://man.openbsd.org/sysexits in docs/prd/exit-codes.md. OpenBSD's man pages respond slowly and intermittently exceed lychee's 60s timeout even after retries. Add the domain to the exclude list, matching the existing pattern for other slow external sites (refspecs.linuxfoundation.org, gnu.org, taskfile.dev, etc.). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.221.0-rc.5. |
what
!git.*YAML functions that expose Git repository metadata from theoriginremote:!git.repository(the<owner>/<repo>slug, e.g.cloudposse/atmos),!git.owner,!git.name,!git.host, and!git.url.atmos.Resolvetemplate function, which evaluates any Atmos YAML-function string (!git.*,!exec,!store,!terraform.output, …) at template-render time so its result can be composed with other strings and template variables in a single value.atmos.yamlconfig preprocessing.why
!exec echo ${GITHUB_REPOSITORY:-$(git remote get-url origin | sed …)}.workspace_key_prefixwith the repo slug) was impossible without!exec;atmos.Resolvemakes that composition native:references
/functions/yaml/git.repository,/functions/template/atmos.Resolve.docs/prd/lazy-yaml-function-template-values.md(lazy-Stringer auto-deref so{{ .settings.context.repo }}evaluates withoutatmos.Resolve).Summary by CodeRabbit
New Features
Documentation
Tests
Chores