Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ To contribute improvements to documentation related to currently released featur
### Config

Starting with [v0.6.30](CHANGELOG.md#v0630---2022-11-22), the default location of the built binary's config file has
changed to `~/.earthly-dev/config.yml`. The standard location is not used as a fallback; it is possible to `export EARTHLY_CONFIG=~/.earthly/config.yml`, or create a symlink if required.
changed to `~/.earthly-dev/config.yml`. The standard location is not used as a fallback; it is possible to `export EARTH_CONFIG=~/.earthly/config.yml`, or create a symlink if required.

## Prereleases

Expand Down
136 changes: 31 additions & 105 deletions buildcontext/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type resolvedGitProject struct {
hash string
// shortHash is the short git hash.
shortHash string
// contentHash is the git tree hash (content-addressable).
contentHash string
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this PR should set base to the giles-content branch so we see the right change set here

// branches is the git branches.
branches []string
// tags is the git tags.
Expand Down Expand Up @@ -227,6 +229,7 @@ func (gr *gitResolver) resolveEarthProject(
RemoteURL: gitURL,
Hash: rgp.hash,
ShortHash: rgp.shortHash,
ContentHash: rgp.contentHash,
BranchOverrideTagArg: gr.gitBranchOverride != "",
Branch: rgp.branches,
Tags: rgp.tags,
Expand Down Expand Up @@ -306,6 +309,7 @@ func (gr *gitResolver) resolveGitProject(
"git rev-parse HEAD >/dest/git-hash ; " +
"uname -m >/dest/uname-m ;" +
"git rev-parse --short=8 HEAD >/dest/git-short-hash ; " +
"git rev-parse HEAD^{tree} >/dest/git-content-hash ; " +
"git rev-parse --abbrev-ref HEAD >/dest/git-branch || touch /dest/git-branch ; " +
"ls .git/refs/heads/ | head -n 1 >/dest/git-default-branch || touch /dest/git-default-branch ; " +
"git describe --exact-match --tags >/dest/git-tags || touch /dest/git-tags ; " +
Expand Down Expand Up @@ -362,22 +366,23 @@ func (gr *gitResolver) resolveGitProject(
gitImage, string(unameM), platr.LLBNative().Architecture)
}

var gitHashBytes []byte

gitHashBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-hash",
})
if err != nil {
return nil, errors.Wrap(err, "read git-hash")
metaFiles := []string{
"git-hash", "git-short-hash", "git-content-hash",
"git-default-branch", "git-tags",
"git-committer-ts", "git-author-ts",
"git-author-email", "git-author-name",
"git-body", "git-refs", "Earthfile-paths",
}

var gitShortHashBytes []byte
meta := make(map[string][]byte, len(metaFiles))

gitShortHashBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-short-hash",
})
if err != nil {
return nil, errors.Wrap(err, "read git-short-hash")
for _, name := range metaFiles {
meta[name], err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: name,
})
if err != nil {
return nil, errors.Wrap(err, "read "+name)
}
}

var gitBranch string
Expand All @@ -387,97 +392,17 @@ func (gr *gitResolver) resolveGitProject(
return nil, errors.Wrap(err, "read git-branch")
}

var gitDefaultBranchBytes []byte

gitDefaultBranchBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-default-branch",
})
if err != nil {
return nil, errors.Wrap(err, "read git-default-branch")
}

var gitTagsBytes []byte

gitTagsBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-tags",
})
if err != nil {
return nil, errors.Wrap(err, "read git-tags")
}

var gitCommitterTsBytes []byte

gitCommitterTsBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-committer-ts",
})
if err != nil {
return nil, errors.Wrap(err, "read git-committer-ts")
}

var gitAuthorTsBytes []byte

gitAuthorTsBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-author-ts",
})
if err != nil {
return nil, errors.Wrap(err, "read git-author-ts")
}

var gitAuthorEmailBytes []byte

gitAuthorEmailBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-author-email",
})
if err != nil {
return nil, errors.Wrap(err, "read git-author-email")
}

var gitAuthorNameBytes []byte

gitAuthorNameBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-author-name",
})
if err != nil {
return nil, errors.Wrap(err, "read git-author-name")
}

var gitBodyBytes []byte

gitBodyBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-body",
})
if err != nil {
return nil, errors.Wrap(err, "read git-body")
}

var gitRefsBytes []byte

gitRefsBytes, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "git-refs",
})
if err != nil {
return nil, errors.Wrap(err, "read git-refs")
}

var earthfilePathsRaw []byte

earthfilePathsRaw, err = gitMetaRef.ReadFile(ctx, gwclient.ReadRequest{
Filename: "Earthfile-paths",
})
if err != nil {
return nil, errors.Wrap(err, "read Earthfile-paths")
}

isNotHead := func(s string) bool {
return s != "" && s != "HEAD"
}

