Atlas › Test

commit_on_default_branch

Exact test identity: go.temporal.io/server/cmd/tools/check-dependencies/TestResolveModuleOriginForSpec/commit_on_default_branch

Package
go.temporal.io/server/cmd/tools/check-dependencies
Suite / test hierarchy
TestResolveModuleOriginForSpec/commit_on_default_branch
Test
commit_on_default_branch
Introduced at
main.go ×1 Frontier kind: Joint frontier
Covered ranges
5
Covered lines
11
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/cmd/tools/check-dependencies/main.go 11 covered LOC · 5 ranges

Open complete file

200 // refs/heads/<defaultBranch>: the branch tip to check ancestry against.
201 // Any other exit code indicates an error (e.g. the object does not exist).
202 > func resolveModuleOriginForSpec(ctx context.Context, mod moduleSpec, shortHash string) (bool, error) { main.go
203 > tmpRepo, err := os.MkdirTemp("", "check-dependencies-*")
204 > if err != nil {
205 return false, fmt.Errorf("failed to create temp repo dir: %w", err)
206 }
207 > defer func() { _ = os.RemoveAll(tmpRepo) }() main.go
208
209 > cmd := exec.CommandContext(ctx, "git", "clone", "--bare", "--filter=blob:none", "--single-branch", "--branch", mod.defaultBranch, mod.repoURL, tmpRepo) main.go
210 > out, err := cmd.CombinedOutput()
211 > if err != nil {
212 return false, fmt.Errorf("git clone failed: %w: %s", err, strings.TrimSpace(string(out)))
213 }
214
215 > out, err = exec.CommandContext(ctx, "git", "-C", tmpRepo, "merge-base", "--is-ancestor", shortHash, "refs/heads/"+mod.defaultBranch).CombinedOutput() main.go
216 > if err == nil {
217 > return true, nil main.go
218 > }
219 var exitErr *exec.ExitError
220 if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 {