Conversation
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
Signed-off-by: Giles Cope <gilescope@gmail.com>
🎉 Are we earthbuild yet?Great progress! You've reduced "earthly" occurrences by 50 (0.89%) 📈 Overall Progress
📁 Changes by file type:
Keep up the great work migrating from Earthly to Earthbuild! 🚀 💡 Tips for finding more occurrencesRun locally to see detailed breakdown: ./.github/scripts/count-earthly.shNote that the goal is not to reach 0. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the flexibility and caching mechanisms within the system. It introduces a new set of environment variables with an Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for EARTH_* environment variables as aliases for the existing EARTHLY_* variables, ensuring backward compatibility. This is achieved consistently across the codebase by prioritizing the new EARTH_* variables. Additionally, a new git-related built-in argument, EARTH_GIT_CONTENT_HASH, is introduced. This represents the git tree hash, which is more stable for caching purposes than the commit hash. The implementation includes helpful refactorings, such as in buildcontext/git.go and util/gitutil/detectgit.go, to reduce code duplication, and is well-tested. The documentation has also been updated accordingly. My main feedback is a suggestion to reduce code duplication in variables/builtin.go where both new and old variables are being set.
| ret.Add(arg.EarthlyGitHash, gitMeta.Hash) | ||
| ret.Add(arg.EarthGitHash, gitMeta.Hash) | ||
| ret.Add(arg.EarthlyGitShortHash, gitMeta.ShortHash) | ||
| ret.Add(arg.EarthGitShortHash, gitMeta.ShortHash) | ||
| ret.Add(arg.EarthGitContentHash, gitMeta.ContentHash) | ||
|
|
||
| branch := firstOrZero(gitMeta.Branch) | ||
|
|
||
| ret.Add(arg.EarthlyGitBranch, branch) | ||
| ret.Add(arg.EarthGitBranch, branch) | ||
|
|
||
| tag := firstOrZero(gitMeta.Tags) | ||
|
|
||
| ret.Add(arg.EarthlyGitTag, tag) | ||
| ret.Add(arg.EarthGitTag, tag) | ||
| ret.Add(arg.EarthlyGitOriginURL, gitMeta.RemoteURL) | ||
| ret.Add(arg.EarthGitOriginURL, gitMeta.RemoteURL) | ||
| ret.Add(arg.EarthlyGitOriginURLScrubbed, stringutil.ScrubCredentials(gitMeta.RemoteURL)) | ||
| ret.Add(arg.EarthGitOriginURLScrubbed, stringutil.ScrubCredentials(gitMeta.RemoteURL)) | ||
| ret.Add(arg.EarthlyGitProjectName, getProjectName(gitMeta.RemoteURL)) | ||
| ret.Add(arg.EarthGitProjectName, getProjectName(gitMeta.RemoteURL)) | ||
| ret.Add(arg.EarthlyGitCommitTimestamp, gitMeta.CommitterTimestamp) | ||
| ret.Add(arg.EarthGitCommitTimestamp, gitMeta.CommitterTimestamp) |
There was a problem hiding this comment.
This function now contains a significant amount of duplicated code to add both the new EARTH_* and old EARTHLY_* variables. To improve maintainability and readability, consider introducing a helper function to handle adding both variables at once.
For example:
func addWithAlias(s *Scope, new, old, val string) {
s.Add(new, val)
s.Add(old, val)
}You could then replace pairs of ret.Add(...) calls with a single call to this helper, like:
addWithAlias(ret, arg.EarthGitHash, arg.EarthlyGitHash, gitMeta.Hash)
addWithAlias(ret, arg.EarthGitShortHash, arg.EarthlyGitShortHash, gitMeta.ShortHash)This would make the code much cleaner and easier to manage, especially if more aliased variables are added in the future.
Signed-off-by: Giles Cope <gilescope@gmail.com>
There was a problem hiding this comment.
Should we update docs in the same pass? Hopefully can be mostly LLM'd
Docs updated in base branch: https://github.com/EarthBuild/earthbuild/pull/341/changes#diff-a08415d10d04e498b9f32bd0057aa2a077391fb3f09f0c569c3d7577c1704364
Should be coherent once this is rebased after that merges
|
|
||
| // LookupEnv checks for newKey first, then falls back to oldKey. | ||
| // Returns the value and whether either key was found. | ||
| func LookupEnv(newKey, oldKey string) (string, bool) { |
There was a problem hiding this comment.
I think we should update this to just take newKey and infer oldKey or visa-versa.
Also this seems the right place to hook in for warn logging if the old naming is used
| // shortHash is the short git hash. | ||
| shortHash string | ||
| // contentHash is the git tree hash (content-addressable). | ||
| contentHash string |
There was a problem hiding this comment.
I think this PR should set base to the giles-content branch so we see the right change set here
Allow to understand
EARTH_*env vars as well asEARTHLY_*(Merge #341 first.)