gitHash := strings.SplitN(string(gitHashBytes), "\n", 2)[0]
gitShortHash := strings.SplitN(string(gitShortHashBytes), "\n", 2)[0]
gitHash := strings.SplitN(string(meta["git-hash"]), "\n", 2)[0]
gitShortHash := strings.SplitN(string(meta["git-short-hash"]), "\n", 2)[0]
gitContentHash := strings.SplitN(string(meta["git-content-hash"]), "\n", 2)[0]
gitBranches := strings.SplitN(gitBranch, "\n", 2)
gitAuthorEmail := strings.SplitN(string(gitAuthorEmailBytes), "\n", 2)[0]
gitAuthorName := strings.SplitN(string(gitAuthorNameBytes), "\n", 2)[0]
gitCoAuthors := gitutil.ParseCoAuthorsFromBody(string(gitBodyBytes))
gitAuthorEmail := strings.SplitN(string(meta["git-author-email"]), "\n", 2)[0]
gitAuthorName := strings.SplitN(string(meta["git-author-name"]), "\n", 2)[0]
gitCoAuthors := gitutil.ParseCoAuthorsFromBody(string(meta["git-body"]))

var gitBranches2 []string

Expand All @@ -495,11 +420,11 @@ func (gr *gitResolver) resolveGitProject(
gitBranches2 = []string{gitRef}
}
} else {
gitBranches2 = []string{strings.SplitN(string(gitDefaultBranchBytes), "\n", 2)[0]}
gitBranches2 = []string{strings.SplitN(string(meta["git-default-branch"]), "\n", 2)[0]}
}
}

gitTags := strings.SplitN(string(gitTagsBytes), "\n", 2)
gitTags := strings.SplitN(string(meta["git-tags"]), "\n", 2)

var gitTags2 []string

Expand All @@ -509,9 +434,9 @@ func (gr *gitResolver) resolveGitProject(
}
}

gitCommitterTs := strings.SplitN(string(gitCommitterTsBytes), "\n", 2)[0]
gitAuthorTs := strings.SplitN(string(gitAuthorTsBytes), "\n", 2)[0]
gitRefs := strings.Split(string(gitRefsBytes), "\n")
gitCommitterTs := strings.SplitN(string(meta["git-committer-ts"]), "\n", 2)[0]
gitAuthorTs := strings.SplitN(string(meta["git-author-ts"]), "\n", 2)[0]
gitRefs := strings.Split(string(meta["git-refs"]), "\n")

var gitRefs2 []string

Expand All @@ -537,6 +462,7 @@ func (gr *gitResolver) resolveGitProject(
rgp = &resolvedGitProject{
hash: gitHash,
shortHash: gitShortHash,
contentHash: gitContentHash,
branches: gitBranches2,
tags: gitTags2,
committerTs: gitCommitterTs,
Expand All @@ -545,7 +471,7 @@ func (gr *gitResolver) resolveGitProject(
authorName: gitAuthorName,
coAuthors: gitCoAuthors,
refs: gitRefs2,
earthfilePaths: strings.Split(strings.TrimSpace(string(earthfilePathsRaw)), "\n"),
earthfilePaths: strings.Split(strings.TrimSpace(string(meta["Earthfile-paths"])), "\n"),
state: pllb.Git(
gitURL,
gitHash,
Expand Down
5 changes: 3 additions & 2 deletions cmd/earthly/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/EarthBuild/earthbuild/buildkitd"
"github.com/EarthBuild/earthbuild/cmd/earthly/common"
"github.com/EarthBuild/earthbuild/cmd/earthly/helper"
"github.com/EarthBuild/earthbuild/util/envutil"
"github.com/EarthBuild/earthbuild/conslogging"
"github.com/EarthBuild/earthbuild/earthfile2llb"
"github.com/EarthBuild/earthbuild/inputgraph"
Expand Down Expand Up @@ -68,12 +69,12 @@ func (app *EarthlyApp) unhideFlags() error {
// TODO delete this check after 2022-03-01
if os.Getenv("EARTHLY_AUTOCOMPLETE_HIDDEN") != "" && os.Getenv("COMP_POINT") == "" {
// only display warning when NOT under complete mode (otherwise we break auto completion)
app.BaseCLI.Console().Warn("Warning: EARTHLY_AUTOCOMPLETE_HIDDEN has been renamed to EARTHLY_SHOW_HIDDEN\n")
app.BaseCLI.Console().Warn("Warning: EARTHLY_AUTOCOMPLETE_HIDDEN has been renamed to EARTH_SHOW_HIDDEN\n")
}

showHidden := false

showHiddenStr := os.Getenv("EARTHLY_SHOW_HIDDEN")
showHiddenStr, _ := envutil.LookupEnv("EARTH_SHOW_HIDDEN", "EARTHLY_SHOW_HIDDEN")
if showHiddenStr != "" {
showHidden, err = strconv.ParseBool(showHiddenStr)
if err != nil {
Expand Down
Loading
Loading