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>
Allow to understand
EARTH_*env vars as well asEARTHLY_*(Merge #341 first.)